aboutgitcodebugslistschat
path: root/test/lib/term
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-05-12 13:36:21 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-05-19 15:24:15 +0200
commit13ad716f300b2e78866978a1e4097e5ad016cbc1 (patch)
tree2d9eb0728908ec2b8ec06c9ab8d02b62f530275b /test/lib/term
parent3e0641f91f7296dca67224babc221f3a161224e1 (diff)
downloadpasst-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar.gz
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar.bz2
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar.lz
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar.xz
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.tar.zst
passt-13ad716f300b2e78866978a1e4097e5ad016cbc1.zip
tests: Add pane_status command to check for success of issued commands
When we use pane_wait to wait for a command issued to a tmux pane to finish we have no idea whether the command succeeded or not. This means that the test scripts can keep running long after the point something vital has failed, making it difficult to work out what went wrong. Add a new pane_status command that checks for success of the issued command and use it in most places instead of pane_wait. We still need explicit pane_wait where we're gathering explicit output with pane_parse, because the way we check the status with 'echo $?' means we lose track of that output. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: - instead of quitting the script, make a test fail if a command issued in a pane fails during a test, and loop until the status code is numeric in pane_status() as a hack to make it a bit more robust - retain usage of pane_wait() in iperf3 and teardown functions as we interrupt iperf3, passt, and pasta, so a non-zero exit code is expected - drop bogus ns_{1,2}_wait() calls in teardown_two_guests(), those functions were never implemented - use pane_status() for "guest" test directives too ] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/lib/term')
-rwxr-xr-xtest/lib/term14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lib/term b/test/lib/term
index 0093f90..004c2a2 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -228,6 +228,20 @@ pane_parse() {
printf '%s' "${__buf}" || printf '@EMPTY@'
}
+# pane_status() - Wait for command to complete and return its exit status
+# $1: Pane name
+pane_status() {
+ pane_wait "${1}"
+ __status="$(pane_parse "${1}")"
+ while ! [ "${__status}" -eq "${__status}" ]; do
+ sleep 1
+ pane_run "${1}" 'echo $?'
+ pane_wait "${1}"
+ __status="$(pane_parse "${1}")"
+ done
+ return ${__status}
+}
+
# status_file_end() - Display and log messages when tests from one file are done
status_file_end() {
[ -z "${STATUS_FILE}" ] && return