mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-13 12:48:20 +00:00
Move repositories to 'repos/' subdirectory
This patch changes the top-level directory layout as a preparatory step for improving the tools for managing 3rd-party source codes. The rationale is described in the issue referenced below. Issue #1082
This commit is contained in:
52
repos/base-linux/src/test/lx_hybrid_ctors/main.cc
Normal file
52
repos/base-linux/src/test/lx_hybrid_ctors/main.cc
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* \brief Test if global static constructors in hybrid applications get called
|
||||
* \author Christian Prochaska
|
||||
* \date 2011-11-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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.
|
||||
*/
|
||||
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
#include "testlib.h"
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
struct Testapp_testclass
|
||||
{
|
||||
Testapp_testclass()
|
||||
{
|
||||
Genode::printf("Global static constructor of Genode application called\n");
|
||||
}
|
||||
|
||||
void dummy() { }
|
||||
};
|
||||
|
||||
|
||||
extern Testlib_testclass testlib_testobject;
|
||||
|
||||
Testapp_testclass testapp_testobject;
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("--- lx_hybrid global static constructor test ---\n");
|
||||
|
||||
/*
|
||||
* Call a dummy function on each test object to make sure that the
|
||||
objects don't get optimized out.
|
||||
*/
|
||||
testlib_testobject.dummy();
|
||||
testapp_testobject.dummy();
|
||||
|
||||
printf("--- returning from main ---\n");
|
||||
|
||||
return 0;
|
||||
}
|
22
repos/base-linux/src/test/lx_hybrid_ctors/target.mk
Normal file
22
repos/base-linux/src/test/lx_hybrid_ctors/target.mk
Normal file
@ -0,0 +1,22 @@
|
||||
TARGET = test-lx_hybrid_ctors
|
||||
SRC_CC = main.cc
|
||||
LIBS = lx_hybrid
|
||||
|
||||
TESTLIB_SO = libtestlib.so
|
||||
TESTLIB_SRC_CC = testlib.cc
|
||||
|
||||
EXT_OBJECTS += $(BUILD_BASE_DIR)/test/lx_hybrid_ctors/$(TESTLIB_SO)
|
||||
|
||||
$(TARGET): $(TESTLIB_SO)
|
||||
|
||||
$(TESTLIB_SO): $(TESTLIB_SRC_CC)
|
||||
$(MSG_BUILD)$(TESTLIB_SO)
|
||||
$(VERBOSE)g++ $(CC_MARCH) -fPIC -c $^
|
||||
$(VERBOSE)g++ $(CC_MARCH) -shared -o $@ $(notdir $(^:.cc=.o))
|
||||
|
||||
clean_libtestlib:
|
||||
$(VERBOSE)rm -f $(TESTLIB_SO) $(TESTLIB_SRC_CC:.cc=.o)
|
||||
|
||||
clean: clean_libtestlib
|
||||
|
||||
vpath testlib.cc $(PRG_DIR)
|
28
repos/base-linux/src/test/lx_hybrid_ctors/testlib.cc
Normal file
28
repos/base-linux/src/test/lx_hybrid_ctors/testlib.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* \brief Test if global static constructors in host shared libs get called
|
||||
* \author Christian Prochaska
|
||||
* \date 2011-11-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "testlib.h"
|
||||
|
||||
|
||||
Testlib_testclass::Testlib_testclass()
|
||||
{
|
||||
printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n");
|
||||
}
|
||||
|
||||
|
||||
void Testlib_testclass::dummy() { }
|
||||
|
||||
|
||||
Testlib_testclass testlib_testobject;
|
18
repos/base-linux/src/test/lx_hybrid_ctors/testlib.h
Normal file
18
repos/base-linux/src/test/lx_hybrid_ctors/testlib.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* \brief Test if global static constructors in host shared libs get called
|
||||
* \author Christian Prochaska
|
||||
* \date 2011-11-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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.
|
||||
*/
|
||||
|
||||
struct Testlib_testclass
|
||||
{
|
||||
Testlib_testclass();
|
||||
void dummy();
|
||||
};
|
68
repos/base-linux/src/test/lx_hybrid_errno/main.cc
Normal file
68
repos/base-linux/src/test/lx_hybrid_errno/main.cc
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* \brief Test for thread-local errno handling of hybrid Linux/Genode programs
|
||||
* \author Norman Feske
|
||||
* \date 2011-12-05
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/thread.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
enum { STACK_SIZE = 4096 };
|
||||
|
||||
struct Thread : Genode::Thread<STACK_SIZE>
|
||||
{
|
||||
Genode::Lock &_barrier;
|
||||
|
||||
Thread(Genode::Lock &barrier)
|
||||
: Genode::Thread<STACK_SIZE>("stat"), _barrier(barrier) { start(); }
|
||||
|
||||
void entry()
|
||||
{
|
||||
/*
|
||||
* Stat syscall should return with errno ENOENT
|
||||
*/
|
||||
struct stat buf;
|
||||
int ret = stat("", &buf);
|
||||
|
||||
Genode::printf("thread: stat returned %d, errno=%d\n", ret, errno);
|
||||
|
||||
/*
|
||||
* Let main thread procees
|
||||
*/
|
||||
_barrier.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
Genode::printf("--- thread-local errno test ---\n");
|
||||
|
||||
static Genode::Lock barrier(Genode::Lock::LOCKED);
|
||||
|
||||
int const orig_errno = errno;
|
||||
|
||||
Genode::printf("main: before thread creation, errno=%d\n", orig_errno);
|
||||
|
||||
/* create thread, which modifies its thread-local errno value */
|
||||
static Thread thread(barrier);
|
||||
|
||||
/* block until the thread performed a 'stat' syscall */
|
||||
barrier.lock();
|
||||
|
||||
Genode::printf("main: after thread completed, errno=%d\n", errno);
|
||||
|
||||
if (orig_errno != errno) {
|
||||
PERR("unexpected change of main thread's errno value");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Genode::printf("--- finished thread-local errno test ---\n");
|
||||
return 0;
|
||||
}
|
3
repos/base-linux/src/test/lx_hybrid_errno/target.mk
Normal file
3
repos/base-linux/src/test/lx_hybrid_errno/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-lx_hybrid_errno
|
||||
SRC_CC = main.c
|
||||
LIBS = lx_hybrid
|
37
repos/base-linux/src/test/lx_hybrid_exception/main.cc
Normal file
37
repos/base-linux/src/test/lx_hybrid_exception/main.cc
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* \brief Test if the exception mechanism works in hybrid applications
|
||||
* \author Christian Prochaska
|
||||
* \date 2011-11-22
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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.
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
class Test_exception { };
|
||||
|
||||
/**
|
||||
* Main program
|
||||
*/
|
||||
int main(int, char **)
|
||||
{
|
||||
printf("--- lx_hybrid exception test ---\n");
|
||||
|
||||
try {
|
||||
printf("Throwing Test_exception\n");
|
||||
throw Test_exception();
|
||||
} catch(Test_exception) {
|
||||
printf("Caught Test_exception\n");
|
||||
}
|
||||
|
||||
printf("--- returning from main ---\n");
|
||||
|
||||
return 0;
|
||||
}
|
3
repos/base-linux/src/test/lx_hybrid_exception/target.mk
Normal file
3
repos/base-linux/src/test/lx_hybrid_exception/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-lx_hybrid_exception
|
||||
SRC_CC = main.cc
|
||||
LIBS = lx_hybrid
|
62
repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc
Normal file
62
repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* \brief Test for performing IPC from a pthread created outside of Genode
|
||||
* \author Norman Feske
|
||||
* \date 2011-12-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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/thread.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
static Genode::Lock *main_wait_lock()
|
||||
{
|
||||
static Genode::Lock inst(Genode::Lock::LOCKED);
|
||||
return &inst;
|
||||
}
|
||||
|
||||
|
||||
static void *pthread_entry(void *)
|
||||
{
|
||||
PINF("first message");
|
||||
|
||||
/*
|
||||
* Without the lazy initialization of 'Thread_base' objects for threads
|
||||
* created w/o Genode's Thread API, the printing of the first message will
|
||||
* never return because the IPC reply could not be delivered.
|
||||
*
|
||||
* With the on-demand creation of 'Thread_base' objects, the second message
|
||||
* will appear in the LOG output.
|
||||
*/
|
||||
|
||||
PINF("second message");
|
||||
|
||||
main_wait_lock()->unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
Genode::printf("--- pthread IPC test ---\n");
|
||||
|
||||
/* create thread w/o Genode's thread API */
|
||||
pthread_t pth;
|
||||
pthread_create(&pth, 0, pthread_entry, 0);
|
||||
|
||||
/* wait until 'pthread_entry' finished */
|
||||
main_wait_lock()->lock();
|
||||
|
||||
Genode::printf("--- finished pthread IPC test ---\n");
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
TARGET = test-lx_hybrid_pthread_ipc
|
||||
SRC_CC = main.c
|
||||
LIBS = lx_hybrid
|
10
repos/base-linux/src/test/lx_rmap/dynamic/target.mk
Normal file
10
repos/base-linux/src/test/lx_rmap/dynamic/target.mk
Normal file
@ -0,0 +1,10 @@
|
||||
# dynamic variant is not supported in hybrid mode
|
||||
ifeq ($(filter-out $(SPECS),always_hybrid),)
|
||||
REQUIRES = plain_linux
|
||||
endif
|
||||
|
||||
TARGET = test-lx_rmap_dynamic
|
||||
SRC_CC = main.cc
|
||||
LIBS = base ld
|
||||
|
||||
vpath main.cc $(PRG_DIR)/..
|
105
repos/base-linux/src/test/lx_rmap/main.cc
Normal file
105
repos/base-linux/src/test/lx_rmap/main.cc
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* \brief Linux region-map test
|
||||
* \author Christian Helmuth
|
||||
* \date 2013-09-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-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/printf.h>
|
||||
#include <base/env.h>
|
||||
#include <base/crt0.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/thread.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <rm_session/connection.h>
|
||||
|
||||
|
||||
|
||||
static void blob() __attribute__((used));
|
||||
static void blob()
|
||||
{
|
||||
asm volatile (
|
||||
".balign 4096, -1\n"
|
||||
"blob_beg:\n"
|
||||
".space 16*4096, -2\n"
|
||||
"blob_end:\n"
|
||||
".global blob_beg\n"
|
||||
".global blob_end\n"
|
||||
: : : );
|
||||
}
|
||||
|
||||
|
||||
extern unsigned long blob_beg;
|
||||
extern unsigned long blob_end;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
/* activate for early printf in Rm_session_mmap::attach() etc. */
|
||||
if (0) Thread_base::trace("FOO");
|
||||
|
||||
/* induce initial heap expansion to remove RM noise */
|
||||
if (1) {
|
||||
void *addr(env()->heap()->alloc(0x100000));
|
||||
env()->heap()->free(addr, 0);
|
||||
}
|
||||
|
||||
addr_t beg((addr_t)&blob_beg);
|
||||
addr_t end(align_addr((addr_t)&blob_end, 12));
|
||||
|
||||
size_t size(end - beg);
|
||||
|
||||
PLOG("blob region region [%016lx,%016lx) size=%zx", beg, end, size);
|
||||
|
||||
/* RAM dataspace attachment overlapping binary */
|
||||
try {
|
||||
Ram_dataspace_capability ds(env()->ram_session()->alloc(size));
|
||||
|
||||
PLOG("before RAM dataspace attach");
|
||||
env()->rm_session()->attach_at(ds, beg);
|
||||
PERR("after RAM dataspace attach -- ERROR");
|
||||
} catch (Rm_session::Region_conflict) {
|
||||
PLOG("OK caught Region_conflict exception");
|
||||
}
|
||||
|
||||
/* empty managed dataspace overlapping binary */
|
||||
try {
|
||||
Rm_connection rm(0, size);
|
||||
Dataspace_capability ds(rm.dataspace());
|
||||
|
||||
PLOG("before sub-RM dataspace attach");
|
||||
env()->rm_session()->attach_at(ds, beg);
|
||||
PERR("after sub-RM dataspace attach -- ERROR");
|
||||
} catch (Rm_session::Region_conflict) {
|
||||
PLOG("OK caught Region_conflict exception");
|
||||
}
|
||||
|
||||
/* sparsely populated managed dataspace in free VM area */
|
||||
try {
|
||||
Rm_connection rm(0, 0x100000);
|
||||
|
||||
rm.attach_at(env()->ram_session()->alloc(0x1000), 0x1000);
|
||||
|
||||
Dataspace_capability ds(rm.dataspace());
|
||||
|
||||
PLOG("before populated sub-RM dataspace attach");
|
||||
char *addr = (char *)env()->rm_session()->attach(ds) + 0x1000;
|
||||
PLOG("after populated sub-RM dataspace attach / before touch");
|
||||
char const val = *addr;
|
||||
*addr = 0x55;
|
||||
PLOG("after touch (%x/%x)", val, *addr);
|
||||
} catch (Rm_session::Region_conflict) {
|
||||
PLOG("OK caught Region_conflict exception -- ERROR");
|
||||
}
|
||||
|
||||
sleep_forever();
|
||||
}
|
5
repos/base-linux/src/test/lx_rmap/static/target.mk
Normal file
5
repos/base-linux/src/test/lx_rmap/static/target.mk
Normal file
@ -0,0 +1,5 @@
|
||||
TARGET = test-lx_rmap_static
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
||||
|
||||
vpath main.cc $(PRG_DIR)/..
|
53
repos/base-linux/src/test/rm_session_mmap/main.cc
Normal file
53
repos/base-linux/src/test/rm_session_mmap/main.cc
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* \brief Linux: Test bug in rm_session_mmap.cc
|
||||
* \author Christian Helmuth
|
||||
* \date 2012-12-19
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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.
|
||||
*/
|
||||
|
||||
#include <base/env.h>
|
||||
#include <base/printf.h>
|
||||
#include <ram_session/connection.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
|
||||
static void test_linux_rmmap_bug()
|
||||
{
|
||||
enum { QUOTA = 1*1024*1024, CHUNK = 0x1000, ROUNDS = 0x10 };
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
PLOG("line: %d", __LINE__);
|
||||
Ram_connection ram;
|
||||
|
||||
#if 1 /* transfer quota */
|
||||
PLOG("line: %d", __LINE__);
|
||||
ram.ref_account(env()->ram_session_cap());
|
||||
env()->ram_session()->transfer_quota(ram.cap(), QUOTA);
|
||||
#endif
|
||||
|
||||
PLOG("line: %d", __LINE__);
|
||||
for (unsigned i = 0; i < ROUNDS; ++i) {
|
||||
Ram_dataspace_capability ds(ram.alloc(CHUNK));
|
||||
PLOG("%d of %d pages allocated", (i + 1), ROUNDS);
|
||||
}
|
||||
|
||||
PLOG("Done.");
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
Genode::printf("--- test-rm_session_mmap started ---\n");
|
||||
|
||||
// Timer::Connection timer;
|
||||
// timer.msleep(1000);
|
||||
|
||||
test_linux_rmmap_bug();
|
||||
}
|
3
repos/base-linux/src/test/rm_session_mmap/target.mk
Normal file
3
repos/base-linux/src/test/rm_session_mmap/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-rm_session_mmap
|
||||
LIBS = base
|
||||
SRC_CC = main.cc
|
22
repos/base-linux/src/test/sub_rm/config.h
Normal file
22
repos/base-linux/src/test/sub_rm/config.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* \brief Linux-specific policy for sub_rm test
|
||||
* \author Norman Feske
|
||||
* \date 2011-11-22
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Linux implementation of the RM service does not support attaching
|
||||
* the same sub RM session twice. This configuration enables the respective
|
||||
* error-handling test.
|
||||
*/
|
||||
enum { attach_twice_forbidden = true };
|
||||
|
||||
enum { support_attach_sub_any = false };
|
||||
|
Reference in New Issue
Block a user