[Git][NTPsec/ntpsec][packet-raw-mod] 2 commits: Make sure to fail on test failures

Eric S. Raymond gitlab at mg.gitlab.com
Tue Apr 11 14:05:35 UTC 2017


Eric S. Raymond pushed to branch packet-raw-mod at NTPsec / ntpsec


Commits:
b298cca8 by Matt Selsky at 2017-04-11T01:21:07-04:00
Make sure to fail on test failures

Print a list of working/failed tests as well

Fixes GitLab issue #258

- - - - -
1b47ed72 by Ian Bruene at 2017-04-11T14:05:06+00:00
Added raw return mode to mode 6 parser

- - - - -


2 changed files:

- pylib/packet.py
- wscript


Changes:

=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1243,7 +1243,7 @@ class ControlSession:
         idlist.sort(key=lambda a: a.associd)
         return idlist
 
-    def __parse_varlist(self):
+    def __parse_varlist(self, raw=False):
         "Parse a response as a textual varlist."
         # Strip out NULs and binary garbage from text;
         # ntpd seems prone to generate these, especially
@@ -1268,11 +1268,18 @@ class ControlSession:
                     var = pair[:eq].strip()
                     val = pair[eq+1:].strip().replace("\xae", ",")
                     try:
-                        val = int(val, 0)
+                        if raw is True:
+                            val = (int(val, 0), val)
+                        else:
+                            val = int(val, 0)
                     except ValueError:
                         try:
-                            valf = float(val)
-                            if var == "delay":
+                            if raw is True:
+                                valf = (float(val), val)
+                            else:
+                                valf = float(val)
+                            if (var == "delay") and (raw is False):
+                                # raw==false, if true str returned anyway
                                 # hack to pass string version
                                 # so printout can handle .3f vs .6f
                                 items.append(("delay-s", val))
@@ -1280,6 +1287,8 @@ class ControlSession:
                         except ValueError:
                             if val[0] == '"' and val[-1] == '"':
                                 val = val[1:-1]
+                                if raw is True:
+                                    val = (val, val)
                     items.append((var, val))
                 except ValueError:
                     # Yes, ntpd really does emit bare tags for empty
@@ -1288,14 +1297,14 @@ class ControlSession:
         return ntp.util.OrderedDict(items)
 
     def readvar(self, associd=0, varlist=None,
-                opcode=ntp.control.CTL_OP_READVAR):
+                opcode=ntp.control.CTL_OP_READVAR, raw=False):
         "Read system vars from the host as a dict, or throw an exception."
         if varlist is None:
             qdata = ""
         else:
             qdata = ",".join(varlist)
         self.doquery(opcode, associd=associd, qdata=qdata)
-        return self.__parse_varlist()
+        return self.__parse_varlist(raw)
 
     def config(self, configtext):
         "Send configuration text to the daemon. Return True if accepted."


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -232,6 +232,7 @@ def build(ctx):
 
         # Print a summary at the end
         ctx.add_post_fun(waf_unit_test.summary)
+        ctx.add_post_fun(waf_unit_test.set_exit_code)
     else:
         pprint("YELLOW", "Unit test runner skipped on a cross-compiled build.")
         from waflib import Options



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/0d193918f6bd03546c021f7a453c0a465b4befdd...1b47ed72aedcc8f2e39ae198a0ea26a565ca6a15
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170411/69beac8c/attachment.html>


More information about the vc mailing list