create_boot_directory

import_from_depot [depot_user]/src/[base_src] \
                  [depot_user]/src/init \
                  [depot_user]/src/sequence \
                  [depot_user]/src/vfs \
                  [depot_user]/src/vfs_import \
                  [depot_user]/src/zlib


set build_components {
	test/protobuf/add_person
	test/protobuf/list_people
}

build $build_components

set config {
<config verbose="yes">
	<parent-provides>
		<service name="CPU"/>
		<service name="LOG"/>
		<service name="PD"/>
		<service name="ROM"/>
	</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="ram_fs">
		<resource name="RAM" quantum="4M" />
		<binary name="vfs"/>
		<provides> <service name="File_system"/> </provides>
		<config>
			<vfs>
				<ram/>
				<import>
					<inline name="input.txt">1
Muster Hans
hans@muster.com
123456789012345
home

					</inline>
					<inline name="input2.txt">2
Hans Muster
muster@hans.com
999999999999999
mobile

					</inline>
					<inline name="addresses.bin"></inline>
				</import>
			</vfs>
			<default-policy root="/" writeable="yes"/>
		</config>
	</start>

	<start name="sequence" caps="300">
		<resource name="RAM" quantum="16M" />
		<config>

			<start name="add_person">
				<resource name="RAM" quantum="8M" />
				<config>
					<arg value="add_person"/>
					<arg value="/home/addresses.bin"/>
					<libc stdin="/home/input.txt" stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
					<vfs>
						<dir name="dev">
							<log/> <null/>
							<inline name="rtc">2000-01-01 00:00</inline>
						</dir>
						<dir name="home"> <fs/> </dir>
					</vfs>
				</config>
			</start>

			<start name="add_person">
				<resource name="RAM" quantum="8M" />
				<config>
					<arg value="add_person"/>
					<arg value="/home/addresses.bin"/>
					<libc stdin="/home/input2.txt" stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
					<vfs>
						<dir name="dev">
							<log/> <null/>
							<inline name="rtc">2000-01-01 00:00</inline>
						</dir>
						<dir name="home"> <fs/> </dir>
					</vfs>
				</config>
			</start>

			<start name="list_people">
				<resource name="RAM" quantum="8M" />
				<config>
					<arg value="list_people"/>
					<arg value="/home/addresses.bin"/>
					<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
					<vfs>
						<dir name="dev">
							<log/> <null/>
							<inline name="rtc">2000-01-02 00:00</inline>
						</dir>
						<dir name="home"> <fs/> </dir>
					</vfs>
				</config>
			</start>

		</config>
		<route>
			<any-service> <parent/> <any-child/> </any-service>
		</route>
	</start>

</config>
}

install_config $config

set boot_modules {
	add_person
	list_people
	libc.lib.so
	libm.lib.so
	stdcxx.lib.so
	protobuf.lib.so
	posix.lib.so
}

append qemu_args " -nographic "

build_boot_image $boot_modules

run_genode_until {child "sequence" exited with exit value 0} 20
