tests: regression: homogenize indentation style
PATCH 1/2 tests: regression: homogenize indentation style
Python interpreter doesn't like mixed indentation. So in order to prevent future problems, this commit replace some tabs found in the script with space indentation.
--- tests/regression/nft-test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tests/regression/nft-test.py +5 -5
@@ -499,7 +499,7 @@ def rule_add(rule, table_list, chain_list, filename, lineno, payload_log = open("%s.payload" % filename_path) if rule[1].strip() == "ok": - try: + try: payload_expected.index(rule[0]) except (ValueError): payload_expected = payload_find_expected(payload_log, rule[0])
@@ -553,7 +553,7 @@ def rule_add(rule, table_list, chain_list, filename, lineno, if line == "": break gotf.write(line) - gotf.close() + gotf.close() print_warning("Wrote payload for rule %s" % rule[0], gotf.name, 1) # Check output of nft
@@ -722,8 +722,8 @@ def payload_find_expected(payload_log, rule): while True: line = payload_log.readline() - if not line: - break + if not line: + break if line[0] == "#": # rule start rule_line = line.strip()[2:]
@@ -910,7 +910,7 @@ def main(): if not os.path.isdir("tests/regression/"): print "You have to run nft-test.py from the repository root directory, eg.\n\n" + \ - " nftables# python tests/regression/nft-test.py\n" + " nftables# python tests/regression/nft-test.py\n" return test_files = files_ok = run_total = 0
Signature · 1 line
2.6.2
PATCH 2/2 tests: regression: allow to run tests from anywhere
Since 357d8cf "tests: use the src/nft binary instead of $PATH one", the tests script needs to be executed from nftables repository root. Now the script can be run from any location and also checks the binary existence.
To run a single test file, the path must be relative from the directory where you launch the script.
--- tests/regression/nft-test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tests/regression/nft-test.py +6 -4
@@ -20,7 +20,7 @@ import argparse import signal TERMINAL_PATH = os.getcwd() -NFT_BIN = TERMINAL_PATH + "/src/nft" +NFT_BIN = "src/nft" TESTS_PATH = os.path.dirname(os.path.abspath(__file__)) TESTS_DIRECTORY = ["any", "arp", "bridge", "inet", "ip", "ip6"] LOGFILE = "/tmp/nftables-test.log"
@@ -908,9 +908,11 @@ def main(): print "You need to be root to run this, sorry" return - if not os.path.isdir("tests/regression/"): - print "You have to run nft-test.py from the repository root directory, eg.\n\n" + \ - " nftables# python tests/regression/nft-test.py\n" + # Change working directory to repository root + os.chdir(TESTS_PATH + "/../..") + + if not os.path.isfile(NFT_BIN): + print "The nft binary does not exist. You need to build the project." return test_files = files_ok = run_total = 0
Signature · 1 line
2.6.2
Florian Westphal
maintainerRe: [PATCH nft 2/2] tests: regression: allow to run tests from anywhere
Quoted 7 lines · Pablo M. Bermudo Garay
Since 357d8cf "tests: use the src/nft binary instead of $PATH one", the tests script needs to be executed from nftables repository root. Now the script can be run from any location and also checks the binary existence.
To run a single test file, the path must be relative from the directory where you launch the script.
Looks good, I pushed both patches to nft master.
Thanks!