From 00f9febf9c16d932380243a3135ee5aed1adc410 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 29 Mar 2019 16:31:39 +1100 Subject: tests: Rename tests.sh to testutils.sh tests.sh has a bunch of shell setup that's sourced in a number of other scripts. It _doesn't_ actually run a bunch of tests, which is kind of what the name suggests. So rename it to be more obvious. Signed-off-by: David Gibson --- tests/dtc-checkfails.sh | 2 +- tests/dtc-fails.sh | 2 +- tests/dtc-fatal.sh | 2 +- tests/fdtdump-runtest.sh | 2 +- tests/fdtget-runtest.sh | 2 +- tests/fdtoverlay-runtest.sh | 2 +- tests/fdtput-runtest.sh | 2 +- tests/run_tests.sh | 2 +- tests/tests.sh | 63 --------------------------------------------- tests/testutils.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 tests/tests.sh create mode 100644 tests/testutils.sh (limited to 'tests') diff --git a/tests/dtc-checkfails.sh b/tests/dtc-checkfails.sh index 7319597..0e8beb4 100755 --- a/tests/dtc-checkfails.sh +++ b/tests/dtc-checkfails.sh @@ -1,6 +1,6 @@ #! /bin/sh -. ./tests.sh +. ./testutils.sh for x; do shift diff --git a/tests/dtc-fails.sh b/tests/dtc-fails.sh index 4ddcb27..4543203 100755 --- a/tests/dtc-fails.sh +++ b/tests/dtc-fails.sh @@ -1,6 +1,6 @@ #! /bin/sh -. ./tests.sh +. ./testutils.sh if [ "$1" = "-n" ]; then NEG="$1" diff --git a/tests/dtc-fatal.sh b/tests/dtc-fatal.sh index 6781ced..22eea69 100644 --- a/tests/dtc-fatal.sh +++ b/tests/dtc-fatal.sh @@ -1,6 +1,6 @@ #! /bin/sh -. ./tests.sh +. ./testutils.sh verbose_run $VALGRIND "$DTC" -o/dev/null "$@" ret="$?" diff --git a/tests/fdtdump-runtest.sh b/tests/fdtdump-runtest.sh index 77593cf..616c737 100644 --- a/tests/fdtdump-runtest.sh +++ b/tests/fdtdump-runtest.sh @@ -4,7 +4,7 @@ # $1 - source file to compile and compare with fdtdump output of the # compiled file. -. ./tests.sh +. ./testutils.sh dts="$1" dtb="${dts}.dtb" diff --git a/tests/fdtget-runtest.sh b/tests/fdtget-runtest.sh index 8d8b058..21044f3 100755 --- a/tests/fdtget-runtest.sh +++ b/tests/fdtget-runtest.sh @@ -1,6 +1,6 @@ #! /bin/sh -. ./tests.sh +. ./testutils.sh LOG=tmp.log.$$ EXPECT=tmp.expect.$$ diff --git a/tests/fdtoverlay-runtest.sh b/tests/fdtoverlay-runtest.sh index 06c1169..c7dbc0f 100644 --- a/tests/fdtoverlay-runtest.sh +++ b/tests/fdtoverlay-runtest.sh @@ -6,7 +6,7 @@ # Usage # fdtoverlay-runtest.sh name expected_output dtb_file node property flags value -. ./tests.sh +. ./testutils.sh LOG=tmp.log.$$ EXPECT=tmp.expect.$$ diff --git a/tests/fdtput-runtest.sh b/tests/fdtput-runtest.sh index 527a968..b5beb90 100644 --- a/tests/fdtput-runtest.sh +++ b/tests/fdtput-runtest.sh @@ -6,7 +6,7 @@ # Usage # fdtput-runtest.sh name expected_output dtb_file node property flags value -. ./tests.sh +. ./testutils.sh LOG=tmp.log.$$ EXPECT=tmp.expect.$$ diff --git a/tests/run_tests.sh b/tests/run_tests.sh index f6b308f..e951959 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1,6 +1,6 @@ #! /bin/sh -. ./tests.sh +. ./testutils.sh if [ -z "$CC" ]; then CC=gcc diff --git a/tests/tests.sh b/tests/tests.sh deleted file mode 100644 index 8dda6e1..0000000 --- a/tests/tests.sh +++ /dev/null @@ -1,63 +0,0 @@ -# Common functions for shell testcases - -PASS () { - echo "PASS" - exit 0 -} - -FAIL () { - echo "FAIL" "$@" - exit 2 -} - -FAIL_IF_SIGNAL () { - ret="$1" - if [ "$ret" -gt 127 ]; then - signame=$(kill -l $((ret - 128))) - FAIL "Killed by SIG$signame" - fi -} - -DTC=../dtc -DTGET=../fdtget -DTPUT=../fdtput -FDTDUMP=../fdtdump -FDTOVERLAY=../fdtoverlay - -verbose_run () { - if [ -z "$QUIET_TEST" ]; then - "$@" - else - "$@" > /dev/null 2> /dev/null - fi -} - -verbose_run_check () { - verbose_run "$@" - ret="$?" - FAIL_IF_SIGNAL $ret - if [ $ret != 0 ]; then - FAIL "Returned error code $ret" - fi -} - -verbose_run_log () { - LOG="$1" - shift - "$@" > "$LOG" 2>&1 - ret=$? - if [ -z "$QUIET_TEST" ]; then - cat "$LOG" >&2 - fi - return $ret -} - -verbose_run_log_check () { - verbose_run_log "$@" - ret="$?" - FAIL_IF_SIGNAL $ret - if [ $ret != 0 ]; then - FAIL "Returned error code $ret" - fi -} - diff --git a/tests/testutils.sh b/tests/testutils.sh new file mode 100644 index 0000000..8dda6e1 --- /dev/null +++ b/tests/testutils.sh @@ -0,0 +1,63 @@ +# Common functions for shell testcases + +PASS () { + echo "PASS" + exit 0 +} + +FAIL () { + echo "FAIL" "$@" + exit 2 +} + +FAIL_IF_SIGNAL () { + ret="$1" + if [ "$ret" -gt 127 ]; then + signame=$(kill -l $((ret - 128))) + FAIL "Killed by SIG$signame" + fi +} + +DTC=../dtc +DTGET=../fdtget +DTPUT=../fdtput +FDTDUMP=../fdtdump +FDTOVERLAY=../fdtoverlay + +verbose_run () { + if [ -z "$QUIET_TEST" ]; then + "$@" + else + "$@" > /dev/null 2> /dev/null + fi +} + +verbose_run_check () { + verbose_run "$@" + ret="$?" + FAIL_IF_SIGNAL $ret + if [ $ret != 0 ]; then + FAIL "Returned error code $ret" + fi +} + +verbose_run_log () { + LOG="$1" + shift + "$@" > "$LOG" 2>&1 + ret=$? + if [ -z "$QUIET_TEST" ]; then + cat "$LOG" >&2 + fi + return $ret +} + +verbose_run_log_check () { + verbose_run_log "$@" + ret="$?" + FAIL_IF_SIGNAL $ret + if [ $ret != 0 ]; then + FAIL "Returned error code $ret" + fi +} + -- cgit v1.1