Blame SOURCES/0015-tests-py-Support-testing-host-binaries.patch

911625
From 74575c409bad2940470f31946c97430043c3195e Mon Sep 17 00:00:00 2001
911625
From: Phil Sutter <psutter@redhat.com>
911625
Date: Wed, 12 Feb 2020 22:35:27 +0100
911625
Subject: [PATCH] tests: py: Support testing host binaries
911625
911625
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1754047
911625
Upstream Status: nftables commit 5f2746205e50c
911625
911625
commit 5f2746205e50c77295d0f84f8178ee3a1ce15407
911625
Author: Phil Sutter <phil@nwl.cc>
911625
Date:   Thu Feb 6 01:36:01 2020 +0100
911625
911625
    tests: py: Support testing host binaries
911625
911625
    Support -H/--host option to use host's libnftables.so.1. Alternatively
911625
    users may specify a custom library path via -l/--library option.
911625
911625
    Signed-off-by: Phil Sutter <phil@nwl.cc>
911625
---
911625
 tests/py/nft-test.py | 22 ++++++++++++++++++----
911625
 1 file changed, 18 insertions(+), 4 deletions(-)
911625
911625
diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
911625
index 6edca3c..01ee6c9 100755
911625
--- a/tests/py/nft-test.py
911625
+++ b/tests/py/nft-test.py
911625
@@ -1357,10 +1357,16 @@ def main():
911625
                         dest='force_all_family',
911625
                         help='keep testing all families on error')
911625
 
911625
+    parser.add_argument('-H', '--host', action='store_true',
911625
+                        help='run tests against installed libnftables.so.1')
911625
+
911625
     parser.add_argument('-j', '--enable-json', action='store_true',
911625
                         dest='enable_json',
911625
                         help='test JSON functionality as well')
911625
 
911625
+    parser.add_argument('-l', '--library', default=None,
911625
+                        help='path to libntables.so.1, overrides --host')
911625
+
911625
     parser.add_argument('-s', '--schema', action='store_true',
911625
                         dest='enable_schema',
911625
                         help='verify json input/output against schema')
911625
@@ -1388,9 +1394,17 @@ def main():
911625
     # Change working directory to repository root
911625
     os.chdir(TESTS_PATH + "/../..")
911625
 
911625
-    if not os.path.exists('src/.libs/libnftables.so'):
911625
-        print("The nftables library does not exist. "
911625
-              "You need to build the project.")
911625
+    check_lib_path = True
911625
+    if args.library is None:
911625
+        if args.host:
911625
+            args.library = 'libnftables.so.1'
911625
+            check_lib_path = False
911625
+        else:
911625
+            args.library = 'src/.libs/libnftables.so.1'
911625
+
911625
+    if check_lib_path and not os.path.exists(args.library):
911625
+        print("The nftables library at '%s' does not exist. "
911625
+              "You need to build the project." % args.library)
911625
         return
911625
 
911625
     if args.enable_schema and not args.enable_json:
911625
@@ -1398,7 +1412,7 @@ def main():
911625
         return
911625
 
911625
     global nftables
911625
-    nftables = Nftables(sofile = 'src/.libs/libnftables.so')
911625
+    nftables = Nftables(sofile = args.library)
911625
 
911625
     test_files = files_ok = run_total = 0
911625
     tests = passed = warnings = errors = 0
911625
-- 
8ff5ad
2.31.1
911625