mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-13 04:38:20 +00:00
test/synced_interface: move to base
The test uses only stuff from the base repo. Ref #1987
This commit is contained in:
committed by
Norman Feske
parent
ad2d1fe586
commit
d1134644cc
54
repos/base/src/test/synced_interface/main.cc
Normal file
54
repos/base/src/test/synced_interface/main.cc
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* \brief Test for 'Synced_interface'
|
||||
* \author Norman Feske
|
||||
* \date 2013-05-16
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/synced_interface.h>
|
||||
#include <base/component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
struct Adder
|
||||
{
|
||||
int add(int a, int b)
|
||||
{
|
||||
log("adding ", a, " + ", b);
|
||||
return a + b;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Pseudo_lock
|
||||
{
|
||||
void lock() { log("lock"); }
|
||||
void unlock() { log("unlock"); }
|
||||
};
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Pseudo_lock lock;
|
||||
Adder adder;
|
||||
Synced_interface<Adder, Pseudo_lock> synced_adder { lock, &adder };
|
||||
|
||||
Main(Env &env)
|
||||
{
|
||||
log("--- Synced interface test ---");
|
||||
int const res = synced_adder()->add(13, 14);
|
||||
log("result is ", res);
|
||||
log("--- Synced interface test finished ---");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Env &env) { static Main main(env); }
|
3
repos/base/src/test/synced_interface/target.mk
Normal file
3
repos/base/src/test/synced_interface/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-synced_interface
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
Reference in New Issue
Block a user