Skip to content

Commit

Permalink
Merge pull request #6343 from garlick/issue#6336
Browse files Browse the repository at this point in the history
testsuite: improve test_must_fail_or_be_killed function
  • Loading branch information
mergify[bot] authored Oct 3, 2024
2 parents 98a4912 + b7b0c6c commit 8167833
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions t/sharness.d/flux-sharness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ test_must_fail_or_be_terminated() {
if test $exit_code = 143 -o $exit_code = 137; then
return 0
elif test $exit_code = 0; then
echo >&2 "test_must_fail: command succeeded: $*"
echo >&2 "test_must_fail_or_be_terminated: command succeeded: $*"
return 1
elif test $exit_code -gt 129 -a $exit_code -le 192; then
echo >&2 "test_must_fail: died by non-SIGTERM signal: $*"
elif test $exit_code -ge 129 -a $exit_code -le 192; then
echo >&2 "test_must_fail_or_be_terminated: died by signal $(($exit_code-128)): $*"
return 1
elif test $exit_code = 127; then
echo >&2 "test_must_fail: command not found: $*"
echo >&2 "test_must_fail_or_be_terminated: command not found: $*"
return 1
fi
return 0
Expand Down
12 changes: 12 additions & 0 deletions t/t0001-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ test_expect_success 'test run_timeout with success' '
test_expect_success 'run_timeout fails if exec fails' '
test_must_fail run_timeout 1 /nonexistent/executable
'
test_expect_success 'test_must_fail_or_be_terminated fails on success' '
test_must_fail test_must_fail_or_be_terminated true
'
test_expect_success 'test_must_fail_or_be_terminated succeeds on nonzero exit' '
test_must_fail_or_be_terminated false
'
test_expect_success 'test_must_fail_or_be_terminated succeeds on SIGTERM' '
test_must_fail_or_be_terminated sh -c "kill \$\$"
'
test_expect_success 'test_must_fail_or_be_terminated fails on SIGHUP' '
test_must_fail test_must_fail_or_be_terminated sh -c "kill -HUP \$\$"
'
test_expect_success 'we can find a flux binary' '
flux --help >/dev/null
'
Expand Down

0 comments on commit 8167833

Please sign in to comment.