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 Invoke with no script
WVPASS novaboot -t '' < /dev/null
WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF
WVPASS grep "root ASDF" config-novaboot
-WVSTART Bender
-create_dummy
-WVPASS ./script --gen-only --bender --pulsar
-WVPASS grep "bender" config-novaboot
-
-WVSTART Chainloader support
-create_dummy
-WVPASS ./script --gen-only --chainloader=chain1 -chainloader=chain2 --pulsar
-WVPASS grep "exec chain1" config-novaboot
-WVPASS grep "load chain2" config-novaboot
-
WVSTART Configuration files
create_dummy
echo '1;' > .novaboot
1;
EOF
create_script <<'EOF'
-file < echo Hello
+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"
WVPASS mkdir -p build
create_script <<'EOF'
BUILDDIR=build
-file < echo Hello
+load file < echo Hello
EOF
WVPASS ./script --gen-only
WVPASS test -f build/file
WVPASS ./script --gen-only --pulsar
WVPASS grep "exec HYP" config-novaboot
-exit
-
-# Broken
WVSTART ISO image generation
create_dummy
-WVPASS ./script --iso
+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
+
# Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))