mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 08:25:38 +00:00
Test for enforcing dataspace ownership
This commit is contained in:
parent
88aab61e09
commit
d6f956e37e
42
base/run/ds_ownership.run
Normal file
42
base/run/ds_ownership.run
Normal file
@ -0,0 +1,42 @@
|
||||
build "core init test/ds_ownership"
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<start name="test-ds_ownership">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<route><any-service><parent/></any-service></route>
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image "core init test-ds_ownership"
|
||||
|
||||
run_genode_until {.*Test ended.*\.} 10
|
||||
|
||||
grep_output {\[init -\> test-ds_ownership\] Test ended}
|
||||
|
||||
compare_output_to {
|
||||
[init -> test-ds_ownership] Test ended successfully.
|
||||
}
|
57
base/src/test/ds_ownership/main.cc
Normal file
57
base/src/test/ds_ownership/main.cc
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* \brief Testing the distinction between user and owner of a RAM dataspace
|
||||
* \author Martin Stein
|
||||
* \date 2012-04-19
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <ram_session/connection.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Create some RAM sessions */
|
||||
printf("Dataspace ownership test\n");
|
||||
static Ram_connection ram_1;
|
||||
static Ram_connection ram_2;
|
||||
|
||||
/* Allocate dataspace at one of the RAM sessions */
|
||||
ram_1.ref_account(env()->ram_session_cap());
|
||||
env()->ram_session()->transfer_quota(ram_1.cap(), 8*1024);
|
||||
Ram_dataspace_capability ds = ram_1.alloc(sizeof(unsigned));
|
||||
|
||||
/* Try to free dataspace at another RAM session */
|
||||
ram_2.free(ds);
|
||||
|
||||
/* Check if dataspace was falsely freed */
|
||||
try { env()->rm_session()->attach(ds); }
|
||||
catch (...) {
|
||||
printf("Test ended faulty.\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Try to free dataspace at its originating RAM session */
|
||||
ram_1.free(ds);
|
||||
|
||||
/* Check if dataspace was freed as expected */
|
||||
try { env()->rm_session()->attach(ds); }
|
||||
catch (...) {
|
||||
printf("Test ended successfully.\n");
|
||||
return 0;
|
||||
}
|
||||
printf("Test ended faulty.\n");
|
||||
return -4;
|
||||
}
|
||||
|
3
base/src/test/ds_ownership/target.mk
Normal file
3
base/src/test/ds_ownership/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-ds_ownership
|
||||
SRC_CC = main.cc
|
||||
LIBS = env thread
|
Loading…
x
Reference in New Issue
Block a user