build "core init server/report_rom test/resource_request drivers/timer"

create_boot_directory

install_config {
	<config>
		<parent-provides>
			<service name="ROM"/>
			<service name="CPU"/>
			<service name="PD"/>
			<service name="IRQ"/>
			<service name="IO_PORT"/>
			<service name="IO_MEM"/>
			<service name="LOG"/>
		</parent-provides>
		<default-route>
			<any-service> <parent/> <any-child/> </any-service>
		</default-route>
		<default caps="100"/>
		<start name="timer">
			<resource name="RAM" quantum="1M"/>
			<provides><service name="Timer"/></provides>
		</start>
		<start name="report_rom">
			<resource name="RAM" quantum="2M"/>
			<provides> <service name="ROM"/> <service name="Report"/> </provides>
			<config verbose="no">
				<policy label="init -> config" report="init_monitor -> init.config"/>
				<policy label="init_monitor -> state" report="init -> state"/>
			</config>
		</start>
		<start name="init" caps="4000">
			<resource name="RAM" quantum="10M"/>
			<route>
				<service name="ROM" label="config"> <child name="report_rom"/> </service>
				<any-service> <parent/> <any-child/> </any-service>
			</route>
		</start>
		<start name="init_monitor">
			<binary name="test-resource_request"/>
			<resource name="RAM" quantum="2M"/>
			<config role="monitor"/>
			<route>
				<service name="ROM" label="state"> <child name="report_rom"/> </service>
				<any-service> <parent/> <any-child/> </any-service>
			</route>
		</start>
	</config>
}

build_boot_image "core ld.lib.so init timer report_rom test-resource_request"

append qemu_args "-nographic "

run_genode_until {child "test-resource_request" exited with exit value 0.*\n} 60
