Skip to content

Commit

Permalink
ktest: Fix Test Failures Due to Missing LOG_FILE Directories
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ayush Jain authored and Steven Rostedt committed Mar 27, 2025
1 parent 7eb1721 commit 5a1bed2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4303,6 +4303,14 @@ sub cancel_test {
if ($opt{"CLEAR_LOG"}) {
unlink $opt{"LOG_FILE"};
}

if (! -e $opt{"LOG_FILE"} && $opt{"LOG_FILE"} =~ m,^(.*/),) {
my $dir = $1;
if (! -d $dir) {
mkpath($dir) or die "Failed to create directories '$dir': $!";
print "\nThe log directory $dir did not exist, so it was created.\n";
}
}
open(LOG, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
LOG->autoflush(1);
}
Expand Down

0 comments on commit 5a1bed2

Please sign in to comment.