summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/chains
diff options
context:
space:
mode:
authorLaura Garcia Liebana <nevola@gmail.com>2018-03-07 22:51:10 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2018-03-09 12:45:16 +0100
commit7d93e2c2fbc77f05fd7acb63a2acf9874c9ad58f (patch)
tree6773a61dcd261a25d525457bf8b6049787345424 /tests/shell/testcases/chains
parent1870165e0241bd06f96da43edbee0e0e82bfa09d (diff)
tests: shell: autogenerate dump verification
Complete the automated shell tests with the verification of the test file dump, only for positive tests and if the test execution was successful. It's able to generate the dump file with the -g option. Example: # ./run-tests.sh -g testcases/chains/0001jumps_0 The dump files are generated in the same path in the folder named dumps/ with .nft extension. It has been avoided the dump verification code in every test file. Signed-off-by: Laura Garcia Liebana <nevola@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/chains')
-rwxr-xr-xtests/shell/testcases/chains/0016delete_handle_023
-rw-r--r--tests/shell/testcases/chains/dumps/0001jumps_0.nft64
-rw-r--r--tests/shell/testcases/chains/dumps/0006masquerade_0.nft6
-rw-r--r--tests/shell/testcases/chains/dumps/0013rename_0.nft4
-rw-r--r--tests/shell/testcases/chains/dumps/0016delete_handle_0.nft20
5 files changed, 94 insertions, 23 deletions
diff --git a/tests/shell/testcases/chains/0016delete_handle_0 b/tests/shell/testcases/chains/0016delete_handle_0
index cf11da8a..677fba37 100755
--- a/tests/shell/testcases/chains/0016delete_handle_0
+++ b/tests/shell/testcases/chains/0016delete_handle_0
@@ -11,26 +11,3 @@ $NFT add chain ip6 test-ip6 y # should have handle 2
$NFT add chain ip6 test-ip6 z # should have handle 3
$NFT delete chain test-ip handle 2
$NFT delete chain ip6 test-ip6 handle 3
-
-EXPECTED="table ip test-ip {
- chain x {
- }
-
- chain z {
- }
-}
-table ip6 test-ip6 {
- chain x {
- }
-
- chain y {
- }
-}"
-
-GET="$($NFT list ruleset)"
-
-if [ "$EXPECTED" != "$GET" ] ; then
- DIFF="$(which diff)"
- [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
- exit 1
-fi
diff --git a/tests/shell/testcases/chains/dumps/0001jumps_0.nft b/tests/shell/testcases/chains/dumps/0001jumps_0.nft
new file mode 100644
index 00000000..7054cde4
--- /dev/null
+++ b/tests/shell/testcases/chains/dumps/0001jumps_0.nft
@@ -0,0 +1,64 @@
+table ip t {
+ chain c1 {
+ jump c2
+ }
+
+ chain c2 {
+ jump c3
+ }
+
+ chain c3 {
+ jump c4
+ }
+
+ chain c4 {
+ jump c5
+ }
+
+ chain c5 {
+ jump c6
+ }
+
+ chain c6 {
+ jump c7
+ }
+
+ chain c7 {
+ jump c8
+ }
+
+ chain c8 {
+ jump c9
+ }
+
+ chain c9 {
+ jump c10
+ }
+
+ chain c10 {
+ jump c11
+ }
+
+ chain c11 {
+ jump c12
+ }
+
+ chain c12 {
+ jump c13
+ }
+
+ chain c13 {
+ jump c14
+ }
+
+ chain c14 {
+ jump c15
+ }
+
+ chain c15 {
+ jump c16
+ }
+
+ chain c16 {
+ }
+}
diff --git a/tests/shell/testcases/chains/dumps/0006masquerade_0.nft b/tests/shell/testcases/chains/dumps/0006masquerade_0.nft
new file mode 100644
index 00000000..e4b9872b
--- /dev/null
+++ b/tests/shell/testcases/chains/dumps/0006masquerade_0.nft
@@ -0,0 +1,6 @@
+table ip t {
+ chain c1 {
+ type nat hook postrouting priority 0; policy accept;
+ masquerade
+ }
+}
diff --git a/tests/shell/testcases/chains/dumps/0013rename_0.nft b/tests/shell/testcases/chains/dumps/0013rename_0.nft
new file mode 100644
index 00000000..e4e0171c
--- /dev/null
+++ b/tests/shell/testcases/chains/dumps/0013rename_0.nft
@@ -0,0 +1,4 @@
+table ip t {
+ chain c2 {
+ }
+}
diff --git a/tests/shell/testcases/chains/dumps/0016delete_handle_0.nft b/tests/shell/testcases/chains/dumps/0016delete_handle_0.nft
new file mode 100644
index 00000000..de6ee9c0
--- /dev/null
+++ b/tests/shell/testcases/chains/dumps/0016delete_handle_0.nft
@@ -0,0 +1,20 @@
+table ip test-ip {
+ chain x {
+ }
+
+ chain y {
+ }
+
+ chain z {
+ }
+}
+table ip6 test-ip6 {
+ chain x {
+ }
+
+ chain y {
+ }
+
+ chain z {
+ }
+}