if {![have_spec linux]} {
	puts "ROM padding requires that this script run on linux!"
	exit 1
}

# Build program images
build {
	core init
	proxy/rom_verify
	test/log
}

create_boot_directory

set sha256sum     [installed_command sha256sum]


set   ld_digest [lindex [exec $sha256sum bin/ld-linux.lib.so] 0]
set test_digest [lindex [exec $sha256sum bin/test-log] 0]

append config {
<config>
	<default caps="128"/>
	<parent-provides>
		<service name="CPU"/>
		<service name="IO_MEM"/>
		<service name="IO_PORT"/>
		<service name="IRQ"/>
		<service name="LOG"/>
		<service name="PD"/>
		<service name="RM"/>
		<service name="ROM"/>
</parent-provides>
	<default-route>
		<any-service><parent/><any-child/></any-service>
	</default-route>
	<start name="rom_verify">
		<resource name="RAM" quantum="2M"/>
		<provides> <service name="ROM"/> </provides>
		<config>}
append config "<policy label=\"ld.lib.so\" sha256=\"$ld_digest\"/>"
append config "<policy label=\"test-log\" sha256=\"$test_digest\"/>"
append config {
		</config>
	</start>
	<start name="test-log">
		<resource name="RAM" quantum="1M"/>
		<route>
			<service name="ROM">
				<child name="rom_verify"/> </service>
			<any-service> <parent/> </any-service>
		</route>
	</start>
</config>
}

install_config $config

build_boot_image {
	core init ld.lib.so
	libc.lib.so vfs.lib.so
	libm.lib.so
	rom_verify
	stdcxx.lib.so
	test-log
}

append qemu_args " -nographic"

run_genode_until {Test done.} 20
