]> rtime.felk.cvut.cz Git - novaboot.git/blobdiff - tests/novaboot.wv
tests: Fix iprelay-cmd test to work on both Debian an NixOS
[novaboot.git] / tests / novaboot.wv
index 91905ec69a486afcb736386a3e1c3812f2d30fe0..4b73577729913e66233bd8ff1225e3f86892c8ce 100755 (executable)
-#!/bin/bash
+#!/usr/bin/env bash
 
 cd $(dirname $0)
 . wvtest.sh
 
+WVSTART Invoke with no script
+WVPASS novaboot -t '' < /dev/null
+
+WVSTART Invoke as script
+create_dummy
+WVPASS ./script --gen-only
+
+WVSTART Invoke as script with absolute path
+create_dummy
+WVPASS $PWD/script --gen-only
+
 WVSTART Pulsar root
-WVPASS ../examples/linux-test --gen-only --pulsar --pulsar-root=ASDF
-WVPASS grep "root ASDF" ../examples/config-novaboot
+create_dummy
+WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF
+WVPASS grep "root ASDF" config-novaboot
+
+WVSTART Pulsar supports chld
+create_script <<EOF
+chld grub
+EOF
+WVPASS ./script --gen-only --pulsar
+WVPASS grep "chld grub" config-novaboot
+
+WVSTART Configuration files
+create_dummy
+echo '1;' > .novaboot
+WVPASS sh -c "./script --gen-only 2> log"
+WVPASS grep "novaboot: Read $PWD/.novaboot" log
+
+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
+
+WVSTART ISO image generation
+create_dummy
+WVPASS ./script --iso --gen-only
+
+WVSTART Recursive target definition
+create_dummy
+cat > .novaboot <<EOF
+%targets = (
+    't1' => '--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 <<EOF
+%targets = ('t1' => '--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="$(which echo) -e '<iprelayd: connected>\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 <<EOF
+all:
+       novaboot /dev/null
+EOF
+WVPASS make -C dir | WVPASS grep "Config OK"
+
+WVSTART "INTERACTION variable"
+WVPASS novaboot --remote-cmd=cat <<<INTERACTION=0
+
+WVSTART "Do not accept directories"
+WVPASS mkdir -p tftproot
+WVFAIL novaboot --server=tftproot <<<"load $PWD"
 
-WVSTART Bender
-WVPASS ../examples/linux-test --gen-only --bender --pulsar
-WVPASS grep "bender" ../examples/config-novaboot
+WVSTART "Accept /dev/null file"
+WVPASS mkdir -p tftproot
+WVPASS novaboot --server=tftproot <<<"load /dev/null"
 
-WVSTART Chainloader support
-WVPASS ../examples/linux-test --gen-only --chainloader=chain1 -chainloader=chain2 --pulsar
-WVPASS grep "exec chain1" ../examples/config-novaboot
-WVPASS grep "load chain2" ../examples/config-novaboot
+# Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))