diff options
| author | Amitay Isaacs <amitay@ozlabs.org> | 2018-11-14 16:14:08 +1100 |
|---|---|---|
| committer | Alistair Popple <alistair@popple.id.au> | 2018-11-15 15:18:00 +1100 |
| commit | 9067b232acc3cf576615d1e393ab0fe96ce453a5 (patch) | |
| tree | 1580e26547d33b5ec00238b6ff0f3acff461819b /tests | |
| parent | 15998979ba453cb4f07c4e287bf2fa1f0c7bca0b (diff) | |
| download | pdbg-9067b232acc3cf576615d1e393ab0fe96ce453a5.tar.gz pdbg-9067b232acc3cf576615d1e393ab0fe96ce453a5.zip | |
tests: Update driver to pass test_wrapper argument
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/driver.sh | 15 | ||||
| -rwxr-xr-x | tests/test_driver.sh | 10 | ||||
| -rwxr-xr-x | tests/test_hw_bmc.sh | 6 |
3 files changed, 23 insertions, 8 deletions
diff --git a/tests/driver.sh b/tests/driver.sh index 6df34b3..9e92135 100644 --- a/tests/driver.sh +++ b/tests/driver.sh @@ -44,8 +44,9 @@ # # test_wrapper # -# To execute commands in a special context, test_wrapper function can be -# defined. This function will be passed all the arguments to test_run +# Register a test wrapper function. If test_wrapper is called without +# an argument, then the test wrapper function is set to default. +# The test wrapper function will be passed all the arguments to test_run # command. # # @@ -222,9 +223,15 @@ test_wrapper_default () "$@" } +test_wrapper_func=test_wrapper_default + test_wrapper () { - test_wrapper_default "$@" + if [ $# -eq 0 ] ; then + test_wrapper_func=test_wrapper_default + else + test_wrapper_func="$1" + fi } result_filter_default () @@ -337,7 +344,7 @@ test_run () stderr_file=$(mktemp) - output_raw=$(test_wrapper "$@" 2>"$stderr_file") + output_raw=$($test_wrapper_func "$@" 2>"$stderr_file") rc=$? if [ $rc -ne $required_rc ] ; then diff --git a/tests/test_driver.sh b/tests/test_driver.sh index 6e8343a..803f69f 100755 --- a/tests/test_driver.sh +++ b/tests/test_driver.sh @@ -52,10 +52,14 @@ echo_stderr () echo "$*" >&2 } +test_wrapper echo_stderr + echo "match stderr" test_result 0 -- test_result_stderr foo -test_run echo_stderr foo +test_run foo + +test_wrapper echo @@ -73,11 +77,13 @@ test_run echo 666 echo -test_wrapper () +prefix_output () { echo "output: $*" } +test_wrapper prefix_output + test_result 0 "output: foobar" test_run foobar diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh index c65a630..c35597b 100755 --- a/tests/test_hw_bmc.sh +++ b/tests/test_hw_bmc.sh @@ -40,7 +40,7 @@ copy_pdbg () ${BMC_USER}@${BMC_HOST}:${PDBG_PATH} } -test_wrapper () +run_over_ssh () { sshpass -p "$BMC_PASS" \ ssh ${BMC_USER}@${BMC_HOST} \ @@ -64,7 +64,7 @@ do_skip () echo -n "Checking if the host is up... " -output=$(test_wrapper /usr/sbin/obmcutil state | grep CurrentHostState) +output=$(run_over_ssh /usr/sbin/obmcutil state | grep CurrentHostState) rc=$? if [ $rc -ne 0 ] || \ [ "$output" = "CurrentHostState : xyz.openbmc_project.State.Host.HostState.Running" ] ; then @@ -75,6 +75,8 @@ else echo "$output" fi +test_wrapper run_over_ssh + result_filter () { sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#' \ |

