diff options
author | Rob Austein <sra@hactrn.net> | 2017-01-31 20:12:37 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-01-31 20:12:37 -0500 |
commit | 9ec81408c25207149d8b3bfcfc80faf1c8ff0811 (patch) | |
tree | d6759e2deaeb5821c4fbebec3dfc661fa07f8241 | |
parent | 31ce1c88f745c2946b3c0eb9986e0aaed164485c (diff) |
Enable low-level debugging support in libhal.py.
-rw-r--r-- | libhal.py | 4 | ||||
-rw-r--r-- | unit-tests.py | 8 |
2 files changed, 4 insertions, 8 deletions
@@ -417,7 +417,7 @@ class HSM(object): def _send(self, msg): # Expects an xdrlib.Packer msg = slip_encode(msg.get_buffer()) - #logger.debug("send: %s", ":".join("{:02x}".format(ord(c)) for c in msg)) + logger.debug("send: %s", ":".join("{:02x}".format(ord(c)) for c in msg)) self.socket.sendall(msg) def _recv(self, code): # Returns an xdrlib.Unpacker @@ -428,7 +428,7 @@ class HSM(object): if msg[-1] == "": raise HAL_ERROR_RPC_TRANSPORT() msg.append(self.sockfile.read(1)) - #logger.debug("recv: %s", ":".join("{:02x}".format(ord(c)) for c in msg)) + logger.debug("recv: %s", ":".join("{:02x}".format(ord(c)) for c in msg)) msg = slip_decode("".join(msg)) if not msg: continue diff --git a/unit-tests.py b/unit-tests.py index a8779c5..895bdb5 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -66,23 +66,19 @@ except ImportError: ecdsa_loaded = False -def log(msg): - if not args.quiet: - sys.stderr.write(msg) - sys.stderr.write("\n") - - def main(): from sys import argv global args args = parse_arguments(argv[1:]) argv = argv[:1] + args.only_test + logging.basicConfig(level = logging.DEBUG if args.debug else logging.INFO) unittest.main(verbosity = 1 if args.quiet else 2, argv = argv, catchbreak = True, testRunner = TextTestRunner) def parse_arguments(argv = ()): from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter parser = ArgumentParser(description = __doc__, formatter_class = ArgumentDefaultsHelpFormatter) parser.add_argument("--quiet", action = "store_true", help = "suppress chatter") + parser.add_argument("--debug", action = "store_true", help = "debug-level logging") parser.add_argument("--wheel-pin", default = "fnord", help = "PIN for wheel user") parser.add_argument("--so-pin", default = "fnord", help = "PIN for security officer") parser.add_argument("--user-pin", default = "fnord", help = "PIN for normal user") |