X-Git-Url: http://rtime.felk.cvut.cz/gitweb/novaboot.git/blobdiff_plain/1958327d3c0324675528cca740c7a362184d4359..504a3e5a47335c921b8df0bba19660b918d9bfee:/tests/novaboot.wv diff --git a/tests/novaboot.wv b/tests/novaboot.wv index 194dde1..d7e35c7 100755 --- a/tests/novaboot.wv +++ b/tests/novaboot.wv @@ -1,40 +1,30 @@ -#!/bin/bash +#!/usr/bin/env bash cd $(dirname $0) . wvtest.sh -PATH=$(dirname $PWD):$PATH # Find our version of novaboot first -function create_script () -{ - (echo "#!/usr/bin/env novaboot"; cat) > script - chmod +x script -} +WVSTART Invoke with no script +WVPASS novaboot -t '' < /dev/null -function create_dummy () -{ - create_script < .novaboot WVPASS sh -c "./script --gen-only 2> log" WVPASS grep "novaboot: Read $PWD/.novaboot" log -exit +WVSTART Configuration files in symlinked directories +mkdir config +echo '1;' > config/.novaboot +mkdir script +( cd script; create_dummy ) +ln -s ../script config +WVPASS sh -c "./config/script/script --gen-only 2> log" +WVPASS grep "novaboot: Read $PWD/config/.novaboot" log + +WVSTART Builddir configuration variable +WVPASS mkdir -p build +cat > .novaboot <<'EOF' +$builddir="build"; +1; +EOF +create_script <<'EOF' +load file < echo Hello +EOF +WVPASS ./script --gen-only +WVPASS test -f build/file + +WVSTART Configuration directory +mkdir -p dir +echo '$test_a = 1;' > dir/a +echo '$test_c = 2;' > dir/c +echo '$test_c = 1;' > dir/b # Overriden by the 'c' file +echo '$test_ign=1;' > dir/b.txt # Ignored +WVPASS sh -c 'NOVABOOT_CONFIG_DIR=./dir novaboot --dump-config > config' +WVPASS sh -c 'grep \$test config > test' +WVPASS diff -u - test <<'EOF' +$test_a = 1; +$test_c = 2; +EOF + +WVSTART Fail with unknown target +create_dummy +WVFAIL sh -c "./script --gen-only -t non-existing-target" + +WVSTART BUILDDIR variable +WVPASS mkdir -p build +create_script <<'EOF' +BUILDDIR=build +load file < echo Hello +EOF +WVPASS ./script --gen-only +WVPASS test -f build/file + +WVSTART Hypervisor configuration variable +create_dummy +echo '$hypervisor="HYP";' > .novaboot +WVPASS ./script --gen-only --pulsar +WVPASS grep "exec HYP" config-novaboot -# Broken WVSTART ISO image generation create_dummy -WVPASS ./script --iso +WVPASS ./script --iso --gen-only + +WVSTART Recursive target definition +create_dummy +cat > .novaboot < '--reset-cmd="echo MyResetCmd"', + 't2' => '--target t1', +); +EOF +WVPASS sh -c "./script --target=t2|tee output" +WVPASS grep -q ^MyResetCmd output + +WVSTART Wrong target definition +create_dummy +cat > .novaboot < '--nonsense'); +EOF +WVPASS sh -c "./script --target=t1 2>&1 |tee output" +WVPASS grep -q "Error in target definition" output + +WVSTART Different ways of specifying target +cat > .novaboot <<'EOF' +%targets = ('t1' => '--remote-cmd="echo Target1 > t"', + 't2' => '--remote-cmd="echo Target2 > t"', + 't3' => '--remote-cmd="echo Target3 > t"'); +$default_target = 't1'; +EOF +WVPASSSH 'novaboot /dev/null' +WVPASS test "$(cat t)" = Target1 +WVPASSSH 'NOVABOOT_TARGET=t2 novaboot /dev/null' +WVPASS test "$(cat t)" = Target2 +WVPASSSH 'NOVABOOT_TARGET=t2 novaboot --target t3 /dev/null' +WVPASS test "$(cat t)" = Target3 + +WVSTART --iprelay-cmd +WVPASS novaboot --iprelay-cmd="echo -e '\xFF\xFA\x2C\x97\xDF\xFF\xF0 \xFF\xFA\x2C\x97\xFF\xFF\xF0'" --on + +WVSTART Killing of --remote-cmd when it ignores SIGHUP +WVPASS tee script <<'EOF' +$SIG{HUP}='IGNORE'; +open(FH, ">", "pid") or die; +print FH "$$"; +close FH; +print "ready pid=$$\n"; +print "exit\n"; +sleep; +EOF +WVPASS novaboot --remote-cmd='perl script' --remote-expect=ready --exiton=exit /dev/null +WVFAIL test -d /proc/$(cat pid) +coproc novaboot --remote-cmd='perl script' --remote-expect=ready /dev/null +WVPASS sed -e '/ready/q0' <&${COPROC[0]} +WVPASS kill $COPROC_PID +WVFAIL wait $COPROC_PID # Signal termination is considered a failure +WVFAIL test -d /proc/$(cat pid) + +WVSTART Correct invocation path +WVPASS mkdir dir +WVPASS tee dir/.novaboot <<<'print "Config OK\n";' +( + WVPASS cd dir + WVPASS novaboot /dev/null | WVPASS grep "Config OK" +) +WVPASS tee dir/Makefile <