]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Collect failed command trace logs in k5test 1458/head
authorGreg Hudson <ghudson@mit.edu>
Sat, 27 Sep 2025 06:32:58 +0000 (02:32 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 30 Sep 2025 20:41:19 +0000 (16:41 -0400)
In _run_cmd(), read the trace file and copy it into the log before
checking the return code and expected output message.

src/util/k5test.py

index 5659fed1c4a6c044a772dd4c72d6402a8ffbfeed..bef645dd063cade115f0fb4cc71b2455f42f1dfc 100644 (file)
@@ -776,20 +776,24 @@ def _run_cmd(args, env, input=None, expected_code=0, expected_msg=None,
     _stop_or_shell(_stop_after, _shell_after, env, _cmd_index)
     _cmd_index += 1
 
-    # Check the return code and return the output.
+    # Copy trace output into the log if we collected it.
+    if tracefile is not None:
+        with open(tracefile, 'r') as f:
+            trace = f.read()
+        output('*** Trace output for previous command:\n')
+        output(trace)
+
+    # Check the return code.
     if code != expected_code:
         fail('%s failed with code %d.' % (args[0], code))
 
+    # Check for the expected message if given.
     if expected_msg is not None and expected_msg not in outdata:
         fail('Expected string not found in command output: ' + expected_msg)
 
-    if tracefile is not None:
-        with open(tracefile, 'r') as f:
-            trace = f.read()
-        output('*** Trace output for previous command:\n')
-        output(trace)
-        if expected_trace is not None:
-            _check_trace(trace, expected_trace)
+    # Check for expected trace log messages if given.
+    if expected_trace is not None:
+        _check_trace(trace, expected_trace)
 
     return (outdata, trace) if return_trace else outdata