netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH 6/6] tests/monitor: Add a small README
Date: Tue, 25 Jul 2017 16:56:29 +0200	[thread overview]
Message-ID: <20170725145629.20974-7-phil@nwl.cc> (raw)
In-Reply-To: <20170725145629.20974-1-phil@nwl.cc>

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/monitor/README | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 tests/monitor/README

diff --git a/tests/monitor/README b/tests/monitor/README
new file mode 100644
index 0000000000000..9c5e37f5c75c9
--- /dev/null
+++ b/tests/monitor/README
@@ -0,0 +1,48 @@
+Simple NFT MONITOR Testsuite
+============================
+
+The purpose of this suite of tests is to assert correct 'nft monitor' output for
+known input. The suite consists of the single shell script 'run-tests.sh' which
+performs the tests and a number of test definition files in 'testcases/'. The
+latter have to be suffixed '.t' in order to be recognized as such.
+
+Test Case Syntax
+----------------
+
+Each testcase defines a number of commands to pass on to 'nft' binary and an
+associated 'nft monitor' output definition. Prerequisites for each command have
+to be established manually, i.e. in order to test monitor output when adding a
+chain, the table containing it has to be created first. In between each
+testcase, rule set is flushed completely.
+
+Input and output lines are prefixed by 'I' and 'O', respectively. The prefix has
+to be separated from the rest of the line by whitespace. Consecutive input lines
+are passed to 'nft' together, hence lead to a single transaction.
+
+Since in most cases output should be equal to input, there is a shortcut: If a
+line consists of 'O -' only, the test script uses all previous input lines as
+expected output directly.
+
+Empty lines and those starting with '#' are ignored.
+
+Test Script Semantics
+---------------------
+
+The script iterates over all test case files, reading them line by line. It
+assumes that sections of 'I' lines alternate with sections of 'O' lines. After
+stripping the prefix, each line is appended to a temporary file. There are
+separate files for input and output lines.
+
+If a set of input and output lines is complete (i.e. upon encountering either a
+new input line or end of file), a testrun is performed: 'nft monitor' is run in
+background, redirecting the output into a third file. The input file is passed
+to 'nft -f'. Finally 'nft monitor' is killed and it's output compared to the
+output file created earlier. If the files differ, a unified diff is printed and
+test execution aborts.
+
+After each testrun, input and output files are cleared.
+
+Note: Running 'nft monitor' in background is prone to race conditions. Hence
+an artificial delay is introduced before calling 'nft -f' to allow for 'nft
+monitor' to complete initialization and another one before comparing the output
+to allow for 'nft monitor' to process the netlink events.
-- 
2.13.1


  parent reply	other threads:[~2017-07-25 14:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 14:56 [nft PATCH 0/6] monitor: Some fixes and improvements Phil Sutter
2017-07-25 14:56 ` [nft PATCH 1/6] tests/monitor: Ignore newgen messages in output Phil Sutter
2017-07-25 15:57   ` Pablo Neira Ayuso
2017-07-25 14:56 ` [nft PATCH 2/6] monitor: Fix printing of set declarations Phil Sutter
2017-07-25 15:57   ` Pablo Neira Ayuso
2017-07-25 17:09     ` Phil Sutter
2017-07-26 11:18       ` Pablo Neira Ayuso
2017-07-26 13:19         ` Phil Sutter
2017-07-25 14:56 ` [nft PATCH 3/6] tests/monitor: Simplify testcases Phil Sutter
2017-07-25 16:02   ` Pablo Neira Ayuso
2017-07-25 16:12     ` Pablo Neira Ayuso
2017-07-25 14:56 ` [nft PATCH 4/6] monitor: Print space after semicolon Phil Sutter
2017-07-25 16:03   ` Pablo Neira Ayuso
2017-07-25 14:56 ` [nft PATCH 5/6] tests/monitor: Clear ruleset after testing Phil Sutter
2017-07-25 16:03   ` Pablo Neira Ayuso
2017-07-25 14:56 ` Phil Sutter [this message]
2017-07-25 16:18   ` [nft PATCH 6/6] tests/monitor: Add a small README Pablo Neira Ayuso

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=20170725145629.20974-7-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).