]> rtime.felk.cvut.cz Git - omk.git/blobdiff - tests/wvtest.sh
Update wvtool
[omk.git] / tests / wvtest.sh
index 0cfc6b240794377a83ca48b516fba9be96f4adf1..d6bc1984d73ad4651e8ee310caefd2c9028085f9 100644 (file)
@@ -1,6 +1,6 @@
 #
 # Include this file in your shell script by using:
-#         #!/bin/sh
+#         #!/bin/bash
 #         . ./wvtest.sh
 #
 
@@ -14,6 +14,8 @@ _wvtextclean()
 
 
 if [ -n "$BASH_VERSION" ]; then
+        trap 'echo "! ${BASH_SOURCE[0]}:${LINENO} ${BASH_COMMAND} FAILED"' ERR
+
        _wvfind_caller()
        {
                LVL=$1
@@ -130,5 +132,70 @@ WVSTART()
 {
        echo >&2
        _wvfind_caller
-       echo "Testing \"$*\" in $WVCALLER_FILE:" >&2
+       echo "Testing \"$* ($OMK_RULES)\" in $WVCALLER_FILE:" >&2
+       cd "$WV_BASE_DIR"
+       local dir=test.$(echo $* | tr -s '[[:blank:]]' _ | tr "A-Z" "a-z")
+       rm -rf "$dir"
+       mkdir -p "$dir"
+       WVPASS cd "$WV_BASE_DIR/$dir"
+       WVPASS cp "$OMK_TESTSROOT"/../rules/$OMK_RULES/* .
+       WVPASS cp "$OMK_TESTSROOT"/../snippets/Makefile.rules.$OMK_RULES Makefile.rules
+       WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
+}
+
+omkize()
+{
+    WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
+    for i in `find -L . -mindepth 2 -name Makefile.omk`; do
+       d=`dirname ${i}`
+       WVPASS cp Makefile "${d}/Makefile"
+    done
 }
+
+needs_valid_CC()
+{
+    CC=$(make omk-get-var VAR=CC|sed -ne '/^CC=/ s///p')
+    if ! which ${CC%% *} > /dev/null; then
+       echo "Warning: '$CC' not found - skipping the test"
+       exit 0
+    fi
+
+    if [[ $OMK_RULES = sysless-keil16x ]] && ! which cygpath; then
+       echo "Warning: cygpath command not found - skipping the test"
+       exit 0
+    fi
+
+    if [[ $OMK_RULES = sysless-keil51 ]] && ! which l51; then
+       echo "Warning: l51 command not found - skipping the test"
+       exit 0
+    fi
+}
+
+OMK_TESTSROOT=${OMK_TESTSROOT:-$(readlink --canonicalize $(dirname $0))}
+OMK_RULES=${OMK_RULES:-linux}  # When run manually, we use linux rules
+
+if [[ -f "${OMK_TESTSROOT}/${OMK_RULES}.env" ]]; then
+    WVPASS . "${OMK_TESTSROOT}/${OMK_RULES}.env"
+fi
+
+case $OMK_RULES in
+    rtems)
+       [[ -z "$RTEMS_MAKEFILE_PATH" ]] && exit 0
+       ;;
+    vxworks)
+       [[ -z "$WRENV" ]] && exit 0
+       ;;
+esac
+
+echo "Testing \"$OMK_RULES rules\" in $(basename $0):" >&2
+testdir="tmp/$(basename $0 .sh).$OMK_RULES"
+[[ -d "$testdir" ]] && WVPASS rm -rf "$testdir"
+WVPASS mkdir -p "$testdir"
+WVPASS cd "$testdir"
+WVPASS cp "$OMK_TESTSROOT"/../rules/$OMK_RULES/* .
+WVPASS cp "$OMK_TESTSROOT"/../snippets/Makefile.rules.$OMK_RULES Makefile.rules
+WVPASS cp "$OMK_TESTSROOT/../leaf-makefile/Makefile" .
+
+WV_BASE_DIR="$PWD"
+export MAKEFLAGS="--include-dir=$OMK_TESTSROOT/../snippets"
+export LC_ALL=C