Add "Testing" headers
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 5 Feb 2014 16:57:27 +0000 (17:57 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 5 Feb 2014 16:57:27 +0000 (17:57 +0100)
continuous/steps/40-run-tests
continuous/tests/kernelgw
continuous/tests/lib.sh [new file with mode: 0644]
continuous/tests/ugw-mmap-mmap
continuous/tests/ugw-mmsg-mmsg
continuous/tests/ugw-read-write
continuous/tests/ugw-readnb-write
continuous/tests/wvtest.sh [new file with mode: 0644]

index 413e89a..16a6826 100755 (executable)
@@ -4,4 +4,5 @@ set -e
 
 export LINUX_IMAGE=$PWD/linux/arch/powerpc/boot/uImage
 
-run-parts -v ../tests
+cd ../tests
+run-parts -v .
index 2bd5594..6a023e4 100755 (executable)
@@ -1,4 +1,8 @@
-#!/bin/sh
+#!/bin/bash
+
+. lib.sh
+
+WVSTART Kernel gateway
 
 ../gw-setup/run.pl <<EOF
 cangw -A -s can0 -d can1
diff --git a/continuous/tests/lib.sh b/continuous/tests/lib.sh
new file mode 100644 (file)
index 0000000..95c027c
--- /dev/null
@@ -0,0 +1,6 @@
+if [ -z "$BASH_VERSION" ]; then
+    echo >&2 "Please use bash"
+    exit 1
+fi
+
+. wvtest.sh
index 015d134..a8d1030 100755 (executable)
@@ -1,4 +1,8 @@
-#!/bin/sh
+#!/bin/bash
+
+. lib.sh
+
+WVSTART User space gateway (mmap-mmap)
 
 ../gw-setup/run.pl <<EOF
 ugw -r mmap -t mmap
index 79369b6..6b21499 100755 (executable)
@@ -1,4 +1,8 @@
-#!/bin/sh
+#!/bin/bash
+
+. lib.sh
+
+WVSTART User space gateway (recvmmsg-sendmmsg)
 
 ../gw-setup/run.pl <<EOF
 ugw -r mmsg -t mmsg
index 0ee11ca..9529d54 100755 (executable)
@@ -1,4 +1,8 @@
-#!/bin/sh
+#!/bin/bash
+
+. lib.sh
+
+WVSTART User space gateway (read-write)
 
 ../gw-setup/run.pl <<EOF
 ugw -r read -t write
index e3ec081..ce8c222 100755 (executable)
@@ -1,4 +1,8 @@
-#!/bin/sh
+#!/bin/bash
+
+. lib.sh
+
+WVSTART User space gateway (non-blocking read-write)
 
 ../gw-setup/run.pl <<EOF
 ugw -r read -t write -n
diff --git a/continuous/tests/wvtest.sh b/continuous/tests/wvtest.sh
new file mode 100644 (file)
index 0000000..47b4366
--- /dev/null
@@ -0,0 +1,140 @@
+#
+# WvTest:
+#   Copyright (C)2007-2012 Versabanq Innovations Inc. and contributors.
+#       Licensed under the GNU Library General Public License, version 2.
+#       See the included file named LICENSE for license information.
+#       You can get wvtest from: http://github.com/apenwarr/wvtest
+#
+# Include this file in your shell script by using:
+#         #!/bin/sh
+#         . ./wvtest.sh
+#
+
+# we don't quote $TEXT in case it contains newlines; newlines
+# aren't allowed in test output.  However, we set -f so that
+# at least shell glob characters aren't processed.
+_wvtextclean()
+{
+       ( set -f; echo $* )
+}
+
+
+if [ -n "$BASH_VERSION" ]; then
+       _wvfind_caller()
+       {
+               LVL=$1
+               WVCALLER_FILE=${BASH_SOURCE[2]}
+               WVCALLER_LINE=${BASH_LINENO[1]}
+       }
+else
+       _wvfind_caller()
+       {
+               LVL=$1
+               WVCALLER_FILE="unknown"
+               WVCALLER_LINE=0
+       }
+fi
+
+
+_wvcheck()
+{
+       CODE="$1"
+       TEXT=$(_wvtextclean "$2")
+       OK=ok
+       if [ "$CODE" -ne 0 ]; then
+               OK=FAILED
+       fi
+       echo "! $WVCALLER_FILE:$WVCALLER_LINE  $TEXT  $OK" >&2
+       if [ "$CODE" -ne 0 ]; then
+               exit $CODE
+       else
+               return 0
+       fi
+}
+
+
+WVPASS()
+{
+       TEXT="$*"
+
+       _wvfind_caller
+       if "$@"; then
+               _wvcheck 0 "$TEXT"
+               return 0
+       else
+               _wvcheck 1 "$TEXT"
+               # NOTREACHED
+               return 1
+       fi
+}
+
+
+WVFAIL()
+{
+       TEXT="$*"
+
+       _wvfind_caller
+       if "$@"; then
+               _wvcheck 1 "NOT($TEXT)"
+               # NOTREACHED
+               return 1
+       else
+               _wvcheck 0 "NOT($TEXT)"
+               return 0
+       fi
+}
+
+
+_wvgetrv()
+{
+       ( "$@" >&2 )
+       echo -n $?
+}
+
+
+WVPASSEQ()
+{
+       _wvfind_caller
+       _wvcheck $(_wvgetrv [ "$#" -eq 2 ]) "exactly 2 arguments"
+       echo "Comparing:" >&2
+       echo "$1" >&2
+       echo "--" >&2
+       echo "$2" >&2
+       _wvcheck $(_wvgetrv [ "$1" = "$2" ]) "'$1' = '$2'"
+}
+
+
+WVPASSNE()
+{
+       _wvfind_caller
+       _wvcheck $(_wvgetrv [ "$#" -eq 2 ]) "exactly 2 arguments"
+       echo "Comparing:" >&2
+       echo "$1" >&2
+       echo "--" >&2
+       echo "$2" >&2
+       _wvcheck $(_wvgetrv [ "$1" != "$2" ]) "'$1' != '$2'"
+}
+
+
+WVPASSRC()
+{
+       RC=$?
+       _wvfind_caller
+       _wvcheck $(_wvgetrv [ $RC -eq 0 ]) "return code($RC) == 0"
+}
+
+
+WVFAILRC()
+{
+       RC=$?
+       _wvfind_caller
+       _wvcheck $(_wvgetrv [ $RC -ne 0 ]) "return code($RC) != 0"
+}
+
+
+WVSTART()
+{
+       echo >&2
+       _wvfind_caller
+       echo "Testing \"$*\" in $WVCALLER_FILE:" >&2
+}