noux: Run script with two bash shells using the same file system

Related to #1765

Instructions:

1. Create a file in terminal one in the 'ram' directory

! echo "test" > ram/test

2. Second terminal

! tail -f ram/test

3. First terminal

! echo "Meaningless output" >> ram/test

4. Observe second terminal
This commit is contained in:
Sebastian Sumpf 2015-11-05 11:08:05 +01:00 committed by Christian Helmuth
parent 06fe755f8c
commit e2280a1650
1 changed files with 253 additions and 0 deletions

View File

@ -0,0 +1,253 @@
#
# \brief Test for the Noux terminal file system
# \author Christian Prochaska
# \date 2012-06-11
#
#
# The test shows two framebuffer terminals. The upper terminal runs an
# interatctive shell and the lower terminal can be accessed from the shell via
# /dev/terminal.
#
# Example for writing to the lower terminal: echo "test" > /dev/terminal
# Example for reading a line from the lower terminal: head -n 1 /dev/terminal
#
set build_components {
core init drivers/timer noux lib/libc_noux
drivers/framebuffer drivers/input
server/terminal server/ram_fs server/nitpicker app/pointer
server/nit_fb
}
#
# Build Noux packages only once
#
foreach pkg {bash coreutils} {
lappend_if [expr ![file exists bin/$pkg]] build_components noux-pkg/$pkg }
source ${genode_dir}/repos/base/run/platform_drv.inc
append_platform_drv_build_components
build $build_components
# strip all binaries prior archiving
exec sh -c "find bin/bash/ bin/coreutils/ -type f | (xargs strip || true) 2>/dev/null"
exec tar cfv bin/bash.tar -h -C bin/bash .
exec tar cfv bin/coreutils.tar -h -C bin/coreutils .
create_boot_directory
append config {
<config verbose="yes">
<parent-provides>
<service name="ROM"/>
<service name="LOG"/>
<service name="CAP"/>
<service name="RAM"/>
<service name="RM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="IRQ"/>
<service name="IO_PORT"/>
<service name="IO_MEM"/>
<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> }
append_if [have_spec sdl] config {
<start name="fb_sdl">
<resource name="RAM" quantum="4M"/>
<provides>
<service name="Input"/>
<service name="Framebuffer"/>
</provides>
</start> }
append_platform_drv_config
append_if [have_spec framebuffer] config {
<start name="fb_drv">
<resource name="RAM" quantum="4M"/>
<provides><service name="Framebuffer"/></provides>
</start> }
append_if [have_spec ps2] config {
<start name="ps2_drv">
<resource name="RAM" quantum="1M"/>
<provides><service name="Input"/></provides>
</start> }
append config {
<start name="nitpicker">
<resource name="RAM" quantum="1M"/>
<provides><service name="Nitpicker"/></provides>
<config>
<domain name="pointer" layer="1" content="client" label="no" origin="pointer" />
<domain name="" layer="2" content="client" focus="click" />
<policy label="pointer" domain="pointer"/>
<policy label="" domain=""/>
</config>
<route> }
append_if [have_spec ps2] config {
<service name="Input"><child name="ps2_drv"/></service> }
append config {
<service name="Framebuffer"><child name="fb_drv"/> </service>
<any-service><parent/><any-child/></any-service>
</route>
</start>
<start name="pointer">
<resource name="RAM" quantum="1M"/>
</start>
<start name="terminal_noux_fb">
<binary name="nit_fb"/>
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Framebuffer"/>
<service name="Input"/>
</provides>
<config xpos="0" ypos="0" width="1024" height="380" refresh_rate="25"/>
</start>
<start name="terminal_test_fb">
<binary name="nit_fb"/>
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Framebuffer"/>
<service name="Input"/>
</provides>
<config xpos="0" ypos="388" width="1024" height="380" refresh_rate="25"/>
</start>
<start name="terminal_noux">
<binary name="terminal"/>
<resource name="RAM" quantum="2M"/>
<provides><service name="Terminal"/></provides>
<route>
<service name="Input"><child name="terminal_noux_fb"/></service>
<service name="Framebuffer"><child name="terminal_noux_fb"/> </service>
<any-service><parent/><any-child/></any-service>
</route>
<config>
<keyboard layout="us"/>
</config>
</start>
<start name="terminal_noux2">
<binary name="terminal"/>
<resource name="RAM" quantum="2M"/>
<provides><service name="Terminal"/></provides>
<route>
<service name="Input"><child name="terminal_test_fb"/></service>
<service name="Framebuffer"><child name="terminal_test_fb"/> </service>
<any-service><parent/><any-child /></any-service>
</route>
<config>
<keyboard layout="us"/>
</config>
</start>
<!--
<start name="terminal_test">
<binary name="terminal"/>
<resource name="RAM" quantum="2M"/>
<provides><service name="Terminal"/></provides>
<route>
<service name="Input"><child name="terminal_test_fb"/></service>
<service name="Framebuffer"><child name="terminal_test_fb"/> </service>
<any-service><parent/><any-child/></any-service>
</route>
<config>
<keyboard layout="de"/>
</config>
</start>
-->
<start name="ram_fs">
<resource name="RAM" quantum="10M"/>
<provides><service name="File_system"/></provides>
<config>
<!-- constrain sessions according to their labels -->
<policy label="noux -> root" root="/" writeable="yes" />
<policy label="noux2 -> root" root="/" writeable="yes" />
</config>
</start>
<start name="noux">
<resource name="RAM" quantum="50M" />
<route>
<service name="Terminal">
<child name="terminal_noux"/>
</service>
<any-service><parent/><any-child/></any-service>
</route>
<config>
<fstab>
<tar name="coreutils.tar" />
<tar name="bash.tar" />
<dir name="ram"> <fs label="root" /> </dir>
<dir name="dev"> <terminal name="terminal" label="terminal_fs" /> </dir>
</fstab>
<start name="/bin/bash">
<env name="TERM" value="linux" />
</start>
</config>
</start>
<start name="noux2">
<binary name="noux" />
<resource name="RAM" quantum="1G" />
<route>
<service name="Terminal">
<child name="terminal_noux2"/>
</service>
<any-service><parent/><any-child/></any-service>
</route>
<config>
<fstab>
<tar name="coreutils.tar" />
<tar name="bash.tar" />
<dir name="ram"> <fs label="root" /> </dir>
<dir name="dev"> <terminal name="terminal" label="terminal_fs" /> </dir>
</fstab>
<start name="/bin/bash">
<env name="TERM" value="linux" />
</start>
</config>
</start>
</config>
}
install_config $config
#
# Boot modules
#
# generic modules
set boot_modules {
core init timer ld.lib.so noux terminal ram_fs nitpicker nit_fb pointer
libc.lib.so libm.lib.so libc_noux.lib.so
bash.tar coreutils.tar
}
# platform-specific modules
lappend_if [have_spec linux] boot_modules fb_sdl
lappend_if [have_spec framebuffer] boot_modules fb_drv
lappend_if [have_spec ps2] boot_modules ps2_drv
append_platform_drv_boot_modules
build_boot_image $boot_modules
if {[have_spec x86_64]} {
# bash.tar is really huge when built for x86_64
append qemu_args " -m 300 "
}
run_genode_until forever
exec rm bin/bash.tar