Skip to contentSkip to conversation

tests: shell: Fix for ineffective 0007-mid-restore-flush_0

PATCH In review Phil Sutter 1 participant 2 messages Sep 14, 2023 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 tests: shell: Fix for ineffective 0007-mid-restore-flush_0

The test did not catch non-zero exit status of the spawned coprocess. To make it happen, Drop the line killing it (it will exit anyway) and pass its PID to 'wait'.

While being at it, put the sleep into the correct spot (otherwise the check for chain 'foo' existence fails as it runs too early) and make said chain existence check effective.

Fixes 4e3c11a6f5a94 ("nft: Fix for ruleset flush while restoring")
---
 .../shell/testcases/nft-only/0007-mid-restore-flush_0  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
iptables/tests/shell/testcases/nft-only/0007-mid-restore-flush_0 +5 -5
index 43880ffbc5851..981f007f205b9 100755
@@ -13,11 +13,11 @@ COMMIT
 :foo [0:0]
 EOF
 
-$XT_MULTI iptables-save | grep -q ':foo'
+sleep 1
+$XT_MULTI iptables-save | grep -q ':foo' || exit 1
 nft flush ruleset
 
 echo "COMMIT" >&"${COPROC[1]}"
-sleep 1
-
-[[ -n $COPROC_PID ]] && kill $COPROC_PID
-wait
+# close the pipe to make iptables-restore exit if it didn't error out yet
+eval "exec ${COPROC[1]}>&-"
+wait $COPROC_PID
Signature · 1 line
2.41.0
author reviewer
#1 lore raw
Quoted 10 lines · Phil Sutter

The test did not catch non-zero exit status of the spawned coprocess. To make it happen, Drop the line killing it (it will exit anyway) and pass its PID to 'wait'.

While being at it, put the sleep into the correct spot (otherwise the check for chain 'foo' existence fails as it runs too early) and make said chain existence check effective.

Fixes 4e3c11a6f5a94 ("nft: Fix for ruleset flush while restoring")

Patch applied.