]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: py: Fix --keep test runner option master
authorPhil Sutter <phil@nwl.cc>
Wed, 15 Jul 2026 22:57:56 +0000 (00:57 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 15 Jul 2026 23:02:40 +0000 (01:02 +0200)
The boolean flag expected a value, although not used. Set
'action=store_true' to really make it a flag.

While at it, simplify the code by eliminating the inverse-value
auto_delete helper variable.

Fixes: f2b5d6fc26b9a ("tests: py: don't use a fixed filename")
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/py/nft-test.py

index 56d4e0fc9d4e088411de092f3579d9d664c79e78..4a00ce0cd725a1cda5b534c301c4d7bf8351def5 100755 (executable)
@@ -36,7 +36,6 @@ chain_list = []
 all_set = dict()
 obj_list = []
 signal_received = 0
-auto_delete = True
 
 
 class Colors:
@@ -1523,7 +1522,7 @@ def main():
     parser.add_argument('-l', '--library', default=None,
                         help='path to libntables.so.1, overrides --host')
 
-    parser.add_argument('-k', '--keep', default=False,
+    parser.add_argument('-k', '--keep', action='store_true',
                         help='keep log file around after tests')
 
     parser.add_argument('-N', '--no-netns', action='store_true',
@@ -1577,11 +1576,6 @@ def main():
               "You need to build the project." % args.library)
         return 99
 
-    global auto_delete
-
-    if args.keep:
-        auto_delete = False
-
     if args.enable_schema and not args.enable_json:
         print_error("Option --schema requires option --json")
         return 99
@@ -1593,8 +1587,8 @@ def main():
     tests = passed = warnings = errors = 0
     global log_file
     try:
-        log_file = tempfile.NamedTemporaryFile(prefix="nftables-test-py-", suffix=".log", mode='w', delete=auto_delete)
-        if auto_delete:
+        log_file = tempfile.NamedTemporaryFile(prefix="nftables-test-py-", suffix=".log", mode='w', delete = not args.keep)
+        if not args.keep:
             print_info("Log file %s will not be retained.  Pass -k to keep it." % log_file.name)
         else:
             print_info("Log will be available at %s" % log_file.name)