Skip to content

Commit 5a1bed2

Browse files
AYUSHJAIN951rostedt
authored andcommitted
ktest: Fix Test Failures Due to Missing LOG_FILE Directories
Handle missing parent directories for LOG_FILE path to prevent test failures. If the parent directories don't exist, create them to ensure the tests proceed successfully. Cc: <warthog9@eaglescrag.net> Link: https://lore.kernel.org/20250307043854.2518539-1-Ayush.jain3@amd.com Signed-off-by: Ayush Jain <Ayush.jain3@amd.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 7eb1721 commit 5a1bed2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4303,6 +4303,14 @@ sub cancel_test {
43034303
if ($opt{"CLEAR_LOG"}) {
43044304
unlink $opt{"LOG_FILE"};
43054305
}
4306+
4307+
if (! -e $opt{"LOG_FILE"} && $opt{"LOG_FILE"} =~ m,^(.*/),) {
4308+
my $dir = $1;
4309+
if (! -d $dir) {
4310+
mkpath($dir) or die "Failed to create directories '$dir': $!";
4311+
print "\nThe log directory $dir did not exist, so it was created.\n";
4312+
}
4313+
}
43064314
open(LOG, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
43074315
LOG->autoflush(1);
43084316
}

0 commit comments

Comments
 (0)