|author||Phil Sutter <firstname.lastname@example.org>||2018-10-11 17:49:01 +0200|
|committer||Pablo Neira Ayuso <email@example.com>||2018-10-15 13:37:51 +0200|
tests: monitor: Test JSON output as well
Enhance monitor test suite to test check JSON output as well. Note that for now there is no support for --echo output testing with JSON. Signed-off-by: Phil Sutter <firstname.lastname@example.org> Signed-off-by: Pablo Neira Ayuso <email@example.com>
Diffstat (limited to 'tests/monitor/README')
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/monitor/README b/tests/monitor/README
index 9c5e37f5..39096a7f 100644
@@ -15,13 +15,14 @@ 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.
+Input lines are prefixed by 'I'. Multiple 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.
+There are two types of output lines: Those for standard syntax, prefixed by 'O'
+and those for JSON output, prefixed by 'J'. For standard syntax output lines,
+there is a shortcut: If a line consists of 'O -' only, the test script uses all
+previous input lines as expected output directly. Of course this is not
+available for JSON output lines.
Empty lines and those starting with '#' are ignored.
@@ -29,8 +30,8 @@ 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
+assumes that sections of 'I' lines alternate with sections of 'O'/'J' 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
@@ -46,3 +47,13 @@ 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.
+By default, only standard syntax is being tested for, i.e. 'J'-prefixed lines
+are simply ignored. If JSON testing was requested (by passing '-j' flag to the
+test script), 'O'-prefixed lines in turn are ignored.
+There is one caveat with regards to JSON output: Since it always contains handle
+properties (if the given object possesses such) which is supposed to be
+arbitrary, there is a filter script which normalizes all handle values in
+monitor output to zero before comparison. Therefore expected output must have
+all handle properties present but with a value of zero.