summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/rule_management
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-08-01 13:35:27 +0200
committerPhil Sutter <phil@nwl.cc>2023-08-03 14:58:20 +0200
commitf6cc747991758801e4c3eb25bb06840870963cc2 (patch)
tree2ae998c68d919ad65c72d7d43bc85586671929d6 /tests/shell/testcases/rule_management
parent28d202216535ac54216f825e511a92d9acea5d3c (diff)
tests: shell: Review test-cases for destroy command
Having separate files for successful destroy of existing and non-existing objects is a bit too much, just combine them into one. While being at it: * No bashisms, using /bin/sh is fine * Append '-e' to shebang itself instead of calling 'set' * Use 'nft -a -e' instead of assuming the created rule's handle value * Shellcheck warned about curly braces, quote them Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'tests/shell/testcases/rule_management')
-rwxr-xr-xtests/shell/testcases/rule_management/0012destroy_09
-rwxr-xr-xtests/shell/testcases/rule_management/0013destroy_08
-rw-r--r--tests/shell/testcases/rule_management/dumps/0013destroy_04
3 files changed, 7 insertions, 14 deletions
diff --git a/tests/shell/testcases/rule_management/0012destroy_0 b/tests/shell/testcases/rule_management/0012destroy_0
index 1b61155e..85f9c9f6 100755
--- a/tests/shell/testcases/rule_management/0012destroy_0
+++ b/tests/shell/testcases/rule_management/0012destroy_0
@@ -1,7 +1,12 @@
-#!/bin/bash
+#!/bin/sh -e
-set -e
$NFT add table t
$NFT add chain t c
+# pass for non-existent rule
$NFT destroy rule t c handle 3333
+
+# successfully delete existing rule
+handle=$($NFT -a -e insert rule t c accept | \
+ sed -n 's/.*handle \([0-9]*\)$/\1/p')
+$NFT destroy rule t c handle "$handle"
diff --git a/tests/shell/testcases/rule_management/0013destroy_0 b/tests/shell/testcases/rule_management/0013destroy_0
deleted file mode 100755
index 895c24a4..00000000
--- a/tests/shell/testcases/rule_management/0013destroy_0
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-set -e
-$NFT add table t
-$NFT add chain t c
-$NFT insert rule t c accept # should have handle 2
-
-$NFT destroy rule t c handle 2
diff --git a/tests/shell/testcases/rule_management/dumps/0013destroy_0 b/tests/shell/testcases/rule_management/dumps/0013destroy_0
deleted file mode 100644
index 1e0d1d60..00000000
--- a/tests/shell/testcases/rule_management/dumps/0013destroy_0
+++ /dev/null
@@ -1,4 +0,0 @@
-table ip t {
- chain c {
- }
-}