[nft] tests: shell: add tests for listing objects

Message ID 20180710200021.10147-1-harshasharmaiitr@gmail.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series
  • [nft] tests: shell: add tests for listing objects
Related show

Commit Message

Harsha Sharma July 10, 2018, 8 p.m.
Add tests for listing specific object for a given table name and all
objects of a table.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
 tests/shell/testcases/listing/0013objects_0 | 33 +++++++++++++++++++++++++++++
 tests/shell/testcases/listing/0014objects_0 | 24 +++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100755 tests/shell/testcases/listing/0013objects_0
 create mode 100755 tests/shell/testcases/listing/0014objects_0

Comments

Pablo Neira Ayuso July 16, 2018, 3:50 p.m. | #1
On Tue, Jul 10, 2018 at 10:00:21PM +0200, Harsha Sharma wrote:
> Add tests for listing specific object for a given table name and all
> objects of a table.

Applied, thanks Harsha.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/tests/shell/testcases/listing/0013objects_0 b/tests/shell/testcases/listing/0013objects_0
new file mode 100755
index 0000000..c5e0e32
--- /dev/null
+++ b/tests/shell/testcases/listing/0013objects_0
@@ -0,0 +1,33 @@ 
+#!/bin/bash
+
+# list table with all objects and chains
+
+EXPECTED="table ip test {
+	quota https-quota {
+		25 mbytes
+	}
+
+	ct helper cthelp {
+		type \"sip\" protocol tcp
+		l3proto ip
+	}
+
+	chain input {
+	}
+}"
+
+set -e
+
+$NFT add table test
+$NFT add chain test input
+$NFT add quota test https-quota 25 mbytes
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
+$NFT add table test-ip
+
+GET="$($NFT list table test)"
+if [ "$EXPECTED" != "$GET" ] ; then
+	DIFF="$(which diff)"
+	[ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+	exit 1
+fi
+
diff --git a/tests/shell/testcases/listing/0014objects_0 b/tests/shell/testcases/listing/0014objects_0
new file mode 100755
index 0000000..dcfe2e6
--- /dev/null
+++ b/tests/shell/testcases/listing/0014objects_0
@@ -0,0 +1,24 @@ 
+#!/bin/bash
+
+# list only the object asked for with table
+
+EXPECTED="table ip test {
+	quota https-quota {
+		25 mbytes
+	}
+}"
+
+set -e
+
+$NFT add table test
+$NFT add quota test https-quota 25 mbytes
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
+$NFT add table test-ip
+
+GET="$($NFT list quota test https-quota)"
+if [ "$EXPECTED" != "$GET" ] ; then
+	DIFF="$(which diff)"
+	[ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+	exit 1
+fi
+