Skip to content

Commit

Permalink
sdnotify test: accept MAINPID anywhere
Browse files Browse the repository at this point in the history
systemd sometimes spits out lines in the wrong order. Deal with it.

This fixes an infrequent flake that I haven't filed because I
didn't understand it well enough. (Hence, this reduces BUGS
but does not reduce BUG COUNT. Sorry!)

Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago committed Sep 30, 2021
1 parent 16b9b51 commit cc42321
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/system/260-sdnotify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function _stop_socat() {

# Check that MAINPID=xxxxx points to a running conmon process
function _assert_mainpid_is_conmon() {
local mainpid=$(expr "$1" : "MAINPID=\([0-9]\+\)")
local mainpid=$(expr "$1" : ".*MAINPID=\([0-9]\+\)")
test -n "$mainpid" || die "Could not parse '$1' as 'MAINPID=nnnn'"

test -d /proc/$mainpid || die "sdnotify MAINPID=$mainpid - but /proc/$mainpid does not exist"
Expand Down Expand Up @@ -121,7 +121,7 @@ function _assert_mainpid_is_conmon() {
# we look for READY=1 _anywhere_ in the output, not just the last line.
is "$output" ".*READY=1.*" "sdnotify sent READY=1"

_assert_mainpid_is_conmon "${lines[0]}"
_assert_mainpid_is_conmon "$output"

# Done. Stop container, clean up.
run_podman exec $cid touch /stop
Expand Down Expand Up @@ -163,7 +163,7 @@ function _assert_mainpid_is_conmon() {

is "$output" ".*READY=1" "received READY=1 through notify socket"

_assert_mainpid_is_conmon "${lines[0]}"
_assert_mainpid_is_conmon "$output"

# Done. Stop container, clean up.
run_podman exec $cid touch /stop
Expand Down

0 comments on commit cc42321

Please sign in to comment.