From bde7aa6d4b0a5eaa23abba58538c7c571baf9b9e Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 20 Oct 2026 10:33:38 -0400 Subject: [PATCH] ktest.pl: Add total test run time to output It can be interesting to know what the total time of all the tests took. Instead of just seeing the time for each individual test, at the end of the test (even on failure) show the total time the test took to complete. This can also help identify if something has changed in the setup that should be investigated if the times suddenly increase drastically. Link: https://patch.msgid.link/20261020103338.4be97a72@gandalf.local.home Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 1945f6ee2483..ad61f1ee2e7c 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -227,6 +227,7 @@ my $build_time; my $install_time; my $reboot_time; my $test_time; +my $start_run_time; my $warning_found = 0; @@ -1609,6 +1610,14 @@ sub run_post_ktest { $post_ktest_done = 1; } +sub show_run_time { + return if (!$start_run_time); + my $end_run_time = time; + doprint "\n Total run time: "; + show_time($end_run_time - $start_run_time); + doprint "\n"; +} + sub dodie { # avoid recursion return if ($in_die); @@ -1631,6 +1640,8 @@ sub dodie { `$power_off`; } + show_run_time(); + if (defined($opt{"LOG_FILE"})) { print " See $opt{LOG_FILE} for more info.\n"; } @@ -4534,6 +4545,8 @@ print_test_preamble 0; $SIG{INT} = qw(cancel_test); +$start_run_time = time; + # First we need to do is the builds for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { @@ -4766,6 +4779,8 @@ if ($email_when_finished) { "$successes of $opt{NUM_TESTS} tests started at $script_start_time were successful!"); } +show_run_time(); + if (defined($opt{"LOG_FILE"})) { print "\n See $opt{LOG_FILE} for the record of results.\n\n"; close LOG;