mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
parent
6aa0ab1bf9
commit
a596bfe797
26
base/run/thread.run
Normal file
26
base/run/thread.run
Normal file
@ -0,0 +1,26 @@
|
||||
build "core init test/thread"
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="LOG"/>
|
||||
<service name="RM"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> </any-service>
|
||||
</default-route>
|
||||
<start name="test-thread">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image "core init test-thread"
|
||||
|
||||
append qemu_args "-nographic -m 64"
|
||||
|
||||
run_genode_until "child exited with exit value 0.*\n" 10
|
||||
|
||||
puts "Test succeeded"
|
47
base/src/test/thread/main.cc
Normal file
47
base/src/test/thread/main.cc
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* \brief Testing thread environment of a main thread
|
||||
* \author Alexander Boettcher
|
||||
* \date 2013-12-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/printf.h>
|
||||
#include <base/thread.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* check wether my thread object exists */
|
||||
Thread_base * myself = Genode::Thread_base::myself();
|
||||
if (!myself) { return -1; }
|
||||
printf("thread base %p\n", myself);
|
||||
|
||||
/* check wether my stack is inside the first context region */
|
||||
addr_t const context_base = Native_config::context_area_virtual_base();
|
||||
addr_t const context_size = Native_config::context_area_virtual_size();
|
||||
addr_t const context_top = context_base + context_size;
|
||||
addr_t const stack_top = (addr_t)myself->stack_top();
|
||||
addr_t const stack_base = (addr_t)myself->stack_base();
|
||||
if (stack_top <= context_base) { return -2; }
|
||||
if (stack_top > context_top) { return -3; }
|
||||
if (stack_base >= context_top) { return -4; }
|
||||
if (stack_base < context_base) { return -5; }
|
||||
printf("thread stack top %p\n", myself->stack_top());
|
||||
printf("thread stack bottom %p\n", myself->stack_base());
|
||||
|
||||
/* check wether my stack pointer is inside my stack */
|
||||
unsigned dummy = 0;
|
||||
addr_t const sp = (addr_t)&dummy;
|
||||
if (sp >= stack_top) { return -6; }
|
||||
if (sp < stack_base) { return -7; }
|
||||
printf("thread stack pointer %p\n", (void *)sp);
|
||||
return 0;
|
||||
}
|
3
base/src/test/thread/target.mk
Normal file
3
base/src/test/thread/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-thread
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
Loading…
Reference in New Issue
Block a user