]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
tests: xlate-test: Don't skip any input after the first empty line
authorPhil Sutter <phil@nwl.cc>
Mon, 6 Sep 2021 10:52:22 +0000 (12:52 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 13 Sep 2021 15:00:51 +0000 (17:00 +0200)
In conditionals, testing the empty string evaluates to false. This is
dumb but seems intentional, as readline() method returns an empty string
at EOF. This is distinct from reading an empty line as the latter
contains the newline character - unless it is stripped in between
readline() and conditional. The fixed commit introduced just that by
accident, effectively reducing any test file to the first contained
test:

| $ ./xlate-test.py
| [...]
| 81 test files, 84 tests, 84 tests passed, 0 tests failed, 0 errors

With this change in place, the summary looks much better:

| 81 test files, 368 tests, 368 tests passed, 0 tests failed, 0 errors

Fixes: 62828a6aff231 ("tests: xlate-test: support multiline expectation")
Signed-off-by: Phil Sutter <phil@nwl.cc>
xlate-test.py

index cba98b6e8e4910697e776310d0b15d6ca990a255..1fa5eca3e07643db0b5e96de3db4626c358f6bd2 100755 (executable)
@@ -48,9 +48,9 @@ def run_test(name, payload):
             if process.returncode == 0:
                 translation = output.decode("utf-8").rstrip(" \n")
                 expected = payload.readline().rstrip(" \n")
-                next_expected = payload.readline().rstrip(" \n")
+                next_expected = payload.readline()
                 if next_expected.startswith("nft"):
-                    expected += "\n" + next_expected
+                    expected += "\n" + next_expected.rstrip(" \n")
                     line = payload.readline()
                 else:
                     line = next_expected