genode/repos/os/recipes/raw/test-init/test-init.config
Norman Feske b661459aca sandbox/init: parse config using 'List_model'
This commit replaces the hand-crafted config processing by the use of
the 'List_model' utility. This has the following advantages:

- The parsing follows a common formalism that makes the code
  easier to maintain and to understand. Several parts of the code
  had to be changed (for the better) to make it fit the list model
  approach. E.g., the child states have become more expressive
  and logical.

- In the common case, the XML data is traversed only once, which
  increases the parsing speed in dynamic scenarios.

- The code becomes easier to optimize. In particular, the patch skips
  the re-evaluation of the session routing if no service is affected
  by the config change.

The patch also revisits the init test by removing overly long sleep
phases and extending a few sleep phases that were too short when
executing the test on Qemu.

Issue #4068
2021-04-20 12:03:04 +02:00

1752 lines
50 KiB
Plaintext

<config>
<!-- let init settle, processing the initially invalid config -->
<sleep ms="150"/>
<message string="test state reporting"/>
<init_config version="initial">
<report init_ram="yes" ids="yes" child_ram="yes" requested="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="application">
<binary name="dummy"/>
<resource name="RAM" quantum="1G"/>
<config>
<log string="started"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> application] started"/>
<sleep ms="200"/>
<expect_init_state>
<attribute name="version" value="initial"/>
<node name="child">
<attribute name="name" value="application"/>
<attribute name="binary" value="dummy"/>
<node name="requested">
<node name="session">
<attribute name="service" value="PD"/>
<attribute name="label" value="application"/>
<attribute name="state" value="CAP_HANDED_OUT"/>
</node>
</node>
</node>
</expect_init_state>
<message string="exit state handling"/>
<init_config version="exiting child">
<report ids="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="exiting">
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config>
<log string="started"/>
<exit/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> exiting] started"/>
<sleep ms="350"/>
<expect_init_state>
<attribute name="version" value="exiting child"/>
<node name="child">
<attribute name="name" value="exiting"/>
<attribute name="binary" value="dummy"/>
<attribute name="id" value="2"/>
<attribute name="exited" value="0"/>
</node>
</expect_init_state>
<!-- Trigger reconfiguration without changing anything about
the exited application.
The exited application must remain in its 'exited' state. -->
<init_config version="exiting child 2">
<report ids="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="exiting">
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config>
<log string="started"/>
<exit/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="unrelated">
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="200"/>
<expect_init_state>
<attribute name="version" value="exiting child 2"/>
<node name="child">
<attribute name="name" value="exiting"/>
<attribute name="binary" value="dummy"/>
<attribute name="id" value="2"/>
<attribute name="exited" value="0"/>
</node>
</expect_init_state>
<message string="routing to custom log service"/>
<!-- We let the client manually create a LOG session in addition
to its env LOG session. So there are two sessions at the
server, one initiated by init and one initiated by the
child. Both cases trigger distinct code paths at child-
destruction time. -->
<init_config version="chained log services">
<report ids="yes" requested="yes" provided="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="indirect_server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route>
<service name="LOG"> <child name="server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="client">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config>
<log string="client started"/>
<create_log_connections count="1"/>
</config>
<route>
<service name="LOG"> <child name="indirect_server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> server] [indirect_server] [client] client started"/>
<sleep ms="200"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="server"/>
<attribute name="id" value="4"/>
</node>
<node name="child">
<attribute name="name" value="client"/>
<attribute name="id" value="6"/>
</node>
</expect_init_state>
<sleep ms="150"/>
<message string="changing route of indirect server"/>
<!-- Because the route to the LOG session of the 'indirect_server'
is re-directed to the parent, the 'indirect_server' must be
restarted. As the 'client' depends on the 'indirect_server'
for its LOG session, the client must implicitly be restarted
as well. -->
<init_config version="restarted indirect server">
<report ids="yes" requested="yes" provided="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="indirect_server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="client">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config>
<log string="client started"/>
<create_log_connections count="1"/>
</config>
<route>
<service name="LOG"> <child name="indirect_server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<!-- the output of the new 'client' does no longer go via 'server' -->
<expect_log string="[init -> indirect_server] [client] client started"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="server"/>
<attribute name="id" value="4"/>
</node>
<node name="child">
<attribute name="name" value="client"/>
<attribute name="id" value="8"/> <!-- client was restarted -->
</node>
</expect_init_state>
<sleep ms="100"/>
<!-- Kill the client and validate that all session states are freed -->
<init_config version="client removed">
<report ids="yes" requested="yes" provided="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="indirect_server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="300"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="indirect_server"/>
<node name="provided">
<not>
<node name="session"/>
</not>
</node>
</node>
</expect_init_state>
<message string="test changing provided services"/>
<!-- Initially, the log service lacks the <provides> declaration.
Therefore the attempt to route the LOG session of the client
to the 'log' fails. The environment of 'dummy' will remain
incomplete. -->
<init_config version="incomplete">
<report requested="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="log">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config> <log string="no service yet"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="dummy">
<resource name="RAM" quantum="1M"/>
<config> <log string="started"/> </config>
<route>
<service name="LOG"> <child name="log"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> log] no service yet"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="log"/> </node>
<node name="child">
<attribute name="name" value="dummy"/>
<attribute name="state" value="incomplete"/>
</node>
</expect_init_state>
<!-- We add the <provides> node to the log server and thereby
make the LOG route of the 'dummy' client available. The
server is expected to remain unaffected but the client should
be restarted to re-route its LOG session to the server -->
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="log">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config version="providing service"> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="dummy">
<resource name="RAM" quantum="1M"/>
<config> <log string="started"/> </config>
<route>
<service name="LOG"> <child name="log"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> log] config 2: providing service"/>
<expect_log string="[init -> log] [dummy] started"/>
<!-- We remove <provides> node from 'log' service and thereby
make the LOG service unavailble for 'dummy'. Consequently,
'dummy' will be restarted but will ultimately remain
incomplete (as the LOG environment session cannot be routed).
The server stays alive and reports its third config. -->
<init_config>
<report requested="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="log">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="became unavailable"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="dummy">
<resource name="RAM" quantum="1M"/>
<config> <log string="started"/> </config>
<route>
<service name="LOG"> <child name="log"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<sleep ms="150"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="dummy"/>
<attribute name="state" value="incomplete"/>
</node>
</expect_init_state>
<message string="update child config"/>
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="application">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="Version A"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> application] config 1: Version A"/>
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="application">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="Version B"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> application] config 2: Version B"/>
<!-- Add 'version' attribute to start node, which should trigger
the restart of the child, printing a version count of 1.
We also validate that the version is reflected in the state
report. -->
<init_config>
<report/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="application" version="X">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="Version B"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> application] config 1: Version B"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="version" value="X"/> </node>
</expect_init_state>
<sleep ms="100"/>
<message string="test label rewriting and binary-name update"/>
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="binary-name test"/>
<route>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> test] config 1: binary-name test"/>
<!-- We change the binary name, but also use the label-rewriting
feature of init to produce the same route as the original
binary. Consequently, init does not need to restart the
child. Instead the original child merely prints a new
config version (count 2). -->
<init_config>
<report/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="renamed_dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="binary re-routed to same route"/>
<route>
<service name="ROM" unscoped_label="renamed_dummy">
<parent label="dummy"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> test] config 2: binary re-routed to same route"/>
<!-- We change the binary name in a way that results in a
different route for the binary ROM request, which requires
restart of the child. The config version printed by the
new child will have a count of 1. -->
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="another_dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="binary re-routed to other route"/>
<route>
<service name="ROM" unscoped_label="renamed_dummy">
<parent label="dummy"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> test] config 1: binary re-routed to other route"/>
<sleep ms="100"/>
<message string="test RAM preservation"/>
<init_config>
<report init_ram="yes"/>
<resource name="RAM" preserve="2M"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="regular">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config> <log string="regular component started"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="greedy">
<binary name="dummy"/>
<resource name="RAM" quantum="1G"/>
<config> <log string="greedy component started"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="300"/>
<!-- wait until both children are started -->
<expect_init_state>
<node name="child"> <attribute name="name" value="regular"/> </node>
<node name="child"> <attribute name="name" value="greedy"/> </node>
</expect_init_state>
<expect_init_state>
<node name="ram"> <attribute name="avail" higher="2M"/> </node>
</expect_init_state>
<sleep ms="100"/>
<message string="test RAM-quota adjustments"/>
<init_config>
<report child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="initial" />
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 1: initial"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="1M"/>
<attribute name="quota" lower="1M"/>
</node>
</node>
</expect_init_state>
<!-- increase RAM quota of child by 3 MiB -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="upgraded" />
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 2: upgraded"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="4M"/>
<attribute name="quota" higher="3M"/>
</node>
</node>
</expect_init_state>
<!-- start second child consuming all slack memory -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config/>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="greedy">
<binary name="dummy"/>
<resource name="RAM" quantum="1G"/>
<config version="started"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> greedy] config 1: started"/>
<sleep ms="150"/>
<expect_init_state>
<node name="ram"> <attribute name="avail" lower="1M"/> </node>
</expect_init_state>
<!-- attempt to upgrade the 'test' child to 8 MiB, hitting the RAM limit -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="8M"/>
<config version="upgrade impossible"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="greedy">
<binary name="dummy"/>
<resource name="RAM" quantum="1G"/>
<config version="started"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 4: upgrade impossible"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" lower="8M"/>
</node>
</node>
</expect_init_state>
<!-- kill greedy child, now the upgrade of 'test' can be completed -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="8M"/>
<config version="upgraded to 8 MiB"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 5: upgraded to 8 MiB"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="8M"/>
<attribute name="quota" higher="7M"/>
</node>
</node>
</expect_init_state>
<!-- reduce quota -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="downgraded to 4 MiB"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 6: downgraded to 4 MiB"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="4M"/>
<attribute name="quota" lower="4M"/>
</node>
</node>
</expect_init_state>
<!-- let child consume quota -->
<init_config version="consumed">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="consume 2 MiB">
<handle_yield_requests/>
<consume_ram amount="2M"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 7: consume 2 MiB"/>
<expect_log string="[init -> test] consume 2M bytes of memory"/>
<sleep ms="300"/>
<!-- activate child_ram report -->
<init_config version="report consumed">
<report child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="consume 2 MiB">
<handle_yield_requests/>
<consume_ram amount="2M"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="200"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="avail" lower="2M"/>
</node>
</node>
</expect_init_state>
<!-- reduce child quota by 2M, triggering a resource-yield request -->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config version="consume 2 MiB">
<handle_yield_requests/>
<consume_ram amount="2M"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] got yield request"/>
<expect_log string="[init -> test] release 2M bytes of memory"/>
<sleep ms="500"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram"> <attribute name="quota" lower="2M"/> </node>
</node>
</expect_init_state>
<!-- let child issue a resource request -->
<init_config version="resources requested">
<report init_ram="yes" child_ram="yes" delay_ms="2000"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config version="request more quota than avail">
<consume_ram amount="4M"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 8: request more quota than avail"/>
<sleep ms="200"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="2M"/>
<attribute name="requested" higher="4000K"/>
</node>
</node>
</expect_init_state>
<!-- respond to resource request-->
<init_config>
<report init_ram="yes" child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="6M"/>
<config version="request more quota than avail">
<consume_ram amount="4M"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram">
<attribute name="assigned" value="6M"/>
<attribute name="quota" higher="5M"/>
</node>
</node>
</expect_init_state>
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
</init_config>
<sleep ms="150"/>
<message string="test capability-quota adjustments"/>
<init_config>
<report child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="100">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="initial" />
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 1: initial"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="100"/>
<attribute name="quota" lower="100"/>
</node>
</node>
</expect_init_state>
<!-- increase capability quota of child by 300 -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="400">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config version="upgraded" />
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 2: upgraded"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="400"/>
<attribute name="quota" higher="300"/>
</node>
</node>
</expect_init_state>
<!-- start second child consuming all slack capabilities -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="400">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config/>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="greedy" caps="1000000">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="started"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> greedy] config 1: started"/>
<sleep ms="150"/>
<expect_init_state>
<node name="caps"> <attribute name="avail" lower="1000"/> </node>
</expect_init_state>
<!-- attempt to upgrade the 'test' child to 800 caps, hitting the limit -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="800">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="upgrade impossible"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="greedy" caps="1000000">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="started"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 4: upgrade impossible"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" lower="800"/>
</node>
</node>
</expect_init_state>
<!-- kill greedy child, now the upgrade of 'test' can be completed -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="test" caps="800">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="upgraded to 800 caps"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 5: upgraded to 800 caps"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="800"/>
<attribute name="quota" higher="700"/>
</node>
</node>
</expect_init_state>
<!-- reduce quota -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="200">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="downgraded to 200 caps"/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 6: downgraded to 200 caps"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="200"/>
<attribute name="quota" lower="200"/>
</node>
</node>
</expect_init_state>
<!-- let child consume quota -->
<init_config version="consumed">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="200">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="consume 100 caps">
<handle_yield_requests/>
<consume_caps amount="100"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 7: consume 100 caps"/>
<expect_log string="[init -> test] consume 100 caps"/>
<sleep ms="150"/>
<!-- activate child_caps report -->
<init_config version="report consumed">
<report child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="200">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="consume 100 caps">
<handle_yield_requests/>
<consume_caps amount="100"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="200"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="avail" lower="100"/>
</node>
</node>
</expect_init_state>
<!-- reduce child quota by 100 caps, triggering a resource-yield request -->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="100">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="consume 100 caps">
<handle_yield_requests/>
<consume_caps amount="100"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] got yield request"/>
<expect_log string="[init -> test] release 100 caps"/>
<sleep ms="500"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps"> <attribute name="quota" lower="100"/> </node>
</node>
</expect_init_state>
<!-- let child issue a resource request -->
<init_config version="resources requested">
<report init_caps="yes" child_caps="yes" delay_ms="2000"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="100">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="request more quota than avail">
<consume_caps amount="100"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> test] config 8: request more quota than avail"/>
<sleep ms="300"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="100"/>
<attribute name="requested" higher="1"/>
</node>
</node>
</expect_init_state>
<!-- respond to resource request-->
<init_config>
<report init_caps="yes" child_caps="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<start name="test" caps="200">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="request more quota than avail">
<consume_caps amount="100"/>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="150"/>
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="caps">
<attribute name="assigned" value="200"/>
<attribute name="quota" higher="100"/>
</node>
</node>
</expect_init_state>
<init_config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
</init_config>
<sleep ms="150"/>
<message string="denial of forwarded session request"/>
<init_config version="session forwarding">
<report child_ram="yes" requested="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="service_init" caps="200">
<binary name="init"/>
<resource name="RAM" quantum="10M"/>
<provides> <service name="LOG"/> </provides>
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="60"/>
<service name="LOG">
<!-- deny request because no policy matches -->
<policy label="mismatching"> <child name="server"/> </policy>
</service>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="initial">
<create_log_connections count="1" ram_upgrade="3M"/>
<destroy_log_connections/>
</config>
<route>
<service name="LOG"> <child name="service_init"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<sleep ms="500"/>
<expect_init_state>
<attribute name="version" value="session forwarding"/>
<node name="child">
<attribute name="name" value="test"/>
<attribute name="binary" value="dummy"/>
<node name="requested">
<node name="session">
<attribute name="service" value="LOG"/>
<attribute name="label" value="test"/>
<attribute name="state" value="SERVICE_DENIED"/>
</node>
</node>
</node>
</expect_init_state>
<!-- With the LOG session denied, the 'test' component will remain
in an aborted state. Hence, we have to reset init for the subsequent
good-case tests. -->
<init_config version="empty"> <report/> </init_config>
<sleep ms="150"/>
<expect_init_state>
<attribute name="version" value="empty"/>
</expect_init_state>
<message string="stalled forwarded session request to future server"/>
<init_config version="session forwarding">
<report child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="service_init" caps="200">
<binary name="init"/>
<resource name="RAM" quantum="10M"/>
<provides> <service name="LOG"/> </provides>
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="60"/>
<service name="LOG">
<default-policy> <child name="server"/> </default-policy>
</service>
<!-- server is not yet available -->
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="initial">
<create_log_connections count="1" ram_upgrade="3M"/>
<destroy_log_connections/>
</config>
<route>
<service name="LOG"> <child name="service_init"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<!-- The 'test' client request is supposed to be stalled, not denied.
Good news, the client will get what it wants pretty soon. -->
<sleep ms="500"/>
<message string="forward session request to child"/>
<init_config>
<report child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="service_init" caps="200">
<binary name="init"/>
<resource name="RAM" quantum="10M"/>
<provides> <service name="LOG"/> </provides>
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="60"/>
<service name="LOG">
<default-policy> <child name="server"/> </default-policy>
</service>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service verbose="yes"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="initial">
<create_log_connections count="1" ram_upgrade="3M"/>
<destroy_log_connections/>
</config>
<route>
<service name="LOG"> <child name="service_init"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> service_init -> server] created LOG service"/>
<expect_log string="[init -> service_init -> server] opening session with label test"/>
<expect_log string="[init -> service_init -> server] [test] going to create 1 LOG connections"/>
<expect_log string="[init -> service_init -> server] opening session with label test -> 0"/>
<expect_log string="[init -> service_init -> server] [test] upgrade connection 0"/>
<expect_log string="[init -> service_init -> server] received session quota upgrade"/>
<expect_log string="[init -> service_init -> server] [test] created all LOG connections"/>
<expect_log string="[init -> service_init -> server] closing session with label test -> 0"/>
<expect_log string="[init -> service_init -> server] [test] destroyed all LOG connections"/>
<sleep ms="150"/>
<!-- after closing the LOG session, the session quota is returned to
the 'test' client -->
<expect_init_state>
<node name="child"> <attribute name="name" value="test"/>
<node name="ram"> <attribute name="avail" higher="3M"/> </node>
</node>
</expect_init_state>
<!-- change init service policy such that the route of the
remaining LOG session of 'test' is no longer valid. We
expect the 'service_init' to issue a close request to the
embedded server -->
<init_config>
<report child_ram="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="service_init" caps="200">
<binary name="init"/>
<resource name="RAM" quantum="10M"/>
<provides> <service name="LOG"/> </provides>
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="60"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service verbose="yes"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="test">
<binary name="dummy"/>
<resource name="RAM" quantum="4M"/>
<config version="initial">
<create_log_connections count="1" ram_upgrade="3M"/>
<destroy_log_connections/>
</config>
<route>
<service name="LOG"> <child name="service_init"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> service_init -> server] closing session with label test"/>
<sleep ms="150"/>
<message string="test abandoned any-child routes"/>
<init_config version="abandoned any-child 1">
<report ids="yes" requested="yes" provided="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="client">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config>
<log string="client started"/>
<create_log_connections count="1"/>
</config>
<route>
<any-service> <any-child/> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> server] [client] client started"/>
<sleep ms="200"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="server"/>
<attribute name="id" value="26"/>
</node>
<node name="child">
<attribute name="name" value="client"/>
<attribute name="id" value="27"/>
</node>
</expect_init_state>
<sleep ms="150"/>
<init_config version="abandoned any-child 2">
<report ids="yes" requested="yes" provided="yes"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="client">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config>
<log string="client started"/>
<create_log_connections count="1"/>
</config>
<route>
<any-service> <any-child/> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> client] client started"/>
<sleep ms="200"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="client"/>
<attribute name="id" value="28"/>
</node>
</expect_init_state>
<sleep ms="150"/>
<message string="heartbeat monitoring"/>
<init_config version="flaky component is responsive">
<report/>
<heartbeat rate_ms="100"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="flaky">
<binary name="dummy"/>
<heartbeat/>
<resource name="RAM" quantum="2M"/>
<config>
<log string="started"/>
<!-- respond to heartbeats -->
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> flaky] started"/>
<sleep ms="150"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="flaky"/>
<!-- 'skipped_heartbeats' attribute must not be present -->
<attribute name="skipped_heartbeats" value=""/>
</node>
</expect_init_state>
<init_config version="flaky component freezes">
<report/>
<heartbeat rate_ms="100"/>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="flaky">
<binary name="dummy"/>
<heartbeat/>
<resource name="RAM" quantum="2M"/>
<config version="freeze">
<log string="getting stuck..."/>
<sleep_forever/> <!-- heartbeat stops -->
</config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_log string="[init -> flaky] getting stuck..."/>
<sleep ms="500"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="flaky"/>
<attribute name="skipped_heartbeats" higher="0"/>
</node>
</expect_init_state>
<message string="test destruction of async env sessions"/>
<init_config version="async env session">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="dummy" version="1">
<resource name="RAM" quantum="1M"/>
<config> <log string="started version 1"/> </config>
<route>
<service name="LOG">
<child name="server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> server] [dummy] started version 1"/>
<sleep ms="150"/>
<init_config version="async env session">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="dummy" version="2">
<resource name="RAM" quantum="1M"/>
<config> <log string="started version 2"/> </config>
<route>
<service name="LOG">
<child name="server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<expect_log string="[init -> server] [dummy] started version 2"/>
<sleep ms="150"/>
<message string="test invalid affinity configuration warning"/>
<init_config version="affinity">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
</parent-provides>
<default caps="100"/>
<start name="affinity">
<affinity xpos="0"/>
<binary name="dummy"/>
<resource name="RAM" quantum="2M"/>
<config/>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<expect_warning string="[init] " colored="Warning: affinity-space configuration missing, but affinity defined for child affinity"/>
<sleep ms="350"/>
<message string="destroy child while async close requested"/>
<!-- This is a regression test for issue #4039.
A child is removed while a close request issued by the
child is still pending. Once the close request is completed,
the child can no longer be notified. -->
<init_config version="dangling_close">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
<service name="Timer"/>
</parent-provides>
<default caps="100"/>
<report requested="yes" provided="yes" delay_ms="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service delay_close_ms="750"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
<start name="client">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<config>
<log string="client started"/>
<create_log_connections count="1"/>
<log string="client created one log connection"/>
<destroy_log_connections/>
<log string="client destroyed log connection"/>
</config>
<route>
<service name="LOG" label_prefix=""> <child name="server"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
</init_config>
<sleep ms="600"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="server"/>
<node name="provided">
<node name="session">
<attribute name="state" value="CLOSE_REQUESTED"/>
</node>
</node>
</node>
</expect_init_state>
<init_config version="dangling_close">
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="LOG"/>
<service name="Timer"/>
</parent-provides>
<default caps="100"/>
<report requested="yes" provided="yes" delay_ms="100"/>
<start name="server">
<binary name="dummy"/>
<resource name="RAM" quantum="1M"/>
<provides> <service name="LOG"/> </provides>
<config> <log_service delay_close_ms="500"/> </config>
<route> <any-service> <parent/> </any-service> </route>
</start>
</init_config>
<sleep ms="750"/>
<expect_init_state>
<node name="child">
<attribute name="name" value="server"/>
<node name="provided">
<not>
<node name="session"/>
</not>
</node>
</node>
</expect_init_state>
<sleep ms="150"/>
<message string="test complete"/>
</config>