summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Jain <Ayush.jain3@amd.com>2025-03-07 04:38:54 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-20 10:15:27 +0200
commita4e3c80cecbe724176811475cfb3ec654c24c5a0 (patch)
tree10a862aee3538b2abb6e477cb51ff5145387c824
parent9a6be23eb0ff0460f3de5d215ac1b5727b2bdf80 (diff)
ktest: Fix Test Failures Due to Missing LOG_FILE Directories
[ Upstream commit 5a1bed232781d356f842576daacc260f0d0c8d2e ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index c76ad0be54e2..7e524601e01a 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -4303,6 +4303,14 @@ if (defined($opt{"LOG_FILE"})) {
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);
}