diff --git a/repos/os/run/fs_report.run b/repos/os/run/fs_report.run index 4e5341d6c3..a7469fe927 100644 --- a/repos/os/run/fs_report.run +++ b/repos/os/run/fs_report.run @@ -2,10 +2,8 @@ # Build # set build_components { - core init - drivers/timer - server/fs_report - server/vfs + core init drivers/timer + server/fs_report server/fs_rom server/ram_fs test/fs_report } build $build_components @@ -18,67 +16,61 @@ create_boot_directory append config { - + - + - - + - + - - + - - + + + + + + + + + + - - - + - - - - - - - - - - - - - - - - - - - - + - - - - + + - - + + + + + + + + + + } @@ -87,17 +79,13 @@ install_config $config # # Boot modules # - -# generic modules set boot_modules { - core ld.lib.so init - fs_report - timer - vfs + core ld.lib.so init timer + fs_report fs_rom ram_fs test-fs_report } build_boot_image $boot_modules append qemu_args " -nographic" -run_genode_until {.*.*} 20 +run_genode_until {child "test-fs_report" exited with exit value 0.*\n} 30 diff --git a/repos/os/src/test/fs_report/main.cc b/repos/os/src/test/fs_report/main.cc new file mode 100644 index 0000000000..49c6464e6a --- /dev/null +++ b/repos/os/src/test/fs_report/main.cc @@ -0,0 +1,133 @@ +/* + * \brief Test for combining ram_fs, fs_rom, and fs_report + * \author Norman Feske + * \date 2017-06-28 + */ + +/* + * Copyright (C) 2017 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. + */ + +#include +#include +#include +#include +#include + + +namespace Test { + struct Main; + using namespace Genode; +} + + +struct Test::Main +{ + Env &_env; + + Timer::Connection _timer { _env }; + + Constructible _devices_reporter; + Constructible _focus_reporter; + + typedef String<80> Version; + + void _report(Reporter &reporter, Version const &version) + { + Reporter::Xml_generator xml(reporter, [&] () { + xml.attribute("version", version); }); + } + + Constructible _devices_rom; + Constructible _focus_rom; + + Signal_handler
_devices_rom_update_handler { + _env.ep(), *this, &Main::_handle_devices_rom_update }; + + Signal_handler
_focus_rom_update_handler { + _env.ep(), *this, &Main::_handle_focus_rom_update }; + + Constructible > _one_shot_timeout; + + void _handle_init() + { + log("(1) check initial content of \"devices\" ROM"); + _devices_rom.construct(_env, "devices"); + if (_devices_rom->xml().attribute_value("version", Version()) != "initial") { + error("ROM does not contain expected initial conent"); + throw Exception(); + } + + log("(2) issue new \"devices\" report before installing a ROM signal handler"); + _devices_reporter.construct(_env, "devices"); + _devices_reporter->enabled(true); + _report(*_devices_reporter, "version 2"); + + log("(3) wait a bit to let the report reach the RAM fs"); + _one_shot_timeout.construct(_timer, *this, &Main::_handle_timer_1); + _one_shot_timeout->schedule(Microseconds(500*1000)); + } + + void _handle_timer_1(Duration) + { + log("(4) install ROM signal handler, is expected to trigger immediately"); + + _devices_rom->sigh(_devices_rom_update_handler); + } + + void _handle_devices_rom_update() + { + log("(5) received ROM update as expected"); + + _devices_rom->update(); + if (_devices_rom->xml().attribute_value("version", Version()) != "version 2") { + error("unexpected content of \"devices\" ROM after update"); + throw Exception(); + } + + log("(6) request not-yet-available \"focus\" ROM"); + + _focus_rom.construct(_env, "focus"); + _focus_rom->sigh(_focus_rom_update_handler); + + log("(7) wait a bit until generating the focus report"); + _one_shot_timeout.construct(_timer, *this, &Main::_handle_timer_2); + _one_shot_timeout->schedule(Microseconds(500*1000)); + } + + void _handle_timer_2(Duration) + { + log("(8) generate \"focus\" report, is expected to trigger ROM notification"); + _focus_reporter.construct(_env, "focus"); + _focus_reporter->enabled(true); + _report(*_focus_reporter, "focus version 1"); + } + + void _handle_focus_rom_update() + { + _focus_rom->update(); + + if (_focus_rom->xml().attribute_value("version", Version()) != "focus version 1") { + error("unexpected content of \"focus\" ROM"); + throw Exception(); + } + + log("(9) received expected focus ROM content"); + + /* test completed successfully */ + _env.parent().exit(0); + } + + Main(Env &env) : _env(env) + { + log("--- test-fs_report started ---"); + + _handle_init(); + } +}; + + +void Component::construct(Genode::Env &env) { static Test::Main main(env); } diff --git a/repos/os/src/test/fs_report/target.mk b/repos/os/src/test/fs_report/target.mk new file mode 100644 index 0000000000..38a2e99079 --- /dev/null +++ b/repos/os/src/test/fs_report/target.mk @@ -0,0 +1,4 @@ +TARGET = test-fs_report +SRC_CC = main.cc +LIBS = base + diff --git a/tool/autopilot.list b/tool/autopilot.list index bfcae085dd..6a1a381cff 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -105,3 +105,4 @@ init nic_dump slab ada +fs_report