mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-20 17:32:15 +00:00
test(xcat-core): the Genesis bats helper accepts only the GNU form of a signalled exit
run_genesis in xCAT-test/bats/helpers/genesis_sandbox.bash compared the status of "timeout 20 /bin/bash /run/script" with one exact number. GNU coreutils timeout reports a child that a signal killed as 128+signal, so genesis_discovery_uuid.bats expects 143 for SIGTERM. The uutils coreutils of Ubuntu 26.04 reports the signal number alone, 15, so the same outcome fails the assertion there. run_genesis now accepts the expected status or, when that status is above 128, the signal number alone. A caller that expects 0 keeps one accepted value, and an unrelated failure is still a failure. The comment names the two conventions. Evidence: a four-case bats file drives run_genesis with a controlled status. With the change, 143 and 15 both pass against an expected 143, while status 1 against 143 and status 15 against 0 still fail. Without the change only the 15 case flips to "Expected exit 143, got 15"; the control and both discriminators are unchanged. The five "= 143" comparisons in genesis_openembedded_runtime.bats stay as they are: terminate_after reads its status from the bash wait builtin, which computes 128+signal itself and does not call timeout. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -45,11 +45,18 @@ setup_genesis_sandbox()
|
||||
|
||||
run_genesis()
|
||||
{
|
||||
local expected_status=$1
|
||||
local expected_status=$1 alternate_status
|
||||
shift
|
||||
# GNU timeout reports a child that a signal killed as 128+signal. The uutils timeout of
|
||||
# Ubuntu 26.04 reports the signal number alone, so one SIGTERM is 143 or 15 by platform.
|
||||
alternate_status=$expected_status
|
||||
if [ "$expected_status" -gt 128 ]; then
|
||||
alternate_status=$((expected_status - 128))
|
||||
fi
|
||||
run "${sandbox[@]}" "$@" timeout 20 /bin/bash /run/script </dev/null
|
||||
if [ "$status" -ne "$expected_status" ]; then
|
||||
printf 'Expected exit %s, got %s\n%s\n' "$expected_status" "$status" "$output" >&2
|
||||
if [ "$status" -ne "$expected_status" ] && [ "$status" -ne "$alternate_status" ]; then
|
||||
printf 'Expected exit %s or %s, got %s\n%s\n' \
|
||||
"$expected_status" "$alternate_status" "$status" "$output" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user