diff --git a/ports/run/noux_fork.run b/ports/run/noux_fork.run new file mode 100644 index 0000000000..657c6c5e84 --- /dev/null +++ b/ports/run/noux_fork.run @@ -0,0 +1,77 @@ +if {![have_spec x86_32]} { + puts "\nNoux is supported on the x86_32 architecture only\n" + exit 0 +} +if {[have_spec linux]} { + puts "\nLinux not supported because of missing UART driver\n" + exit 0 +} + +build "core init drivers/timer drivers/uart noux lib/libc_noux test/noux_fork" + +# strip coreutils binaries and create tar archive +exec tar cfv bin/noux_fork.tar -h -C bin test-noux_fork + +create_boot_directory + +install_config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +build_boot_image { + core init timer uart_drv ld.lib.so noux libc.lib.so libm.lib.so + libc_noux.lib.so noux_fork.tar +} + +# +# Redirect the output of Noux via the virtual serial port 1 into a file to be +# dumped after the successful completion of the test. +# +set noux_output_file "noux_output.log" + +append qemu_args " -nographic" +append qemu_args " -serial mon:stdio" +append qemu_args " -serial file:$noux_output_file" + +#run_genode_until "child exited with exit value 0.*\n" 20 +run_genode_until "child.*exited.*\n" 20 + +puts "[exec cat $noux_output_file]" + +exec rm bin/noux_fork.tar +exec rm $noux_output_file diff --git a/ports/src/test/noux_fork/target.mk b/ports/src/test/noux_fork/target.mk new file mode 100644 index 0000000000..9be39c1faa --- /dev/null +++ b/ports/src/test/noux_fork/target.mk @@ -0,0 +1,3 @@ +TARGET = test-noux_fork +SRC_CC = test.cc +LIBS = libc libc_noux diff --git a/ports/src/test/noux_fork/test b/ports/src/test/noux_fork/test new file mode 100755 index 0000000000..bd2bd2a43b Binary files /dev/null and b/ports/src/test/noux_fork/test differ diff --git a/ports/src/test/noux_fork/test.cc b/ports/src/test/noux_fork/test.cc new file mode 100644 index 0000000000..c5c239ad03 --- /dev/null +++ b/ports/src/test/noux_fork/test.cc @@ -0,0 +1,38 @@ +/* + * \brief Simple fork test + * \author Norman Feske + * \date 2012-02-14 + */ + +#include +#include +#include + +int main(int, char **) +{ + int i = 0; + + pid_t fork_ret = fork(); + if (fork_ret < 0) { + printf("Error: fork returned %d, errno=%d\n", fork_ret, errno); + return -1; + } + + printf("pid %d: fork returned %d\n", getpid(), fork_ret); + + if (fork_ret == 0) { + printf("pid %d: child says hello\n", getpid()); + for (int j = 0; j < 50; j++) { + printf("pid %d: child i = %d\n", getpid(), i); + } + } + + printf("pid %d: parent received child pid %d, starts counting...\n", + getpid(), fork_ret); + + for (; i < 50; ) { + printf("pid %d: parent i = %d\n", getpid(), i++); + } + + return 0; +}