mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
lx_hybrid: revive missing errno test
This commit is contained in:
parent
4a92eb5660
commit
fef2551af4
67
base-linux/src/test/lx_hybrid_errno/main.cc
Normal file
67
base-linux/src/test/lx_hybrid_errno/main.cc
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* \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) : _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
base-linux/src/test/lx_hybrid_errno/target.mk
Normal file
3
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 = env cxx thread lx_hybrid
|
Loading…
x
Reference in New Issue
Block a user