]> rtime.felk.cvut.cz Git - novaboot.git/blobdiff - tests/novaboot.wv
Allow specifying target in NOVABOOT_TARGET environment variable
[novaboot.git] / tests / novaboot.wv
index 6dadb83042a54a5b795e0eb237b29e35e1a0faea..da97b45debe5f2723baaa21aa07a5d6e843ca222 100755 (executable)
@@ -2,39 +2,22 @@
 
 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
-}
-
-function create_dummy ()
-{
-    create_script <<EOF
-kernel
-file
-EOF
-    touch kernel
-    touch file
-}
 
-WVSTART Pulsar root
+WVSTART Invoke with no script
+WVPASS novaboot -t '' < /dev/null
+
+WVSTART Invoke as script
 create_dummy
-WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF
-WVPASS grep "root ASDF" config-novaboot
+WVPASS ./script --gen-only
 
-WVSTART Bender
+WVSTART Invoke as script with absolute path
 create_dummy
-WVPASS ./script --gen-only --bender --pulsar
-WVPASS grep "bender" config-novaboot
+WVPASS $PWD/script --gen-only
 
-WVSTART Chainloader support
+WVSTART Pulsar root
 create_dummy
-WVPASS ./script --gen-only --chainloader=chain1 -chainloader=chain2 --pulsar
-WVPASS grep "exec chain1" config-novaboot
-WVPASS grep "load chain2" config-novaboot
+WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF
+WVPASS grep "root ASDF" config-novaboot
 
 WVSTART Configuration files
 create_dummy
@@ -42,32 +25,95 @@ echo '1;' > .novaboot
 WVPASS sh -c "./script --gen-only 2> log"
 WVPASS grep "novaboot: Read $PWD/.novaboot" log
 
-WVSTART Builddir configuration
+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'
-file <<XXX
-Hello
-XXX
+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
+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
 
-exit
+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
 
-# Broken
-WVSTART ISO image generation
+WVSTART Wrong target definition
 create_dummy
-WVPASS ./script --iso
+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
+
 
 # Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))