[Git][NTPsec/ntpsec][20k-Nov22-install-test-fix] 4 commits: ntp.ntpc, bin_test: (ab)use CTYPESDIR when testing install.

James Browning gitlab at mg.gitlab.com
Thu Nov 26 23:11:32 UTC 2020



James Browning pushed to branch 20k-Nov22-install-test-fix at NTPsec / ntpsec


Commits:
2e3d5785 by James Browning at 2020-11-26T14:51:03-08:00
ntp.ntpc, bin_test: (ab)use CTYPESDIR when testing install.

- - - - -
9d6218c4 by James Browning at 2020-11-26T14:51:32-08:00
bin_test: reg is now expected, no run under python when installed.


- - - - -
f94d4b49 by James Browning at 2020-11-26T14:51:41-08:00
bin_test: change from waflibs.Utils.subprocess to subprocess


- - - - -
81d8826b by James Browning at 2020-11-26T15:09:34-08:00
CI: universal install check


- - - - -


3 changed files:

- .gitlab-ci.yml
- pylib/ntpc.py
- wafhelpers/bin_test.py


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -41,6 +41,8 @@ alpine-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/alpine
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 alpine-refclocks:
   <<: *job_definition
@@ -53,6 +55,8 @@ alpine-edge-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/alpine-edge
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 alpine-edge-refclocks:
   <<: *job_definition_allow_failure
@@ -106,6 +110,8 @@ debian-oldstable-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-oldstable
   script:
     - python3 ./waf configure --disable-doc --disable-manpage --disable-nts build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-oldstable-refclocks:
   <<: *job_definition
@@ -118,6 +124,8 @@ debian-stable-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-stable
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-stable-refclocks:
   <<: *job_definition
@@ -130,6 +138,8 @@ debian-testing-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-testing
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-testing-refclocks:
   <<: *job_definition
@@ -142,6 +152,8 @@ debian-unstable-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-unstable
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-unstable-refclocks:
   <<: *job_definition_allow_failure
@@ -154,6 +166,8 @@ ubuntu-latest-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-latest
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 ubuntu-latest-refclocks:
   <<: *job_definition
@@ -166,6 +180,8 @@ ubuntu-rolling-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-rolling
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 ubuntu-rolling-refclocks:
   <<: *job_definition
@@ -178,6 +194,8 @@ ubuntu-devel-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-devel
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 ubuntu-devel-refclocks:
   <<: *job_definition_allow_failure
@@ -189,6 +207,10 @@ freebsd-11-basic:
   <<: *job_definition
   script:
     - python ./waf configure --disable-doc --disable-manpage --disable-nts build
+    - DESTDIR=build/prison python ./waf install
+    - DESTDIR=./prison python ./waf install
+    - DESTDIR=../prison python ./waf install
+    - rm -rvf build/prison ./prison ../prison
   tags:
     - freebsd-11
   rules:
@@ -207,6 +229,10 @@ freebsd-12-basic:
   <<: *job_definition
   script:
     - python ./waf configure --disable-doc --disable-manpage build
+    - DESTDIR=build/prison python ./waf install
+    - DESTDIR=./prison python ./waf install
+    - DESTDIR=../prison python ./waf install
+    - rm -rvf build/prison ./prison ../prison
   tags:
     - freebsd-12
   rules:
@@ -226,6 +252,8 @@ centos-latest-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/centos-latest
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 centos-latest-refclocks:
   <<: *job_definition
@@ -238,6 +266,8 @@ fedora-latest-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/fedora-latest
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 fedora-latest-refclocks:
   <<: *job_definition
@@ -250,6 +280,8 @@ fedora-rawhide-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/fedora-rawhide
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 fedora-rawhide-refclocks:
   <<: *job_definition_allow_failure
@@ -288,12 +320,16 @@ clang-refclocks:
   image: $CI_REGISTRY/ntpsec/ntpsec/clang
   script:
     - python3 ./waf configure --disable-doc --disable-manpage --check-c-compiler=clang --refclock=all build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 openSUSE-leap-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/opensuse-leap
   script:
     - python3 ./waf configure --disable-doc --disable-manpage --disable-nts build 
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 openSUSE-leap-refclocks:
   <<: *job_definition
@@ -306,6 +342,8 @@ openSUSE-tumbleweed-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/opensuse-tumbleweed
   script:
     - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 openSUSE-tumbleweed-refclocks:
   <<: *job_definition_allow_failure
@@ -351,6 +389,12 @@ gentoo-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/gentoo
   script:
     - python ./waf configure --disable-doc --disable-manpage build
+    - DESTDIR=build/prison python ./waf install
+    - DESTDIR=./prison python ./waf install
+    - DESTDIR=../prison python ./waf install
+    - python ./waf install
+    - python ./waf uninstall
+    - rm -rvf build/prison ./prison ../prison
 
 gentoo-refclocks:
   <<: *job_definition
@@ -363,6 +407,12 @@ gentoo-hardened-basic:
   image: $CI_REGISTRY/ntpsec/ntpsec/gentoo-hardened
   script:
     - python ./waf configure --disable-doc --disable-manpage build
+    - DESTDIR=build/prison python ./waf install
+    - DESTDIR=./prison python ./waf install
+    - DESTDIR=../prison python ./waf install
+    - python ./waf install
+    - python ./waf uninstall
+    - rm -rvf build/prison ./prison ../prison
 
 gentoo-hardened-refclocks:
   <<: *job_definition
@@ -397,6 +447,12 @@ macos-refclocks:
   <<: *job_definition
   script:
     - PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig python ./waf configure --disable-doc --disable-manpage --refclock=all build
+    - DESTDIR=build/prison python ./waf install
+    - DESTDIR=./prison python ./waf install
+    - DESTDIR=../prison python ./waf install
+    - python ./waf install
+    - python ./waf uninstall
+    - rm -rvf build/prison ./prison ../prison
   tags:
     - macos
   rules:


=====================================
pylib/ntpc.py
=====================================
@@ -11,29 +11,38 @@ import sys
 import ntp.poly
 
 LIB = 'ntpc'
+CTD = 'CTYPESDIR'
 
 
-def _fmt():
+def _libname():
     """Produce library naming scheme."""
-    if sys.platform.startswith('darwin'):
-        return 'lib%s.dylib'
-    if sys.platform.startswith('win32'):
-        return '%s.dll'
-    if sys.platform.startswith('cygwin'):
-        return 'lib%s.dll'
-    return 'lib%s.so'
+    _format = 'lib%s.so'
+    _templates = {
+        'darwin': 'lib%s.dylib',
+        'win32': '%s.dll',
+        'cygwin': 'lib%s.dll'
+        }
+    for key in _templates:
+        if sys.platform.startswith(key):
+            _format = _templates[key]
+            break
+    return _format % LIB
 
 
 def _importado():
     """Load the ntpc library or throw an OSError trying."""
     ntpc_paths = []         # places to look
 
-    j = __file__.split(os.sep)[:-1]
-    ntpc_paths.append(os.sep.join(j + [_fmt() % LIB]))
+    if CTD in os.environ:  # and not sys.platform.startswith('linux'):
+        ntpc_paths.append(os.environ[CTD] +
+                          os.sep + _libname())
+    else:
+        j = __file__.split(os.sep)[:-1]
+        ntpc_paths.append(os.sep.join(j + [_libname()]))
 
-    ntpc_path = ctypes.util.find_library(LIB)
-    if ntpc_path:
-        ntpc_paths.append(ntpc_path)
+        ntpc_path = ctypes.util.find_library(LIB)
+        if ntpc_path:
+            ntpc_paths.append(ntpc_path)
 
     return _dlo(ntpc_paths)
 


=====================================
wafhelpers/bin_test.py
=====================================
@@ -5,12 +5,12 @@ import os.path
 import sys
 import waflib.Context
 import waflib.Logs
-import waflib.Utils
+import subprocess
 sys.path.insert(0, "%s/main/tests/pylib" % waflib.Context.out_dir)
 import ntp.util
 
 version = ntp.util.stdversion()
-Popen = waflib.Utils.subprocess.Popen
+Popen = subprocess.Popen
 
 cmd_smap = {
     ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % version,
@@ -54,8 +54,8 @@ def bin_test_summary(_):
         waflib.Logs.pprint(i[0], i[1])
 
 
-def run(cmd, reg, pythonic, apath=None, environ=None):
-    """Run an individual non-python test."""
+def run(cmd, expected, pythonic, apath=None, environ=None):
+    """Run an individual test."""
     check = False
     odir = apath if apath else waflib.Context.out_dir
 
@@ -73,20 +73,20 @@ def run(cmd, reg, pythonic, apath=None, environ=None):
 
     p = Popen(cmd, universal_newlines=True,
               env=environ, cwd=odir,
-              stdin=waflib.Utils.subprocess.PIPE,
-              stdout=waflib.Utils.subprocess.PIPE,
-              stderr=waflib.Utils.subprocess.PIPE)
+              stdin=subprocess.PIPE,
+              stdout=subprocess.PIPE,
+              stderr=subprocess.PIPE)
 
     stdout, stderr = p.communicate()
 
-    if reg in (stdout, stderr):
+    if expected in (stdout, stderr):
         check = True
 
     if check:
         addLog("GREEN", prefix + "  OK")
         return True
     addLog("RED", prefix + "  FAILED")
-    addLog("PINK", "Expected: " + reg)
+    addLog("PINK", "Expected: " + expected)
     if stdout:
         addLog("PINK", "Got (stdout): " + stdout)
     if stderr:
@@ -99,16 +99,20 @@ def cmd_bin_test(ctx):
     fails = 0
     skips = 0
     env = {}
+    python_wrap = True
 
     destdir = os.path.abspath(os.environ.get('DESTDIR', '/'))
     path = spath = None
 
     if ctx.cmd == 'install':
-        pypath = destdir + ctx.env.PYTHONARCHDIR  # + os.sep + 'ntp'
-        env = {'PYTHONPATH': pypath} if destdir != '/' else {}
+        pypath = destdir + ctx.env.PYTHONARCHDIR
+        libpath = destdir + ctx.env.LIBDIR
+        env = {'PYTHONPATH': pypath,
+               'CTYPESDIR': libpath }
         path = destdir + os.sep if destdir != '/' else '/'
         spath = path + ctx.env.SBINDIR[1:] + os.sep
         path = path + ctx.env.BINDIR[1:] + os.sep
+        python_wrap = False
         addLog('BLUE', 'Following relative to: %s' % spath)
 
     if ctx.env['PYTHON_ARGPARSE']:
@@ -131,7 +135,7 @@ def cmd_bin_test(ctx):
         skips = skips + 1 if status is None else skips
 
     for cmd in sorted(cmd_map_python):
-        status = run(cmd, cmd_map_python[cmd], True, path, env)
+        status = run(cmd, cmd_map_python[cmd], python_wrap, path, env)
         fails = fails + 1 if status is False else fails
         skips = skips + 1 if status is None else skips
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/e44fc91e765f6d20a157a9b0a7b55139b057adab...81d8826b00a5956bb079426976dc83b0b23e3211

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/e44fc91e765f6d20a157a9b0a7b55139b057adab...81d8826b00a5956bb079426976dc83b0b23e3211
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20201126/a86b5251/attachment-0001.htm>


More information about the vc mailing list