]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: regression: allow to run tests from anywhere
authorPablo M. Bermudo Garay <pablombg@gmail.com>
Thu, 19 Nov 2015 18:51:49 +0000 (19:51 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 19 Nov 2015 21:52:29 +0000 (22:52 +0100)
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.

Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/regression/nft-test.py

index ed9653d230d6175dfdd9e337c6f43a30097ca636..0b0be5dd0ac099ed48dde0724c3df996b9c461f3 100755 (executable)
@@ -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