genode/repos/os/src/test/dynamic_config/main.cc
Martin Stein ad2d1fe586 os/test: transition to new base API
For all tests
* use Component::construct instead of main
* use new connection constructors with env argument
* use log instead of printf

For some tests
* replace signal receivers with signal handlers
* replace global static variables with Main class members
* remove unnecessary multithreading
* model test steps as classes that are independent from each other and managed
  by Main as constructibles
* use references instead of pointers and exceptions instead of error codes
* use Attached_* helpers intead of doing attach/detach manually
* use helpers like String, Id_space, Registry instead of arrays and lists
* make the run script suitable for automated execution and conclusion

Ref #1987
2017-01-31 12:01:15 +01:00

46 lines
1.0 KiB
C++

/*
* \brief Test for changing configuration at runtime
* \author Norman Feske
* \author Martin Stein
* \date 2012-04-04
*/
/*
* Copyright (C) 2012-2017 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/component.h>
#include <base/attached_rom_dataspace.h>
using namespace Genode;
struct Main
{
Env &env;
Attached_rom_dataspace config { env, "config" };
Signal_handler<Main> config_handler { env.ep(), *this, &Main::handle_config };
void handle_config()
{
config.update();
try {
long counter = 1;
config.xml().sub_node("counter").value(&counter);
log("obtained counter value ", counter, " from config");
}
catch (...) { error("could not parse configuration"); }
}
Main(Env &env) : env(env)
{
handle_config();
config.sigh(config_handler);
}
};
void Component::construct(Env &env) { static Main main(env); }