netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shyam Saini <mayhs11saini@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Shyam Saini <mayhs11saini@gmail.com>
Subject: [PATCH 2/2] tests: shell: Test input descriptors for included files
Date: Fri, 23 Jun 2017 17:35:56 +0530	[thread overview]
Message-ID: <1498219556-25179-2-git-send-email-mayhs11saini@gmail.com> (raw)
In-Reply-To: <1498219556-25179-1-git-send-email-mayhs11saini@gmail.com>

Before the [Test] commit, nft error message was pointing to wrong
file.

But after the commit it points to right file.
This commit test the changes made in the [Test] commit.

Test:b14572f72aac (" erec: Fix input descriptors for included files ")
Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
---
 .../include/0013input_descriptors_included_files_0 | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 tests/shell/testcases/include/0013input_descriptors_included_files_0

diff --git a/tests/shell/testcases/include/0013input_descriptors_included_files_0 b/tests/shell/testcases/include/0013input_descriptors_included_files_0
new file mode 100755
index 000000000000..26f43faf3145
--- /dev/null
+++ b/tests/shell/testcases/include/0013input_descriptors_included_files_0
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# This test the changes made in commit id "b14572f72aac".
+# When the commit was not applied, nft pointed to wrong files name.
+# As the commit only fixes the error messages and hence does not change the
+# return value so, we need to compare the "file name" in the error message
+# instead of return value of nft.
+
+
+tmpfile1=$(mktemp -p .)
+if [ ! -w $tmpfile1 ] ; then
+        echo "Failed to create tmp file" >&2
+        exit 0
+fi
+
+tmpfile2=$(mktemp -p .)
+if [ ! -w $tmpfile2 ] ; then
+        echo "Failed to create tmp file" >&2
+        exit 0
+fi
+
+tmpfile3=$(mktemp -p .)
+if [ ! -w $tmpfile3 ] ; then
+        echo "Failed to create tmp file" >&2
+        exit 0
+fi
+
+tmpfile4=$(mktemp -p .)
+if [ ! -w $tmpfile4 ]; then
+        echo "Failed to create tmp file" >&2
+        exit 0
+fi
+
+trap "rm -rf $tmpfile1 $tmpfile2 $tmpfile3 $tmpfile4" EXIT # cleanup if aborted
+
+RULESET1="include \"$tmpfile2\""
+RULESET2="include \"$tmpfile3\""
+RULESET3="add rule x y anything everything"			# wrong nft syntax
+
+
+echo "$RULESET1" > $tmpfile1
+echo "$RULESET2" >> $tmpfile1
+echo "$RULESET3" > $tmpfile2
+
+$NFT -f $tmpfile1 2> $tmpfile4
+
+var=$(awk -F: '$4==" Error"{print $1;exit;}' $tmpfile4)
+
+if [ $var == "$tmpfile3" ]; then
+	echo "E: Test failed" >&2
+	exit 1
+fi
-- 
1.9.1


  reply	other threads:[~2017-06-23 12:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 12:05 [PATCH 1/2] tests: shell: Add test for incomplete set add set command Shyam Saini
2017-06-23 12:05 ` Shyam Saini [this message]
2017-06-26 16:59   ` [PATCH 2/2] tests: shell: Test input descriptors for included files Pablo Neira Ayuso
2017-06-26 16:59 ` [PATCH 1/2] tests: shell: Add test for incomplete set add set command Pablo Neira Ayuso
2017-06-26 17:32   ` Shyam Saini
2017-06-26 17:37     ` Pablo Neira Ayuso
2017-06-26 17:54       ` Shyam Saini
2017-06-26 18:08         ` Pablo Neira Ayuso
2017-06-26 18:16           ` Shyam Saini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498219556-25179-2-git-send-email-mayhs11saini@gmail.com \
    --to=mayhs11saini@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).