if {[have_spec linux]} {
	puts "Platform is unsupported. (rtc driver support)"
	exit 0
}

#
# Build
#

set build_components {
	core init
	timer
	drivers/rtc
	server/vfs
	test/gmock
}

build $build_components

create_boot_directory

#
# Generate config
#

install_config {
<config verbose="yes">
	<parent-provides>
		<service name="ROM"/>
		<service name="CAP"/>
		<service name="RM"/>
		<service name="PD"/>
		<service name="CPU"/>
		<service name="LOG"/>
		<service name="SIGNAL"/>
		<service name="IO_PORT"/>
	</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="rtc_drv">
		<resource name="RAM" quantum="1M"/>
		<provides> <service name="Rtc"/> </provides>
	</start>

	<start name="ram_fs">
		<resource name="RAM" quantum="4M"/>
		<binary name="vfs"/>
		<provides> <service name="File_system"/> </provides>
		<config>
			<vfs> <ram/> </vfs>
			<policy label="gmock -> " root="/" writeable="yes" />
		</config>
	</start>

	<start name="gmock" caps="200">
		<resource name="RAM" quantum="4M"/>
		<config>
			<vfs>
				<dir name="dev"> <log/> <rtc/> </dir>
				<fs/>
			</vfs>
			<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
			<arg value="gmock"/>
			<arg value="--gtest_filter=-*Death*:*.*WhenVerbosityIs*:ExpectCallTest.TakesDefaultAction*:AssertTest.FailsFatally*:LogTest.*:*.LogsAnything*:*MockTest.*:*IsMandatory:*.DoesNotWarnOnAdequateActionCount:*.WarnsOn*:*.Reports*:*FunctionCallMessageTest.*:GMockVerboseFlagTest.*"/>
		</config>
	</start>
</config>}

#
# Boot image
#

build_boot_image {
	core init ld.lib.so
	timer vfs
	libc.lib.so vfs.lib.so libm.lib.so posix.lib.so stdcxx.lib.so
	rtc_drv
	gmock.lib.so gtest.lib.so
	gmock
}

append qemu_args " -nographic "

run_genode_until {.*child "gmock" exited with exit value 0} 1000
