summaryrefslogtreecommitdiffstats
path: root/xlate-test.py
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-02-19 20:39:49 +0100
committerFlorian Westphal <fw@strlen.de>2019-02-22 16:52:46 +0100
commit59372f0c4f2e93b7633ab418536874343e023db7 (patch)
tree59ae4bbd6e0e3e66babca709d7b141f06d066353 /xlate-test.py
parentd68672a641439b72bccfcb39d50f26fe3f915c19 (diff)
xlate-test: Support testing host binaries
Introduce --host parameter to run the testsuite against host's binaries instead of built ones. Apparently, extending PATH variable in main() was redundant with explicit full path call in run_test() so drop the former. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'xlate-test.py')
-rwxr-xr-xxlate-test.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/xlate-test.py b/xlate-test.py
index f365a700..4c014f9b 100755
--- a/xlate-test.py
+++ b/xlate-test.py
@@ -8,6 +8,7 @@ import argparse
from subprocess import Popen, PIPE
keywords = ("iptables-translate", "ip6tables-translate", "ebtables-translate")
+xtables_nft_multi = 'xtables-nft-multi'
if sys.stdout.isatty():
colors = {"magenta": "\033[95m", "green": "\033[92m", "yellow": "\033[93m",
@@ -33,6 +34,7 @@ def green(string):
def run_test(name, payload):
+ global xtables_nft_multi
test_passed = True
tests = passed = failed = errors = 0
result = []
@@ -40,7 +42,7 @@ def run_test(name, payload):
for line in payload:
if line.startswith(keywords):
tests += 1
- process = Popen([ os.path.abspath(os.path.curdir) + "/iptables/xtables-nft-multi" ] + shlex.split(line), stdout=PIPE, stderr=PIPE)
+ process = Popen([ xtables_nft_multi ] + shlex.split(line), stdout=PIPE, stderr=PIPE)
(output, error) = process.communicate()
if process.returncode == 0:
translation = output.decode("utf-8").rstrip(" \n")
@@ -86,8 +88,12 @@ def load_test_files():
print("%d test files, %d tests, %d tests passed, %d tests failed, %d errors" % (test_files, total_tests, total_passed, total_failed, total_error))
def main():
- os.putenv("XTABLES_LIBDIR", os.path.abspath("extensions"))
- os.putenv("PATH", "%s/iptables:%s" % (os.path.abspath(os.path.curdir), os.getenv("PATH")))
+ global xtables_nft_multi
+ if not args.host:
+ os.putenv("XTABLES_LIBDIR", os.path.abspath("extensions"))
+ xtables_nft_multi = os.path.abspath(os.path.curdir) \
+ + '/iptables/' + xtables_nft_multi
+
if args.test:
if not args.test.endswith(".txlate"):
args.test += ".txlate"
@@ -101,6 +107,8 @@ def main():
parser = argparse.ArgumentParser()
+parser.add_argument('-H', '--host', action='store_true',
+ help='Run tests against installed binaries')
parser.add_argument("test", nargs="?", help="run only the specified test file")
args = parser.parse_args()
main()