#
# \brief  Test for using the libc_vfs plugin with the TAR file system
# \author Christian Prochaska
# \date   2012-08-20
#

#
# Build
#

build {
	core init
	drivers/timer
	server/tar_fs
	test/libc_fs_tar_fs
}

create_boot_directory

#
# Generate config
#

set config {
<config>
	<parent-provides>
		<service name="ROM"/>
		<service name="RAM"/>
		<service name="CAP"/>
		<service name="IRQ"/>
		<service name="IO_MEM"/>
		<service name="IO_PORT"/>
		<service name="PD"/>
		<service name="RM"/>
		<service name="CPU"/>
		<service name="LOG"/>
		<service name="SIGNAL"/>
	</parent-provides>
	<default-route>
		<any-service> <parent/> <any-child/> </any-service>
	</default-route>
	<start name="timer">
		<resource name="RAM" quantum="1M"/>
		<provides> <service name="Timer"/> </provides>
	</start>
	<start name="tar_fs">
		<resource name="RAM" quantum="4M"/>
		<provides> <service name="File_system"/> </provides>
		<config>
			<archive name="libc_fs_tar_fs.tar" />
			<policy label="" root="/testdir" />
		</config>
	</start>
	<start name="test-libc_fs_tar_fs">
		<resource name="RAM" quantum="2M"/>
		<config>
			<libc stdout="/dev/log">
				<vfs>
					<dir name="dev"> <log/> </dir>
					<fs/>
				</vfs>
			</libc>
		</config>
	</start>
}

append config {
</config>
}

install_config $config

#
# Create tar archive
#

exec mkdir -p bin/libc_fs_tar_fs/testdir/testdir
exec echo -n "a single line of text" > bin/libc_fs_tar_fs/testdir/testdir/test.tst
exec mkdir -p bin/libc_fs_tar_fs/testdir/a
exec mkdir -p bin/libc_fs_tar_fs/testdir/c
exec ln -sf /a bin/libc_fs_tar_fs/testdir/c/d
exec ln -sf /c bin/libc_fs_tar_fs/testdir/e
exec echo -n "a single line of text" > bin/libc_fs_tar_fs/testdir/a/b
exec tar cfv bin/libc_fs_tar_fs.tar -C bin/libc_fs_tar_fs .

#
# Boot modules
#

# generic modules
set boot_modules {
	core init timer tar_fs
	ld.lib.so libc.lib.so
	test-libc_fs_tar_fs libc_fs_tar_fs.tar
}

build_boot_image $boot_modules

#
# Execute test case
#

#
# Qemu
#
append qemu_args " -m 128 -nographic "

run_genode_until {.*child "test-libc_fs_tar_fs" exited with exit value 0.*} 60

#exec rm -rf bin/libc_fs_tar_fs
#exec rm -rf bin/libc_fs_tar_fs.tar

puts "\nTest succeeded\n"

# vi: set ft=tcl :
