lx_hybrid: revive missing errno test

This commit is contained in:
Christian Helmuth 2012-10-24 18:24:17 +02:00 committed by Stefan Kalkowski
parent 4a92eb5660
commit fef2551af4
2 changed files with 70 additions and 0 deletions

View 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;
}

View File

@ -0,0 +1,3 @@
TARGET = test-lx_hybrid_errno
SRC_CC = main.c
LIBS = env cxx thread lx_hybrid