Commit 68f090f0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull ktest update from Steven Rostedt:

 - Fix failure of directory of log file not existing

   If a LOG_FILE option is set for ktest to log its messages, and the
   directory path does not exist. Then ktest fails. Have ktest attempt
   to create the directory where the log file exists and if that
   succeeds continue on testing.

* tag 'ktest-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
  ktest: Fix Test Failures Due to Missing LOG_FILE Directories
parents 4fa118e5 5a1bed23
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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);
}