]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ktest: Fix Test Failures Due to Missing LOG_FILE Directories
authorAyush Jain <Ayush.jain3@amd.com>
Fri, 7 Mar 2025 04:38:54 +0000 (04:38 +0000)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 27 Mar 2025 13:34:00 +0000 (09:34 -0400)
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>
tools/testing/ktest/ktest.pl

index 8c8da966c641bca1f4a2a2bf3e42b185859dadff..a5f7fdd0c1fbbbdbc2025801f8fc54cbb0db00fb 100755 (executable)
@@ -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);
 }