[29577] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Output last command info on k5test failures

daemon@ATHENA.MIT.EDU (Greg Hudson)
Thu Aug 18 13:30:14 2016

Date: Thu, 18 Aug 2016 13:30:09 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201608181730.u7IHU9L0021165@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/02333eb4ca63de43f465a372bd1291cf6b47bdc8
commit 02333eb4ca63de43f465a372bd1291cf6b47bdc8
Author: Greg Hudson <ghudson@mit.edu>
Date:   Wed Aug 17 11:50:31 2016 -0400

    Output last command info on k5test failures
    
    When a k5test failure occurs, display the last executed command, its
    command index, and its output.  This will make it easier to understand
    "make check" failures when it is not easy to run subsequent commands
    or investigate the filesystem of the build host.

 src/util/k5test.py |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/util/k5test.py b/src/util/k5test.py
index e90c2f3..2110e40 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -373,6 +373,11 @@ def fail(msg):
     """Print a message and exit with failure."""
     global _current_pass
     print "*** Failure:", msg
+    if _last_cmd:
+        print "*** Last command (#%d): %s" % (_cmd_index - 1, _last_cmd)
+    if _last_cmd_output:
+        print "*** Output of last command:"
+        sys.stdout.write(_last_cmd_output)
     if _current_pass:
         print "*** Failed in test pass:", _current_pass
     sys.exit(1)
@@ -643,15 +648,16 @@ def _stop_or_shell(stop, shell, env, ind):
 
 
 def _run_cmd(args, env, input=None, expected_code=0):
-    global null_input, _cmd_index, _debug
+    global null_input, _cmd_index, _last_cmd, _last_cmd_output, _debug
     global _stop_before, _stop_after, _shell_before, _shell_after
 
     if (_match_cmdnum(_debug, _cmd_index)):
         return _debug_cmd(args, env, input)
 
     args = _valgrind(args)
+    _last_cmd = _shell_equiv(args)
 
-    output('*** [%d] Executing: %s\n' % (_cmd_index, _shell_equiv(args)))
+    output('*** [%d] Executing: %s\n' % (_cmd_index, _last_cmd))
     _stop_or_shell(_stop_before, _shell_before, env, _cmd_index)
 
     if input:
@@ -663,6 +669,7 @@ def _run_cmd(args, env, input=None, expected_code=0):
     proc = subprocess.Popen(args, stdin=infile, stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT, env=env)
     (outdata, dummy_errdata) = proc.communicate(input)
+    _last_cmd_output = outdata
     code = proc.returncode
     output(outdata)
     output('*** [%d] Completed with return code %d\n' % (_cmd_index, code))
@@ -697,7 +704,7 @@ def _debug_cmd(args, env, input):
 # we see sentinel as a substring of a line on either stdout or stderr.
 # Clean up the daemon process on exit.
 def _start_daemon(args, env, sentinel):
-    global null_input, _cmd_index, _debug
+    global null_input, _cmd_index, _last_cmd, _last_cmd_output, _debug
     global _stop_before, _stop_after, _shell_before, _shell_after
 
     if (_match_cmdnum(_debug, _cmd_index)):
@@ -708,15 +715,17 @@ def _start_daemon(args, env, sentinel):
         sys.exit(1)
 
     args = _valgrind(args)
-    output('*** [%d] Starting: %s\n' %
-           (_cmd_index, _shell_equiv(args)))
+    _last_cmd = _shell_equiv(args)
+    output('*** [%d] Starting: %s\n' % (_cmd_index, _last_cmd))
     _stop_or_shell(_stop_before, _shell_before, env, _cmd_index)
 
     # Start the daemon and look for the sentinel in stdout or stderr.
     proc = subprocess.Popen(args, stdin=null_input, stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT, env=env)
+    _last_cmd_output = ''
     while True:
         line = proc.stdout.readline()
+        _last_cmd_output += line
         if line == "":
             code = proc.wait()
             fail('%s failed to start with code %d.' % (args[0], code))
@@ -1215,6 +1224,8 @@ atexit.register(_onexit)
 signal.signal(signal.SIGINT, _onsigint)
 _outfile = open('testlog', 'w')
 _cmd_index = 1
+_last_cmd = None
+_last_cmd_output = None
 buildtop = _find_buildtop()
 srctop = _find_srctop()
 plugins = os.path.join(buildtop, 'plugins')
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post