]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ktest.pl: Add new PATCHCHECK_SKIP option to skip testing individual commits
authorSteven Rostedt <rostedt@goodmis.org>
Fri, 25 Jul 2025 15:21:53 +0000 (11:21 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 29 Jul 2025 13:30:08 +0000 (09:30 -0400)
When testing a series of commits that also includes changes to the Linux
tools directory, it is useless to test the changes in tools as they may
not affect the kernel itself. Doing tests on the kernel for changes that
do not affect the kernel is a waste of time.

Add a PATCHCHECK_SKIP that takes a series of shas that will be skipped
while doing the individual commit tests.

For example, the runtime verification may have a series of commits like:

$ git log --abbrev-commit --pretty=oneline fac5493251a6~1..HEAD
3d3800b4f7f4 rv: Remove rv_reactor's reference counter
3d3c376118b5 rv: Merge struct rv_reactor_def into struct rv_reactor
24cbfe18d55a rv: Merge struct rv_monitor_def into struct rv_monitor
b0c08dd5348d rv: Remove unused field in struct rv_monitor_def
58d5f0d437a8 (debiantesting-x86-64/trace/rv/core) rv: Return init error when registering monitors
560473f2e2d7 verification/rvgen: Organise Kconfig entries for nested monitors
9efcf590827c tools/dot2c: Fix generated files going over 100 column limit
1160ccaf772f tools/rv: Stop gracefully also on SIGTERM
f60227f34489 tools/rv: Do not skip idle in trace
f3735df6281e verification/rvgen: Do not generate unused variables
6fb37c2a27eb verification/rvgen: Generate each variable definition only once
8cfcf9b0e92f verification/rvgen: Support the 'next' operator
fac5493251a6 rv: Allow to configure the number of per-task monitor

Where the first commit touches the kernel followed by a series of commits
that do not, and ends with commits that do. Instead of having to add
multiple patchcheck tests to handle the gaps, just include the commits
that should not be tested:

$ git log --abbrev-commit --pretty=oneline fac5493251a6~1..HEAD |
  grep -e verification -e tools/ | cut -d' ' -f1 |
  while read a ; do echo -n "$a "; done
560473f2e2d7 9efcf590827c 1160ccaf772f f60227f34489 f3735df6281e 6fb37c2a27eb 8cfcf9b0e92f

Then set PATCHCHECK_SKIP to that, and those commits will be skipped.

 PATCHCHECK_SKIP = 560473f2e2d7 9efcf590827c 1160ccaf772f f60227f34489 f3735df6281e 6fb37c2a27eb 8cfcf9b0e92f

Cc: John 'Warthog9' Hawley <warthog9@kernel.org>
Cc: Dhaval Giani <dhaval.giani@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/20250725112153.1dd06b84@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
tools/testing/ktest/ktest.pl
tools/testing/ktest/sample.conf

index 2d4ba097d510e8ce5a26ea8274a33b28febdf440..001c4df9f7df66083e16339ae9de2a5edc9fdd61 100755 (executable)
@@ -218,6 +218,7 @@ my $patchcheck_type;
 my $patchcheck_start;
 my $patchcheck_cherry;
 my $patchcheck_end;
+my $patchcheck_skip;
 
 my $build_time;
 my $install_time;
@@ -382,6 +383,7 @@ my %option_map = (
     "PATCHCHECK_START"         => \$patchcheck_start,
     "PATCHCHECK_CHERRY"                => \$patchcheck_cherry,
     "PATCHCHECK_END"           => \$patchcheck_end,
+    "PATCHCHECK_SKIP"          => \$patchcheck_skip,
 );
 
 # Options may be used by other options, record them.
@@ -3537,11 +3539,37 @@ sub patchcheck {
        @list = reverse @list;
     }
 
+    my %skip_list;
+    my $will_skip = 0;
+
+    if (defined($patchcheck_skip)) {
+       foreach my $s (split /\s+/, $patchcheck_skip) {
+           $s = `git log --pretty=oneline $s~1..$s`;
+           $s =~ s/^(\S+).*/$1/;
+           chomp $s;
+           $skip_list{$s} = 1;
+           $will_skip++;
+       }
+    }
+
     doprint("Going to test the following commits:\n");
     foreach my $l (@list) {
+       my $sha1 = $l;
+       $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
+       next if (defined($skip_list{$sha1}));
        doprint "$l\n";
     }
 
+    if ($will_skip) {
+       doprint("\nSkipping the following commits:\n");
+       foreach my $l (@list) {
+           my $sha1 = $l;
+           $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
+           next if (!defined($skip_list{$sha1}));
+           doprint "$l\n";
+       }
+    }
+
     my $save_clean = $noclean;
     my %ignored_warnings;
 
@@ -3556,6 +3584,11 @@ sub patchcheck {
        my $sha1 = $item;
        $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
 
+       if (defined($skip_list{$sha1})) {
+           doprint "\nSkipping \"$item\"\n\n";
+           next;
+       }
+
        doprint "\nProcessing commit \"$item\"\n\n";
 
        run_command "git checkout $sha1" or
index f43477a9b8574a328f40b1a55781e778c4415414..9c4c449a8f3ea9b2634e5b74e0b31e777dcc39f8 100644 (file)
 #      Note, PATCHCHECK_CHERRY requires PATCHCHECK_END to be defined.
 #      (default 0)
 #
+#  PATCHCHECK_SKIP is an optional list of shas to skip testing
+#
 #  PATCHCHECK_TYPE is required and is the type of test to run:
 #      build, boot, test.
 #