Test capability integrity
The test application tries to print a message using init's own LOG session without permission. This patch fixes #106.
This commit is contained in:
parent
7ed13b3920
commit
e6f6defaca
39
base/run/cap_integrity.run
Normal file
39
base/run/cap_integrity.run
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
build "core init test/cap_integrity"
|
||||||
|
|
||||||
|
create_boot_directory
|
||||||
|
|
||||||
|
install_config {
|
||||||
|
<config>
|
||||||
|
<parent-provides>
|
||||||
|
<service name="ROM"/>
|
||||||
|
<service name="RAM"/>
|
||||||
|
<service name="CPU"/>
|
||||||
|
<service name="RM"/>
|
||||||
|
<service name="CAP"/>
|
||||||
|
<service name="PD"/>
|
||||||
|
<service name="SIGNAL"/>
|
||||||
|
<service name="LOG"/>
|
||||||
|
</parent-provides>
|
||||||
|
<default-route>
|
||||||
|
<any-service> <parent/> </any-service>
|
||||||
|
</default-route>
|
||||||
|
<start name="test-cap_integrity">
|
||||||
|
<resource name="RAM" quantum="10M"/>
|
||||||
|
</start>
|
||||||
|
</config>
|
||||||
|
}
|
||||||
|
|
||||||
|
build_boot_image "core init test-cap_integrity"
|
||||||
|
|
||||||
|
append qemu_args "-nographic -m 64"
|
||||||
|
|
||||||
|
# increase expect buffer size, since there might be many log messages
|
||||||
|
match_max -d 100000
|
||||||
|
|
||||||
|
run_genode_until {child exited with exit value 0.*} 60
|
||||||
|
|
||||||
|
if {[regexp {\[init\] test message} $output]} {
|
||||||
|
exit -1
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "Test succeeded"
|
36
base/src/test/cap_integrity/main.cc
Normal file
36
base/src/test/cap_integrity/main.cc
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* \brief Testing capability integrity
|
||||||
|
* \author Christian Prochaska
|
||||||
|
* \date 2012-02-10
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2012 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 <log_session/connection.h>
|
||||||
|
|
||||||
|
using namespace Genode;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
printf("--- capability integrity test ---\n");
|
||||||
|
|
||||||
|
/* try the first 1000 local name IDs */
|
||||||
|
for (int local_name = 0; local_name < 1000; local_name++) {
|
||||||
|
Log_session_capability log_session_cap =
|
||||||
|
reinterpret_cap_cast<Log_session>(Native_capability(env()->ram_session_cap().dst(), local_name));
|
||||||
|
Log_session_client log_session_client(log_session_cap);
|
||||||
|
try {
|
||||||
|
log_session_client.write("test message");
|
||||||
|
} catch(...) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("--- finished capability integrity test ---\n");
|
||||||
|
return 0;
|
||||||
|
}
|
3
base/src/test/cap_integrity/target.mk
Normal file
3
base/src/test/cap_integrity/target.mk
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
TARGET = test-cap_integrity
|
||||||
|
SRC_CC = main.cc
|
||||||
|
LIBS = env
|
Loading…
Reference in New Issue
Block a user