report_rom: deny requests for existing reports

If a requested report already exists the request is denied with
Invalid_args.

Further, I dusted the report_rom test and added it to the
autopilot list.
This commit is contained in:
Christian Helmuth 2015-08-20 16:00:57 +02:00
parent 9a326bed2d
commit e2f2ac567e
4 changed files with 44 additions and 15 deletions

View File

@ -7,15 +7,15 @@ install_config {
<parent-provides>
<service name="ROM"/>
<service name="RAM"/>
<service name="CPU"/>
<service name="RM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="CAP"/>
<service name="PD"/>
<service name="IRQ"/>
<service name="IO_PORT"/>
<service name="IO_MEM"/>
<service name="SIGNAL"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
<service name="SIGNAL"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
@ -26,15 +26,20 @@ install_config {
</start>
<start name="report_rom">
<resource name="RAM" quantum="2M"/>
<provides> <service name="ROM" />
<service name="Report" /> </provides>
<provides> <service name="ROM"/> <service name="Report"/> </provides>
<config>
<rom>
<policy label="test-report_rom -> brightness"
report="test-report_rom -> brightness"/>
</rom>
</config>
</start>
<start name="test-report_rom">
<resource name="RAM" quantum="2M"/>
<route>
<service name="ROM">
<if-arg key="label" value="test-report_rom/brightness" />
<child name="report_rom" />
<if-arg key="label" value="brightness"/>
<child name="report_rom"/>
</service>
<any-service> <parent/> <any-child/> </any-service>
</route>
@ -56,15 +61,19 @@ compare_output_to {
[init -> test-report_rom] Reporter: brightness 10
[init -> test-report_rom] ROM client: request brightness report
[init -> test-report_rom] -> <brightness brightness="10"/>
[init -> test-report_rom]
[init -> test-report_rom] Reporter: updated brightness to 77
[init -> test-report_rom] ROM client: wait for update notification
[init -> test-report_rom] ROM client: got signal
[init -> test-report_rom] ROM client: request updated brightness report
[init -> test-report_rom] -> <brightness brightness="77"/>
[init -> test-report_rom]
[init -> test-report_rom] Reporter: close report session
[init -> test-report_rom] ROM client: wait for update notification
[init -> test-report_rom] ROM client: detected vanished report
[init -> test-report_rom] ROM client: ROM is available despite report was closed - OK
[init -> test-report_rom] Reporter: start reporting (while the ROM client still listens)
[init -> test-report_rom] ROM client: wait for update notification
[init -> test-report_rom] ROM client: try to open the same report again
[init -> test-report_rom] ROM client: catched Parent::Service_denied - OK
[init -> test-report_rom] --- test-report_rom finished ---
}

View File

@ -53,6 +53,15 @@ struct Report::Session_component : Genode::Rpc_object<Session>, Rom::Writer
return i;
}
Rom::Module &_create_module(Rom::Module::Name const &name)
{
try {
return _registry.lookup(*this, name);
} catch (...) {
throw Genode::Root::Invalid_args();
}
}
public:
Session_component(Rom::Module::Name const &name, size_t buffer_size,
@ -60,7 +69,7 @@ struct Report::Session_component : Genode::Rpc_object<Session>, Rom::Writer
:
_registry(registry),
_ds(Genode::env()->ram_session(), buffer_size),
_module(_registry.lookup(*this, name)),
_module(_create_module(name)),
_verbose(verbose)
{ }

View File

@ -47,7 +47,7 @@ int main(int argc, char **argv)
report_brightness(brightness_reporter, 10);
printf("ROM client: request brightness report\n");
Attached_rom_dataspace brightness_rom("test-report_rom/brightness");
Attached_rom_dataspace brightness_rom("brightness");
ASSERT(brightness_rom.is_valid());
@ -72,8 +72,8 @@ int main(int argc, char **argv)
sig_rec.wait_for_signal();
brightness_rom.update();
ASSERT(!brightness_rom.is_valid());
printf("ROM client: detected vanished report\n");
ASSERT(brightness_rom.is_valid());
printf("ROM client: ROM is available despite report was closed - OK\n");
printf("Reporter: start reporting (while the ROM client still listens)\n");
brightness_reporter.enabled(true);
@ -82,6 +82,16 @@ int main(int argc, char **argv)
printf("ROM client: wait for update notification\n");
sig_rec.wait_for_signal();
try {
printf("ROM client: try to open the same report again\n");
Reporter again("brightness");
again.enabled(true);
PERR("expected Service_denied");
return -3;
} catch (Genode::Parent::Service_denied) {
printf("ROM client: catched Parent::Service_denied - OK\n");
}
printf("--- test-report_rom finished ---\n");
sig_rec.dissolve(&sig_ctx);

View File

@ -54,3 +54,4 @@ cpu_quota
stdcxx
nic_loopback
platform
report_rom