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

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