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

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