[Git][NTPsec/ntpsec][master] Updated bin_test

James Browning gitlab at mg.gitlab.com
Mon Oct 1 17:21:36 UTC 2018


James Browning pushed to branch master at NTPsec / ntpsec


Commits:
a69ffb02 by Ian Bruene at 2018-10-01T17:20:31Z
Updated bin_test

- - - - -


15 changed files:

- docs/includes/ntpfrob-body.txt
- docs/includes/ntpkeygen-body.txt
- docs/includes/ntpleapfetch-body.txt
- docs/includes/ntpsweep-body.txt
- docs/includes/ntptime-body.txt
- docs/includes/ntptrace-body.txt
- docs/includes/ntpwait-body.txt
- ntpclients/ntpkeygen.py
- ntpclients/ntpleapfetch
- ntpclients/ntpsweep.py
- ntpclients/ntptrace.py
- ntpclients/ntpwait.py
- ntpfrob/main.c
- ntptime/ntptime.c
- wafhelpers/bin_test.py


Changes:

=====================================
docs/includes/ntpfrob-body.txt
=====================================
@@ -42,6 +42,8 @@ utilities.
   Print usage and exit.
 +-h+::
   Print usage and exit.
++-V+::
+  Print the version string and exit.
 
 [[usage]]
 == Usage ==


=====================================
docs/includes/ntpkeygen-body.txt
=====================================
@@ -4,7 +4,7 @@
 
 == Synopsis ==
 [verse]
-+ntpkeygen+ [+-M+]
++ntpkeygen+ [+-MV+]
 
 == Description ==
 
@@ -26,6 +26,8 @@ passwords for the link:ntpq.html[+ntpq+] utility program.
 +-M+, +--md5key+::
   Dummy option for backward compatibility in old scripts.  This
   program always runs in -M mode.
++-V+, +--version+::
+  Print the version string and exit.
 
 [[run]]
 == Running the program ==


=====================================
docs/includes/ntpleapfetch-body.txt
=====================================
@@ -8,7 +8,7 @@
     [+-46+] [+-c+ 'command'] [+-e+ 'expiry'] [+-f+ 'config'] [+-F+] [+-h+]
 	[+-i+ 'interval'] [+-l+] [+L+] [+-p+ {4|6}] [+-P+ 'logfacility'] [+-q+]
 	[+-r+ 'retries'] [+-s+ 'source-url'] [+-t+ 'path'] [+-v+] [+-z+ 'path']
-	[+-Z+] ['leapfile']
+	[+-Z+] ['leapfile'] [+-V+ | +--version+]
 
 == DESCRIPTION ==
 
@@ -103,4 +103,7 @@ present and to default leapfile) /etc/{ntpconf}
 +-Z+::
   Use system path only.
 
++-V+, +--version+::
+  Print the version string and exit.
+
 // end


=====================================
docs/includes/ntpsweep-body.txt
=====================================
@@ -3,7 +3,7 @@
 // tree, and once to make an individual man page.
 
 == Synopsis ==
-+ntpsweep+ [+-l+ 'host']... [-p] [+-m+ 'number'] [+-s+ 'prefix'] [+-h+ 'string'] [hostfile...]
++ntpsweep+ [+-V+ | +--version+] [+-l+ 'host']... [-p] [+-m+ 'number'] [+-s+ 'prefix'] [+-h+ 'string'] [hostfile...]
 
 
 == Description ==
@@ -43,6 +43,9 @@ by commas.
 +-h+ string, +--host+=_string_::
   Specify a single host.  Deprecated option for backwards compatibility.
 
++-V+, +--version+::
+  Print the version string and exit.
+
 If hostfiles are specified, they are treated as lists of hostnames
 to be swept, one per line.
 


=====================================
docs/includes/ntptime-body.txt
=====================================
@@ -45,6 +45,8 @@ Kernel Model for Precision Timekeeping] page,
   Specify clock status. Better know what you are doing.
 +-t+ 'time_constant'::
   Specify time constant, an integer in the range 0-10.
++-V+::
+  Print the version string and exit.
 
 == Bugs ==
 


=====================================
docs/includes/ntptrace-body.txt
=====================================
@@ -5,7 +5,7 @@
 == SYNOPSIS ==
 
 [verse]
-+ntptrace+ [+-n+ |+--numeric+]
++ntptrace+ [+-V+ | +--version+] [+-n+ |+--numeric+]
     [+-m+ 'number' | +--max-hosts=+'number']
     [+-r+ 'host' | +--host=+'remote']
     'hostname'
@@ -57,4 +57,7 @@ the canonical host names.
 +-r+ string, +--host+=_string_::
   Trace a single remote host.
 
++-V+, +--version+::
+  Print the version string and exit.
+
 // end


=====================================
docs/includes/ntpwait-body.txt
=====================================
@@ -1,6 +1,6 @@
 == SYNOPSIS ==
 
-+ntpwait+ [+-v+] [+-n+ 'number'] [+-s+ 'secs']
++ntpwait+ [+-vV+] [+-n+ 'number'] [+-s+ 'secs']
 
 == DESCRIPTION ==
 
@@ -37,6 +37,9 @@ returns "the time is not yet stable".
 By default, +ntpwait+ is silent. With this option, +ntpwait+ will
 provide status information, including time to synchronization in seconds.
 
++-V+, +--version+::
+  Print the version string and exit.
+
 == BUGS ==
 
 If you are running Python at a version older than 3.3, the report on time


=====================================
ntpclients/ntpkeygen.py
=====================================
@@ -27,6 +27,7 @@ import random
 import time
 import getopt
 import stat
+import ntp.util
 
 #
 # Cryptodefines
@@ -84,7 +85,8 @@ def fheader(fileid,     # file name id
 
 if __name__ == '__main__':
     try:
-        (options, arguments) = getopt.getopt(sys.argv[1:], "hM", ["help"])
+        (options, arguments) = getopt.getopt(sys.argv[1:], "hMV",
+                                             ["help", "version"])
     except getopt.GetoptError as e:
         print(e)
         raise SystemExit(1)
@@ -96,6 +98,9 @@ if __name__ == '__main__':
         elif switch in ("-h", "--help"):
             print("usage: ntpkeygen")
             raise SystemExit(0)
+        elif switch in ("-V", "--version"):
+            print("ntpkeygen %s" % ntp.util.stdversion())
+            raise SystemExit(0)
 
     # The seed is ignored by random.SystemRandom,
     # even though the docs do not say so.


=====================================
ntpclients/ntpleapfetch
=====================================
@@ -87,6 +87,7 @@ All arguments are optional:  Default (or current value) shown:
     -z    Specify path for utilities
           $PATHLIST
     -Z    Only use system path
+    -V    Output version information and exit
 
 $SELF will validate the file currently on the local system
 
@@ -115,6 +116,13 @@ EOF
    return 0
 }
 
+function displayVersion {
+            cat <<EOF
+ntpleapfetch ntpsec- at NTPSEC_VERSION_EXTENDED@
+EOF
+   return 0
+}
+
 # Default: Use syslog for logging if running under cron
 
 SYSLOG="$CRONJOB"
@@ -124,9 +132,14 @@ if [ "$1" = "--help" ]; then
     exit 0
 fi
 
+if [ "$1" = "--version" ]; then
+    displayVersion
+    exit 0
+fi
+
 # Parse options
 
-while getopts 46p:P:s:e:f:Fc:r:i:lLt:hqvz:Z opt; do
+while getopts 46p:P:s:e:f:Fc:r:i:lLt:hqvz:ZV opt; do
     case $opt in
         4)
             PROTO="-4"
@@ -179,6 +192,10 @@ while getopts 46p:P:s:e:f:Fc:r:i:lLt:hqvz:Z opt; do
             displayHelp
             exit 0
             ;;
+		V)
+			displayVersion
+			exit 0
+			;;
 	q)
 	    QUIET="Y"
 	    ;;


=====================================
ntpclients/ntpsweep.py
=====================================
@@ -11,6 +11,7 @@ USAGE: ntpsweep [-<flag> [<val>] | --<name>[{=| }<val>]]... [hostfile]
     -m, --maxlevel=num         Traverse peers up to this level
                                    (4 is a reasonable number)
     -s, --strip=str            Strip this string from hostnames
+    -V, --version              Output version information and exit
 
 Options are specified by doubled hyphens and their name or by a single
 hyphen and the flag character.
@@ -150,8 +151,8 @@ def scan_host(host, level):
 if __name__ == '__main__':
     try:
         (options, arguments) = getopt.getopt(
-            sys.argv[1:], "h:l:m:ps:?",
-            ["host=", "host-list=", "maxlevel=", "peers", "strip="])
+            sys.argv[1:], "h:l:m:ps:?V",
+            ["host=", "host-list=", "maxlevel=", "peers", "strip=", "version"])
     except getopt.GetoptError as err:
         sys.stderr.write(str(err) + "\n")
         raise SystemExit(1)
@@ -174,6 +175,9 @@ if __name__ == '__main__':
         elif switch == "-?" or switch == "--help":
             print(__doc__, file=sys.stderr)
             raise SystemExit(0)
+        elif switch == "-V" or switch == "--version":
+            print("ntpsweep %s" % ntp.util.stdversion())
+            raise SystemExit(0)
 
     try:
         if arguments:


=====================================
ntpclients/ntptrace.py
=====================================
@@ -5,6 +5,7 @@ ntptrace - trace peers of an NTP server
 
 Usage: ntptrace [-n | --numeric] [-m number | --max-hosts=number]
                 [-r hostname | --host=hostname] [--help | --more-help]
+                [-V | --version]
                 hostname
 
 See the manual page for details.
@@ -110,14 +111,15 @@ USAGE: ntptrace [-<flag> [<val>] | --<name>[{=| }<val>]]... [host]
     -r, --host=str               Single remote host
     -?, --help                   Display usage information and exit
         --more-help              Pass the extended usage text through a pager
+    -V, --version                Output version information and exit
 
 Options are specified by doubled hyphens and their name or by a single
 hyphen and the flag character.""" + "\n"
 
 try:
     (options, arguments) = getopt.getopt(
-        sys.argv[1:], "m:nr:?",
-        ["help", "host=", "max-hosts=", "more-help", "numeric"])
+        sys.argv[1:], "m:nr:?V",
+        ["help", "host=", "max-hosts=", "more-help", "numeric", "version"])
 except getopt.GetoptError as err:
     sys.stderr.write(str(err) + "\n")
     raise SystemExit(1)
@@ -137,6 +139,9 @@ for (switch, val) in options:
     elif switch == "-?" or switch == "--help" or switch == "--more-help":
         print(usage, file=sys.stderr)
         raise SystemExit(0)
+    elif switch == "-V" or switch == "--version":
+        print("ntptrace %s" % ntp.util.stdversion())
+        raise SystemExit(0)
 
 if len(arguments):
     host = arguments[0]


=====================================
ntpclients/ntpwait.py
=====================================
@@ -8,6 +8,7 @@ USAGE: ntpwait [-n tries] [-s sleeptime] [-v] [-h]
     -s, --sleep=num              How long to sleep between tries
     -v, --verbose                Be verbose
     -h, --help                   Issue help
+    -V, --version                Output version information and exit
 
 Options are specified by doubled hyphens and their name or by a single
 hyphen and the flag character.
@@ -51,8 +52,8 @@ class Unbuffered(object):
 
 if __name__ == "__main__":
     try:
-        (options, arguments) = getopt.getopt(sys.argv[1:], "hn:s:v", [
-            "tries=", "sleep=", "verbose", "help"
+        (options, arguments) = getopt.getopt(sys.argv[1:], "hn:s:vV", [
+            "tries=", "sleep=", "verbose", "help", "version"
         ])
     except getopt.GetoptError as err:
         sys.stderr.write(str(err) + "\n")
@@ -72,6 +73,9 @@ if __name__ == "__main__":
         elif switch in ("-h", "--help"):
             sys.stdout.write(__doc__)
             raise SystemExit(0)
+        elif switch in ("-V", "--version"):
+            print("ntpwait %s" % ntp.util.stdversion())
+            raise SystemExit(0)
 
     # Autoflush stdout
     sys.stdout = Unbuffered(sys.stdout)


=====================================
ntpfrob/main.c
=====================================
@@ -30,6 +30,7 @@ static void usage(void)
 "        -r         Raw mode. Only applies to the jitter mode.\n"
 "        -?         Print usage\n"
 "        -h         Print usage\n"
+"        -V         Output version information and exit\n"
     , stderr);
 
 }
@@ -40,7 +41,7 @@ main(int argc, char **argv)
 	int ch;
         bool got_one = false;
 	iomode mode = plain_text;
-	while ((ch = getopt(argc, argv, "a:Ab:cdDejp:rh?")) != EOF) {
+	while ((ch = getopt(argc, argv, "a:Ab:cdDejp:rh?V")) != EOF) {
                 got_one = true;
 		switch (ch) {
 		case 'A':
@@ -101,6 +102,9 @@ main(int argc, char **argv)
 		case 'r':
 		    mode = raw;
 		    break;
+	    case 'V':
+		    printf("ntpfrob ntpsec-%s\n", NTPSEC_VERSION_EXTENDED);
+			exit(0);
 		default:
 		    fputs("ntpfrob: no mode option specified.\n", stderr);
                     /* fall through */


=====================================
ntptime/ntptime.c
=====================================
@@ -100,7 +100,7 @@ static volatile int pll_control; /* (0) daemon, (1) kernel loop */
 static volatile int status;	/* most recent status bits */
 static volatile int flash;	/* most recent ntp_adjtime() bits */
 char* progname;
-static char optargs[] = "MNT:cde:f:hjm:o:rs:t:";
+static char optargs[] = "MNT:cde:f:hjm:o:rs:t:V";
 
 int
 main(
@@ -190,6 +190,10 @@ main(
 			ntx.constant = atoi(ntp_optarg);
 			break;
 
+	    case 'V':
+		    printf("ntptime ntpsec-%s\n", NTPSEC_VERSION_EXTENDED);
+			exit(0);
+
 		default:
 			errflg++;
 		}
@@ -207,7 +211,8 @@ main(
 -o offset	current offset (ms)\n\
 -r		print the unix and NTP time raw\n\
 -s status	Set the status bits\n\
--t timeconstant	log2 of PLL time constant (0 .. %d)\n",
+-t timeconstant	log2 of PLL time constant (0 .. %d)\n\
+-V      Output version information and exit\n",
 			progname, optargs,
 #ifdef MOD_MICRO
 "-M		switch to microsecond mode\n",


=====================================
wafhelpers/bin_test.py
=====================================
@@ -1,26 +1,30 @@
 from __future__ import print_function
-import re
+import sys
 from os.path import exists
 from waflib.Utils import subprocess
 from waflib.Logs import pprint
 
+# Need the build form of util.py to get the version string
+sys.path.insert(0, "build/main/pylib/")
+import util
+
+verStr = util.stdversion()
+
 cmd_map = {
-    ("main/ntpd/ntpd", "-invalid"): br'.*must be run as root, not uid.*',
-    ("main/ntpclients/ntpdig", "time.apple.com"): br'.*time.apple.com.*',
-    ("main/ntpfrob/ntpfrob", "-h"): br'usage:',
-    ("main/ntpfrob/ntpfrob", "-b 100000"):
-        br"Bumping clock by 100000 microseconds",
-    ("main/ntpclients/ntpkeygen", None):
-        br'Generating new ',
-    ("main/ntpclients/ntpq", "-p"): br'.*remote.*jitter.*',
-    ("main/ntptime/ntptime", None):
-        br'ntp_gettime\(\) returns code 0 \(OK\)',
-    ("main/attic/sht", "2:r"): br'reader',
-
-    # Perl library
-    #       ("main/ntpclients/ntptrace", ""): br'',
-    #       ("main/ntpclients/ntpwait", ""): br'',
-    #       ("main/ntpclients/ntpsweep", ""): br'',
+    ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % verStr,
+    ("main/ntpclients/ntpdig", "--version"): "ntpdig %s\n" % verStr,
+    ("main/ntpclients/ntpkeygen", "--version"): "ntpkeygen %s\n" % verStr,
+    ("main/ntpclients/ntpq", "--version"): "ntpq %s\n" % verStr,
+    ("main/ntpclients/ntpmon", "--version"): "ntpmon %s\n" % verStr,
+    ("main/ntpclients/ntpleapfetch", "--version"): "ntpleapfetch %s\n" % verStr,
+    ("main/ntpclients/ntplogtemp", "--version"): "ntplogtemp %s\n" % verStr,
+    ("main/ntpclients/ntpsnmpd", "--version"): "ntpsnmpd %s\n" % verStr,
+    ("main/ntpclients/ntpsweep", "--version"): "ntpsweep %s\n" % verStr,
+    ("main/ntpclients/ntptrace", "--version"): "ntptrace %s\n" % verStr,
+    ("main/ntpclients/ntpviz", "--version"): "ntpviz %s\n" % verStr,
+    ("main/ntpclients/ntpwait", "--version"): "ntpwait %s\n" % verStr,
+    ("main/ntpfrob/ntpfrob", "-V"): "ntpfrob %s\n" % verStr,
+    ("main/ntptime/ntptime", "-V"): "ntptime %s\n" % verStr,
 }
 
 
@@ -43,9 +47,7 @@ def run(cmd, reg):
 
     stdout, stderr = p.communicate()
 
-    regex = re.compile(reg)
-
-    if regex.match(stdout) or regex.match(stderr):
+    if (stdout == reg) or (stderr == reg):
         check = True
 
     if check:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a69ffb02efbc1a067e0765c081f7d54887a91150

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a69ffb02efbc1a067e0765c081f7d54887a91150
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/20181001/02b5b52d/attachment-0001.html>


More information about the vc mailing list