krb5 commit: Add k5test --trace option
ghudson at mit.edu
ghudson at mit.edu
Fri Sep 26 12:49:14 EDT 2025
https://github.com/krb5/krb5/commit/26f94a2b9952089066c1f42403a35307575ac606
commit 26f94a2b9952089066c1f42403a35307575ac606
Author: Greg Hudson <ghudson at mit.edu>
Date: Mon Sep 22 15:43:43 2025 -0400
Add k5test --trace option
Make it easier to collect trace logs for commands invoked by test
scripts. Trace output will be placed in testtrace.<cmdnum> for
daemons, or collected in the log for regular command invocations.
.gitignore | 2 +-
src/config/post.in | 2 +-
src/util/k5test.py | 20 ++++++++++++++++----
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
index ae6780c37..d4e978349 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,7 @@ obj/
skiptests
testdir/
testlog
-testtrace
+testtrace*
# Ignore the build directory
/build/
diff --git a/src/config/post.in b/src/config/post.in
index 4d0cb7535..36751f292 100644
--- a/src/config/post.in
+++ b/src/config/post.in
@@ -168,7 +168,7 @@ clean: clean-$(WHAT)
clean-unix::
$(RM) $(OBJS) $(DEPTARGETS_CLEAN) $(EXTRA_FILES)
- $(RM) et-[ch]-*.et et-[ch]-*.[ch] testlog testtrace runenv.sh
+ $(RM) et-[ch]-*.et et-[ch]-*.[ch] testlog testtrace* runenv.sh
-$(RM) -r testdir
clean-windows::
diff --git a/src/util/k5test.py b/src/util/k5test.py
index d22cb5c80..5659fed1c 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -595,7 +595,7 @@ def _find_symbolizer():
# be used by the test script.
def _parse_args():
global args, verbose, testpass, _debug, _debugger_command
- global _stop_before, _stop_after, _shell_before, _shell_after
+ global _stop_before, _stop_after, _shell_before, _shell_after, _trace
parser = optparse.OptionParser()
parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
default=False, help='Display verbose output')
@@ -613,6 +613,8 @@ def _parse_args():
help='Spawn shell before numbered command (or "all")')
parser.add_option('--shell-after', dest='shella', metavar='NUM',
help='Spawn shell after numbered command (or "all")')
+ parser.add_option('--trace', dest='trace', metavar='NUM',
+ help='Collect trace log for numbered command (or "all")')
(options, args) = parser.parse_args()
verbose = options.verbose
testpass = options.testpass
@@ -621,6 +623,7 @@ def _parse_args():
_stop_after = _parse_cmdnum('--stop-after', options.stopa)
_shell_before = _parse_cmdnum('--shell-before', options.shellb)
_shell_after = _parse_cmdnum('--shell-after', options.shella)
+ _trace = _parse_cmdnum('--trace', options.trace)
if options.debugger is not None:
_debugger_command = shlex.split(options.debugger)
@@ -736,10 +739,11 @@ def _check_trace(trace, expected):
def _run_cmd(args, env, input=None, expected_code=0, expected_msg=None,
expected_trace=None, return_trace=False):
global null_input, _cmd_index, _last_cmd, _last_cmd_output, _debug
- global _stop_before, _stop_after, _shell_before, _shell_after
+ global _stop_before, _stop_after, _shell_before, _shell_after, _trace
tracefile = None
- if expected_trace is not None or return_trace:
+ if (expected_trace is not None or return_trace or
+ _match_cmdnum(_trace, _cmd_index)):
tracefile = 'testtrace'
if os.path.exists(tracefile):
os.remove(tracefile)
@@ -813,7 +817,7 @@ def _debug_cmd(args, env, input):
# Clean up the daemon process on exit.
def _start_daemon(args, env, sentinel):
global null_input, _cmd_index, _last_cmd, _last_cmd_output, _debug
- global _stop_before, _stop_after, _shell_before, _shell_after
+ global _stop_before, _stop_after, _shell_before, _shell_after, _trace
if (_match_cmdnum(_debug, _cmd_index)):
output('*** [%d] Warning: ' % _cmd_index, True)
@@ -822,6 +826,14 @@ def _start_daemon(args, env, sentinel):
output('*** Exiting after debugging daemon\n', True)
sys.exit(1)
+ if (_match_cmdnum(_trace, _cmd_index)):
+ tracefile = 'testtrace.' + str(_cmd_index)
+ output('*** [%d] trace log in %s\n' % (_cmd_index, tracefile), True)
+ if os.path.exists(tracefile):
+ os.remove(tracefile)
+ env = env.copy()
+ env['KRB5_TRACE'] = tracefile
+
args = _valgrind(args)
_last_cmd = _shell_equiv(args)
output('*** [%d] Starting: %s\n' % (_cmd_index, _last_cmd))
More information about the cvs-krb5
mailing list