Skip to contentSkip to conversation

ktest: Fixes for v7.1

PATCH New Steven Rostedt 1 participant 3 messages Apr 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ktest: Fixes for v7.1

ktest updates for v7.1:

- Fix date timestamp of failure directory

When a ktest fails, if STORE_FAILURES is set, then if a test fails, it copies various files to a created directory in the STORE_FAILURES location (like the .config used, and some other files). To create the timestamp portion of the directory name, the Perl function localtime() is used. The month field starts from 0 and the code does not account for this. That is, the date of April 20, 2026 will be displayed as 20260320 instead of 20260420. Add one to the month to have the date be more accurate.

- Save the entire log file in the failure directory

The logfile that keeps track of all tests contains boot messages, error messages, dmesg, etc. This information is very useful in figuring out why a test failed. Save the logfile in the failure directory as well.

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git
for-next

Head SHA1: 932cdaf3e273a2727e77af97f79f12577174c5a0

Steven Rostedt (2):
ktest: Fix the month in the name of the failure directory
ktest: Add logfile to failure directory

----

 tools/testing/ktest/ktest.pl | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
#1 lore raw

PATCH 1/2 ktest: Fix the month in the name of the failure directory

From: Steven Rostedt <[email protected]>

The Perl localtime() function returns the month starting at 0 not 1. This caused the date produced to create the directory for saving files of a failed run to have the month off by one.

machine-test-useconfig-fail-20260314073628

The above happened in April, not March. The correct name should have been:

machine-test-useconfig-fail-20260414073628

This was somewhat confusing.

Cc John 'Warthog9' Hawley <[email protected]>
Fixes 7faafbd69639b ("ktest: Add open and close console and start stop monitor")
---
 tools/testing/ktest/ktest.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/ktest/ktest.pl +1 -1
index 112f9ca2444b..dd55eea15070 100755
@@ -1855,7 +1855,7 @@ sub save_logs {
     my ($result, $basedir) = @_;
     my @t = localtime;
     my $date = sprintf "%04d%02d%02d%02d%02d%02d",
-	1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
+	1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0];
 
     my $type = $build_type;
     if ($type =~ /useconfig/) {
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/2 ktest: Add logfile to failure directory

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The logfile contains a lot of useful information about the tests being run. Add it to the stored failure directory when the test fails.

---
 tools/testing/ktest/ktest.pl | 6 ++++++
 1 file changed, 6 insertions(+)
tools/testing/ktest/ktest.pl +6 -0
index dd55eea15070..f94ed2e98887 100755
@@ -1878,6 +1878,12 @@ sub save_logs {
 	"testlog" => $testlog,
     );
 
+    if (defined($opt{"LOG_FILE"})) {
+	if (-f $opt{"LOG_FILE"}) {
+	    cp $opt{"LOG_FILE"}, "$dir/logfile";
+	}
+    }
+
     while (my ($name, $source) = each(%files)) {
 	if (-f "$source") {
 	    cp "$source", "$dir/$name" or
Signature · 1 line
2.51.0