depot_autopilot: test case for entrypoint

Test for entrypoint destruction and signalling.

Issue #3704
This commit is contained in:
Christian Helmuth 2020-03-23 15:44:24 +01:00
parent f051065582
commit 69080014b0
11 changed files with 207 additions and 33 deletions

View File

@ -0,0 +1 @@
Scenario that tests Genode::Entrypoint functionality

View File

@ -0,0 +1,2 @@
_/src/init
_/src/test-entrypoint

View File

@ -0,0 +1 @@
2020-03-21 c9ee8f61ce95fdfdb183ba48b73d66c05f24230e

View File

@ -0,0 +1,28 @@
<runtime ram="32M" caps="1000" binary="init">
<events>
<timeout meaning="failed" sec="60" />
<log meaning="succeeded">child "test-entrypoint" exited with exit value 0</log>
</events>
<content>
<rom label="ld.lib.so"/>
<rom label="test-entrypoint"/>
</content>
<config>
<parent-provides>
<service name="LOG"/>
<service name="PD"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="Timer"/>
</parent-provides>
<default-route>
<any-service> <parent/> </any-service>
</default-route>
<start name="test-entrypoint" caps="100">
<resource name="RAM" quantum="10M"/>
</start>
</config>
</runtime>

View File

@ -0,0 +1,2 @@
SRC_DIR = src/test/entrypoint
include $(GENODE_DIR)/repos/base/recipes/src/content.inc

View File

@ -0,0 +1 @@
2020-03-21 3b4a05c0704d0259fb66ad1cea1166231a2f19dd

View File

@ -0,0 +1 @@
base

View File

@ -0,0 +1,167 @@
/*
* \brief Entrypoint test
* \author Christian Helmuth
* \date 2020-03-20
*/
/*
* Copyright (C) 2020 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/component.h>
#include <base/rpc_server.h>
#include <base/rpc_client.h>
#include <timer_session/connection.h>
using namespace Genode;
/**
* Test destruction of entrypoint with yet not dissolved components
*/
namespace Test_destruct {
struct Session;
struct Component;
}
struct Test_destruct::Session : Genode::Session
{
static const char *service_name() { return "Test_destruct"; }
GENODE_RPC(Rpc_test_untyped, void, test_untyped, unsigned);
GENODE_RPC_INTERFACE(Rpc_test_untyped);
};
struct Test_destruct::Component : Genode::Rpc_object<Test_destruct::Session,
Test_destruct::Component>
{
void test_untyped(unsigned) { }
};
/**
* Test signal handling with proxy and wait_and_dispatch_one_io_signal()
*/
namespace Test_signal {
struct Session;
struct Session_component;
struct Entrypoint;
enum { TIMER_DURATION = 10'000ul };
}
struct Test_signal::Session : Genode::Session
{
static const char *service_name() { return "Test_signal"; }
GENODE_RPC(Rpc_rpc, void, rpc);
GENODE_RPC_INTERFACE(Rpc_rpc);
};
struct Test_signal::Session_component : Rpc_object<Test_signal::Session,
Test_signal::Session_component>
{
Genode::Entrypoint &ep;
Session_component(Genode::Entrypoint &ep) : ep(ep) { }
void stats()
{
log("rpcs=", rpc_count, " signals=", sig_count, " timeout-signals=", sig_timeout_count);
}
unsigned rpc_count { 0 };
unsigned sig_count { 0 };
unsigned sig_timeout_count { 0 };
void rpc()
{
++rpc_count;
ep.wait_and_dispatch_one_io_signal();
}
void sig() { ++sig_count; }
void sig_timeout() { ++sig_timeout_count; }
};
struct Test_signal::Entrypoint : Genode::Entrypoint
{
Env &env;
Session_component sc { *this };
Capability<Session> cap { manage(sc) };
Io_signal_handler<Test_signal::Entrypoint> sigh {
*this, *this, &Test_signal::Entrypoint::handle_signal };
Timer::Connection timer { env };
Io_signal_handler<Test_signal::Entrypoint> timer_sigh {
*this, *this, &Test_signal::Entrypoint::handle_timer_signal };
Entrypoint(Env &env)
:
Genode::Entrypoint(env, 0x4000, "test_ep", Affinity::Location()),
env(env)
{
timer.sigh(timer_sigh);
timer.trigger_periodic(Test_signal::TIMER_DURATION/2);
}
void handle_signal() { sc.sig(); }
void handle_timer_signal() { sc.sig_timeout(); }
};
struct Main
{
Env &env;
Test_signal::Entrypoint test_ep { env };
Timer::Connection timer { env };
Signal_handler<Main> sigh { env.ep(), *this, &Main::handle_signal };
unsigned rpc_count { 0 };
Main(Env &env) : env(env)
{
timer.sigh(sigh);
timer.trigger_periodic(Test_signal::TIMER_DURATION);
}
void handle_signal()
{
Signal_transmitter(test_ep.sigh).submit();
test_ep.cap.call<Test_signal::Session::Rpc_rpc>();
if (++rpc_count % 100 == 0)
test_ep.sc.stats();
if (rpc_count == 3'000)
env.parent().exit(0);
}
};
void Component::construct(Env &env)
{
/* test destruct */
Test_destruct::Component c;
{
Entrypoint ep(env, 0x4000, "test_destruct_ep", Affinity::Location());
ep.manage(c);
}
/* test signal */
static Main inst { env };
}

View File

@ -0,0 +1,3 @@
TARGET = test-entrypoint
SRC_CC = main.cc
LIBS = base

View File

@ -683,38 +683,6 @@ static void test_successive_create_destroy_threads(Env &env)
}
}
/**
* Test destruction of entrypoint with yet not dissolved components
*/
namespace Test {
struct Session;
struct Server;
struct Component;
}
struct Test::Session : Genode::Session
{
static const char *service_name() { return "EP_TEST"; }
GENODE_RPC(Rpc_test_untyped, void, test_untyped, unsigned);
GENODE_RPC_INTERFACE(Rpc_test_untyped);
};
struct Test::Component : Genode::Rpc_object<Test::Session, Test::Component>
{
void test_untyped(unsigned) { }
};
static void test_entrypoint_destruction(Genode::Env &env)
{
Test::Component c;
{
Entrypoint ep(env, 8192 /* STACK*/, "test_ep", Affinity::Location());
ep.manage(c);
}
}
/******************************************************
** Test destruction of inter-dependent CPU sessions **
******************************************************/
@ -755,7 +723,6 @@ void Component::construct(Env &env)
test_create_as_many_threads(env);
test_successive_create_destroy_threads(env);
test_entrypoint_destruction(env);
} catch (int error) {
Genode::error("error ", error);
throw;

View File

@ -656,6 +656,7 @@ set default_test_pkgs {
test-dynamic_config
test-dynamic_config_loader
test-dynamic_config_slave
test-entrypoint
test-expat
test-fault_detection
test-fs_log