]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: Add test for incomplete set add set command
authorShyam Saini <mayhs11saini@gmail.com>
Fri, 23 Jun 2017 12:05:55 +0000 (17:35 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 26 Jun 2017 16:53:40 +0000 (18:53 +0200)
Before c6cd7c22548a ("src: fix crash when inputting an incomplete set
add command") commit, if we run nft with incomplete "add set" command it
caused segmentation fault and exit with error code 139 and further it
didn't throw any error message.

  For example:
    $ sudo nft add set t s

But after the aforementioned commit it throws syntax error message and
exits with return value 1.

  For example:
    $ sudo nft add set t s
    <cmdline>:1:12-12: Error: syntax error, unexpected newline, expecting '{'
    add set t s
               ^
This commit tests changes made in such commit.

Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/sets/0023incomplete_add_set_command_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/sets/0023incomplete_add_set_command_0 b/tests/shell/testcases/sets/0023incomplete_add_set_command_0
new file mode 100755 (executable)
index 0000000..b7535f7
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# This testscase checks bug identified and fixed in the commit Id "c6cd7c22548a"
+# Before the commit c6cd7c22548a, nft returns 139 (i.e, segmentation fault) which
+# indicates the bug but after the commit it returns 1.
+
+$NFT add table t
+$NFT add set t c
+
+ret=$?
+if [ $ret -ne 1 ] ;
+then
+       echo "E: returned $ret instead of 1" >&2
+       exit 1
+fi
+