]> rtime.felk.cvut.cz Git - novaboot.git/blobdiff - tests/wvtest.sh
Add tests for GRUB2 BOOT_METHOD
[novaboot.git] / tests / wvtest.sh
index f3fa327ae9fcf7989d41e422ec680385cd296ae5..6c15ca9ec8646d3983e44a5f467cfe4740cf7785 100644 (file)
@@ -46,7 +46,7 @@ _wvcheck()
        fi
        echo "! $WVCALLER_FILE:$WVCALLER_LINE  $TEXT  $OK" >&2
        if [ "$CODE" -ne 0 ]; then
-               exit $CODE
+               return $CODE
        else
                return 0
        fi
@@ -68,6 +68,23 @@ WVPASS()
        fi
 }
 
+# Use WVPASSSH instead of WVPASS when the command includes pipe or
+# output redirection. The whole command must be one argument - quote
+# it.
+WVPASSSH()
+{
+       TEXT="$1"
+
+       _wvfind_caller
+       if bash -o pipefail -c "$@"; then
+               _wvcheck 0 "$TEXT"
+               return 0
+       else
+               _wvcheck 1 "$TEXT"
+               # NOTREACHED
+               return 1
+       fi
+}
 
 WVFAIL()
 {
@@ -146,3 +163,23 @@ WVSTART()
 
 WV_BASE_DIR="$PWD"
 export NOVABOOT_TEST=1
+export NOVABOOT_CONFIG_DIR=/dev/null # Do not read config from /etc/novaboot.d
+export XDG_CONFIG_HOME=/dev/null # Do not read user config from ~/.config/novaboot
+
+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
+load kernel
+load file
+EOF
+    touch kernel
+    touch file
+}