[Git][NTPsec/ntpsec][master] 5 commits: bin_test: revert 'from install directory recording skips', keep style.

Gary E. Miller gitlab at mg.gitlab.com
Tue Dec 15 03:13:33 UTC 2020



Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
3311f17a by James Browning at 2020-12-13T18:30:02-08:00
bin_test: revert 'from install directory recording skips', keep style.

- - - - -
8e33f87c by James Browning at 2020-12-13T18:30:37-08:00
wscript: Use last git commit time for build_epoch if available.

- - - - -
7e697347 by James Browning at 2020-12-13T18:30:37-08:00
wcript: Use git describe to form extended version ...

now supports dirty suffix and commits since. Output can look like
1.2.0+21-g13613bfcb-dirty 2020-12-13T18:47:47Z

- - - - -
02f91d14 by James Browning at 2020-12-13T18:30:37-08:00
ntp.ntpc: Print warning if wrong libntpc build version.

- - - - -
8b8f0a2f by James Browning at 2020-12-13T18:30:37-08:00
CI: Universal install checks. -r2


- - - - -


5 changed files:

- .gitlab-ci.yml
- libntp/ntp_c.c
- pylib/ntpc.py
- wafhelpers/bin_test.py
- wscript


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -40,7 +40,9 @@ alpine-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/alpine
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 alpine-refclocks:
   <<: *job_definition
@@ -52,7 +54,9 @@ alpine-edge-basic:
   <<: *job_definition_allow_failure
   image: $CI_REGISTRY/ntpsec/ntpsec/alpine-edge
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 alpine-edge-refclocks:
   <<: *job_definition_allow_failure
@@ -105,7 +109,9 @@ debian-oldstable-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-oldstable
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage --disable-nts build
+    - python3 ./waf configure --disable-doc --disable-manpage --disable-nts build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-oldstable-refclocks:
   <<: *job_definition
@@ -117,7 +123,9 @@ debian-stable-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-stable
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-stable-refclocks:
   <<: *job_definition
@@ -129,7 +137,9 @@ debian-testing-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-testing
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-testing-refclocks:
   <<: *job_definition
@@ -141,7 +151,9 @@ debian-unstable-basic:
   <<: *job_definition_allow_failure
   image: $CI_REGISTRY/ntpsec/ntpsec/debian-unstable
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 debian-unstable-refclocks:
   <<: *job_definition_allow_failure
@@ -153,7 +165,9 @@ ubuntu-latest-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-latest
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 ubuntu-latest-refclocks:
   <<: *job_definition
@@ -165,7 +179,9 @@ ubuntu-rolling-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-rolling
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 ubuntu-rolling-refclocks:
   <<: *job_definition
@@ -177,7 +193,9 @@ ubuntu-devel-basic:
   <<: *job_definition_allow_failure
   image: $CI_REGISTRY/ntpsec/ntpsec/ubuntu-devel
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - 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:
@@ -225,7 +251,9 @@ centos-latest-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/centos-latest
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 centos-latest-refclocks:
   <<: *job_definition
@@ -237,7 +265,9 @@ fedora-latest-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/fedora-latest
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 fedora-latest-refclocks:
   <<: *job_definition
@@ -249,7 +279,9 @@ fedora-rawhide-basic:
   <<: *job_definition_allow_failure
   image: $CI_REGISTRY/ntpsec/ntpsec/fedora-rawhide
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 fedora-rawhide-refclocks:
   <<: *job_definition_allow_failure
@@ -281,7 +313,9 @@ clang-basic:
   <<: *job_definition
   image: $CI_REGISTRY/ntpsec/ntpsec/clang
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage --check-c-compiler=clang build
+    - python3 ./waf configure --disable-doc --disable-manpage --check-c-compiler=clang build --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 clang-refclocks:
   <<: *job_definition
@@ -293,7 +327,9 @@ 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 configure --disable-doc --disable-manpage --disable-nts build  --pyshebang "/usr/bin/env python3"
+    - python3 ./waf install
+    - python3 ./waf uninstall
 
 openSUSE-leap-refclocks:
   <<: *job_definition
@@ -305,7 +341,9 @@ openSUSE-tumbleweed-basic:
   <<: *job_definition_allow_failure
   image: $CI_REGISTRY/ntpsec/ntpsec/opensuse-tumbleweed
   script:
-    - python3 ./waf configure --disable-doc --disable-manpage build
+    - python3 ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - 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
@@ -387,7 +437,13 @@ coverity-scan:
 macos-basic:
   <<: *job_definition
   script:
-    - PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig python ./waf configure --disable-doc --disable-manpage build
+    - PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig python ./waf configure --disable-doc --disable-manpage build --pyshebang "/usr/bin/env python3"
+    - 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:


=====================================
libntp/ntp_c.c
=====================================
@@ -34,6 +34,7 @@ bool ntpc_step_systime(double);
 
 /* Don't include anything from OpenSSL */
 
+const char *version = NTPSEC_VERSION_EXTENDED;
 const char *progname = "libntpc";
 int   SYS_TYPE = TYPE_SYS;
 int  PEER_TYPE = TYPE_PEER;


=====================================
pylib/ntpc.py
=====================================
@@ -43,6 +43,10 @@ def _dlo(paths):
     for ntpc_path in paths:
         try:
             lib = ctypes.CDLL(ntpc_path, use_errno=True)
+            wrap_version = "@NTPSEC_VERSION_EXTENDED@"
+            clib_version = ctypes.c_char_p.in_dll(lib, 'version').value
+            if clib_version != wrap_version:
+                sys.stderr.write("ntp.ntpc wrong version %s !== %s" % (clib_version, wrap_version))
             return lib
         except OSError:
             pass


=====================================
wafhelpers/bin_test.py
=====================================
@@ -12,12 +12,10 @@ import ntp.util
 version = ntp.util.stdversion()
 Popen = waflib.Utils.subprocess.Popen
 
-cmd_smap = {
-    ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % version,
-}
 cmd_map = {
     ("main/ntpclients/ntpleapfetch", "--version"): "ntpleapfetch %s\n"
                                                    % version,
+    ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % version,
     ("main/ntpfrob/ntpfrob", "-V"): "ntpfrob %s\n" % version,
     ("main/ntptime/ntptime", "-V"): "ntptime %s\n" % version
 }
@@ -48,45 +46,37 @@ def addLog(color, text):
     test_logs.append((color, text))
 
 
-def bin_test_summary(_):
+def bin_test_summary(ctx):
     """Print out the log."""
     for i in test_logs:
         waflib.Logs.pprint(i[0], i[1])
 
 
-def run(cmd, reg, pythonic, apath=None, environ=None):
+def run(cmd, expected, pythonic):
     """Run an individual non-python test."""
-    check = False
-    odir = apath if apath else waflib.Context.out_dir
-
-    environ = {} if environ is None else environ
-    if apath:
-        cmd = [os.sep.join(['.'] + cmd[0].split(os.sep)[-1:])] + list(cmd[1:])
     prefix = "running: " + " ".join(cmd)
-    if not os.path.exists("%s/%s" % (odir, cmd[0])):
-        addLog("YELLOW", '"%s" SKIPPING (does not exist)' % "%s/%s" % (odir, cmd[0]))
-        return None
-    if not apath:
-        if pythonic:
-            cmd = [sys.executable] + list(cmd)
-            prefix = "running: " + " ".join(cmd)
-
-    p = Popen(cmd, universal_newlines=True,
-              env=environ, cwd=odir,
+
+    if not os.path.exists("%s/%s" % (waflib.Context.out_dir, cmd[0])):
+        addLog("YELLOW", prefix + " SKIPPING (does not exist)")
+        return False
+
+    if pythonic:
+        cmd = [sys.executable] + list(cmd)
+    p = Popen(cmd, env={'PYTHONPATH': '%s/main/tests/pylib' %
+                        waflib.Context.out_dir},
+              universal_newlines=True,
               stdin=waflib.Utils.subprocess.PIPE,
               stdout=waflib.Utils.subprocess.PIPE,
-              stderr=waflib.Utils.subprocess.PIPE)
+              stderr=waflib.Utils.subprocess.PIPE,
+              cwd=waflib.Context.out_dir)
 
     stdout, stderr = p.communicate()
 
-    if reg in (stdout, stderr):
-        check = True
-
-    if check:
+    if expected in (stdout, stderr):
         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:
@@ -97,19 +87,6 @@ def run(cmd, reg, pythonic, apath=None, environ=None):
 def cmd_bin_test(ctx):
     """Run a suite of binary tests."""
     fails = 0
-    skips = 0
-    env = {}
-
-    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 {}
-        path = destdir + os.sep if destdir != '/' else '/'
-        spath = path + ctx.env.SBINDIR[1:] + os.sep
-        path = path + ctx.env.BINDIR[1:] + os.sep
-        addLog('BLUE', 'Following relative to: %s' % spath)
 
     if ctx.env['PYTHON_ARGPARSE']:
         cmd_map_python.update(cmd_map_python_argparse)
@@ -117,34 +94,17 @@ def cmd_bin_test(ctx):
     if ctx.env['PYTHON_CURSES']:
         cmd_map_python.update(cmd_map_python_curses)
 
-    for cmd in sorted(cmd_smap):
-        status = run(cmd, cmd_smap[cmd], False, spath, env)
-        fails = fails + 1 if status is False else fails
-        skips = skips + 1 if status is None else skips
-
-    if ctx.cmd == 'install':
-        addLog('BLUE', 'Following relative to: %s' % path)
-
     for cmd in sorted(cmd_map):
-        status = run(cmd, cmd_map[cmd], False, path, env)
-        fails = fails + 1 if status is False else fails
-        skips = skips + 1 if status is None else skips
+        if not run(cmd, cmd_map[cmd], False):
+            fails += 1
 
     for cmd in sorted(cmd_map_python):
-        status = run(cmd, cmd_map_python[cmd], True, path, env)
-        fails = fails + 1 if status is False else fails
-        skips = skips + 1 if status is None else skips
+        if not run(cmd, cmd_map_python[cmd], True):
+            fails += 1
 
-    if skips > 0 or fails > 0:
+    if 1 == fails:
         bin_test_summary(ctx)
-    if skips == 1:
-        waflib.Logs.warn("1 binary test skipped!")
-    elif skips > 1:
-        waflib.Logs.warn("%d binary tests skipped!" % skips)
-
-    if fails >= 7:
-        pass
-    if fails == 1:
         ctx.fatal("1 binary test failed!")
-    elif fails > 1:
+    elif 1 < fails:
+        bin_test_summary(ctx)
         ctx.fatal("%d binary tests failed!" % fails)


=====================================
wscript
=====================================
@@ -169,6 +169,10 @@ def configure(ctx):
         ctx.start_msg("systemd unit directory:")
         ctx.end_msg(ctx.env.SYSTEMD_systemdsystemunitdir)
 
+    ctx.env.BIN_GIT = False
+    if os.path.exists(".git"):
+        ctx.find_program("git", var="BIN_GIT", mandatory=False)
+
     source_date_epoch = os.getenv('SOURCE_DATE_EPOCH', None)
     if ctx.options.build_epoch is not None:
         build_epoch = ctx.options.build_epoch
@@ -179,22 +183,26 @@ def configure(ctx):
         build_epoch = int(source_date_epoch)
         ctx.define("BUILD_EPOCH", build_epoch,
                    comment="Using SOURCE_DATE_EPOCH")
+    elif ctx.env.BIN_GIT:
+        cmd = ctx.env.BIN_GIT + shlex.split("log -1 --pretty=%ct")
+        build_epoch = int(ctx.cmd_and_log(cmd).strip())
+        ctx.define("BUILD_EPOCH", build_epoch, comment="last git commit")
     else:
         build_epoch = int(time.time())
         ctx.define("BUILD_EPOCH", build_epoch, comment="Using default")
 
     build_epoch_formatted = datetime.utcfromtimestamp(build_epoch).strftime(
         "%Y-%m-%dT%H:%M:%SZ")
-    if ((os.path.exists(".git") and
-            ctx.find_program("git", var="BIN_GIT", mandatory=False))):
-        cmd = ctx.env.BIN_GIT + shlex.split("log -1 --format=%h")
+    if ctx.env.BIN_GIT:
+        cmd = ctx.env.BIN_GIT + shlex.split("describe --dirty")
         git_short_hash = ctx.cmd_and_log(cmd).strip()
+        git_short_hash = '-'.join(git_short_hash.split('-')[1:])
 
         ctx.env.NTPSEC_VERSION = "%s+" % ntpsec_release
-        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+ %s (git rev %s)" %
+        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s %s" %
                                            (ntpsec_release,
-                                            build_epoch_formatted,
-                                            git_short_hash))
+                                            git_short_hash,
+                                            build_epoch_formatted))
     else:
         ctx.env.NTPSEC_VERSION = "%s" % ntpsec_release
         ctx.env.NTPSEC_VERSION_EXTENDED = ("%s %s" % (ntpsec_release,



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/468fc5a7c99a804ed06318f7191c159598e73bf3...8b8f0a2f908d14c193d19a5f2cd96fd30543b0ad

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/468fc5a7c99a804ed06318f7191c159598e73bf3...8b8f0a2f908d14c193d19a5f2cd96fd30543b0ad
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/20201215/b8cf9aff/attachment-0001.htm>


More information about the vc mailing list