[Git][NTPsec/ntpsec][master] Add a new 'bin_test' command.

Amar Takhar gitlab at mg.gitlab.com
Thu Mar 24 00:20:01 UTC 2016


Amar Takhar pushed to branch master at NTPsec / ntpsec


Commits:
d8f791ad by Amar Takhar at 2016-03-23T20:18:36-04:00
Add a new 'bin_test' command.

This is a very low brow command to ensure binaries can actually run.  Eventually
it will be expanded into a proper set of operational testing.  This provides a
skeletal framework for collecting information about binaries and making the
output uniform enough to test properly.

- - - - -


2 changed files:

- + pylib/bin_test.py
- wscript


Changes:

=====================================
pylib/bin_test.py
=====================================
--- /dev/null
+++ b/pylib/bin_test.py
@@ -0,0 +1,57 @@
+from waflib.Utils import subprocess
+from waflib.Logs import pprint
+import re
+
+cmd_map = {
+	("main/ntpd/ntpd",				"-h"):					r'.*must be run as root, not uid.*',
+	("main/ntpdig/ntpdig",			"time.apple.com"):		r'.*time.apple.com.*',
+	("main/ntpfrob/ntpfrob",			"-h"):				r'.*illegal option.*',
+	("main/ntpkeygen/ntpkeygen",	  "-M"):				r'.*Generating new md5 file and link.*',
+	("main/ntpq/ntpq",  			  "-p"):				r'.*remote.*jitter.*',
+	("main/ntptime/ntptime",		  None):				r'.*ntp_gettime\(\) returns code 0 \(OK\).*',
+	("main/util/bumpclock", 		  None):				r".*Bumping clock by 100000 microseconds.*",
+	("main/util/propdelay", 		  "1","1", "2"," 2"):	r'.*summer propagation, height 350 km, hops 1, delay 0.00239626 seconds.*',
+	("main/util/sht",				  "2:r"):				r'.*reader.*',
+	("main/util/tg2",				  "--help"):			r'.*illegal option.*',
+#	("main/util/hist",  			  ""):  				r'',
+#	("main/ntptrace/ntptrace",  	  ""):  				r'',
+#	("main/ntpwait/ntpwait",		  ""):  				r'',
+#	("main/util/ntpsweep/ntpsweep",   ""):  				r'',
+}
+
+
+# XXX: Needs to run in a thread with a timeout.
+def run(cmd, reg):
+	check = False
+
+	if cmd[1] == None:
+		cmd = [cmd[0]]
+
+	print "running: ", " ".join(cmd),
+	p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=None, cwd="build")
+
+	stdout, stderr = p.communicate()
+
+	regex = re.compile(reg)
+
+	if regex.match(stdout) or regex.match(stderr):
+		check = True
+
+	if check:
+		pprint("GREEN", "  OK")
+		return False
+	else:
+		pprint("RED", "  FAILED")
+		return True
+
+
+def cmd_bin_test(ctx, config):
+	fail = True
+
+	for cmd in sorted(cmd_map):
+		fail = run(cmd, cmd_map[cmd])
+
+	if fail:
+		ctx.fatal("Failed")
+
+#cmd_bin_test(None, None)


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -46,6 +46,10 @@ class check(BuildContext):
 	cmd = 'check'
 	variant = "main"
 
+def bin_test(ctx):
+	from pylib.bin_test import cmd_bin_test
+	cmd_bin_test(ctx, config)
+
 # Borrowed from https://www.rtems.org/
 variant_cmd = (
 	("build",   BuildContext),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d8f791add353ba9eb768ba038fb471a114a06623
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160324/5c0d3fa2/attachment.html>


More information about the vc mailing list