mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
nova: platform test for portal permission usage
Test and run script showcasing issue #1335. The test mainly tries out syscalls which should not succeed.
This commit is contained in:
parent
77410a08a8
commit
bfa2ad7d47
32
repos/base-nova/run/platform.run
Normal file
32
repos/base-nova/run/platform.run
Normal file
@ -0,0 +1,32 @@
|
||||
build "core init test/platform"
|
||||
|
||||
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-platform">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image "core init test-platform"
|
||||
|
||||
append qemu_args "-nographic -m 128"
|
||||
|
||||
run_genode_until {Test finished} 15
|
||||
|
||||
puts "\nTest succeeded"
|
80
repos/base-nova/src/test/platform/main.cc
Normal file
80
repos/base-nova/src/test/platform/main.cc
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* \brief Some platform tests for the base-nova
|
||||
* \author Alexander Boettcher
|
||||
* \date 2015-01-02
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 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/thread.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/snprintf.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
static unsigned failed = 0;
|
||||
|
||||
void check(uint8_t res, const char *format, ...)
|
||||
{
|
||||
static char buf[128];
|
||||
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
|
||||
String_console sc(buf, sizeof(buf));
|
||||
sc.vprintf(format, list);
|
||||
|
||||
va_end(list);
|
||||
|
||||
if (res == Nova::NOVA_OK) {
|
||||
PERR("res=%u %s - TEST FAILED", res, buf);
|
||||
failed++;
|
||||
}
|
||||
else
|
||||
printf("res=%u %s\n", res, buf);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("testing base-nova platform\n");
|
||||
|
||||
Thread_base * myself = Thread_base::myself();
|
||||
if (!myself)
|
||||
return -__LINE__;
|
||||
|
||||
addr_t sel_pd = cap_map()->insert();
|
||||
addr_t sel_ec = myself->tid().ec_sel;
|
||||
addr_t sel_cap = cap_map()->insert();
|
||||
addr_t handler = 0UL;
|
||||
uint8_t res = 0;
|
||||
|
||||
Nova::Mtd mtd(Nova::Mtd::ALL);
|
||||
|
||||
if (sel_cap == ~0UL || sel_ec == ~0UL || sel_cap == ~0UL)
|
||||
return -__LINE__;
|
||||
|
||||
/* negative syscall tests - they should not succeed */
|
||||
res = Nova::create_pt(sel_cap, sel_pd, sel_ec, mtd, handler);
|
||||
check(res, "create_pt");
|
||||
|
||||
res = Nova::create_sm(sel_cap, sel_pd, 0);
|
||||
check(res, "create_sm");
|
||||
|
||||
/* changing the badge of one of the portal must fail */
|
||||
for (unsigned i = 0; i < (1U << Nova::NUM_INITIAL_PT_LOG2); i++) {
|
||||
addr_t sel_exc = myself->tid().exc_pt_sel + i;
|
||||
res = Nova::pt_ctrl(sel_exc, 0xbadbad);
|
||||
check(res, "pt_ctrl %2u", i);
|
||||
}
|
||||
|
||||
if (!failed)
|
||||
printf("Test finished\n");
|
||||
|
||||
return -failed;
|
||||
}
|
3
repos/base-nova/src/test/platform/target.mk
Normal file
3
repos/base-nova/src/test/platform/target.mk
Normal file
@ -0,0 +1,3 @@
|
||||
TARGET = test-platform
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
Loading…
x
Reference in New Issue
Block a user