All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v3 4/9] scripts/checkpatch: use new hook for ACPI test data check
Date: Thu, 15 May 2025 14:59:31 +0100	[thread overview]
Message-ID: <20250515135936.86760-5-berrange@redhat.com> (raw)
In-Reply-To: <20250515135936.86760-1-berrange@redhat.com>

The ACPI test data check needs to analyse a list of all files in a
commit, so can use the new hook for processing the file list.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 scripts/checkpatch.pl | 61 ++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b74391e63a..6a7b543ddf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1330,29 +1330,6 @@ sub WARN {
 	}
 }
 
-# According to tests/qtest/bios-tables-test.c: do not
-# change expected file in the same commit with adding test
-sub checkfilename {
-	my ($name, $acpi_testexpected, $acpi_nontestexpected) = @_;
-
-        # Note: shell script that rebuilds the expected files is in the same
-        # directory as files themselves.
-        # Note: allowed diff list can be changed both when changing expected
-        # files and when changing tests.
-	if ($name =~ m#^tests/data/acpi/# and not $name =~ m#^\.sh$#) {
-		$$acpi_testexpected = $name;
-	} elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
-		$$acpi_nontestexpected = $name;
-	}
-	if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) {
-		ERROR("Do not add expected files together with tests, " .
-		      "follow instructions in " .
-		      "tests/qtest/bios-tables-test.c: both " .
-		      $$acpi_testexpected . " and " .
-		      $$acpi_nontestexpected . " found\n");
-	}
-}
-
 sub checkspdx {
     my ($file, $expr) = @_;
 
@@ -1437,6 +1414,34 @@ sub checkspdx {
 # real filenames that were seen in the patch
 sub process_file_list {
 	my @fileinfos = @_;
+
+	# According to tests/qtest/bios-tables-test.c: do not
+	# change expected file in the same commit with adding test
+	my @acpi_testexpected;
+	my @acpi_nontestexpected;
+
+	foreach my $fileinfo (@fileinfos) {
+		# Note: shell script that rebuilds the expected files is in
+		# the same directory as files themselves.
+		# Note: allowed diff list can be changed both when changing
+		#  expected files and when changing tests.
+		if ($fileinfo->{filenew} =~ m#^tests/data/acpi/# &&
+		    $fileinfo->{filenew} !~ m#^\.sh$#) {
+			push @acpi_testexpected, $fileinfo->{filenew};
+		} elsif ($fileinfo->{filenew} !~
+			 m#^tests/qtest/bios-tables-test-allowed-diff.h$#) {
+			push @acpi_nontestexpected, $fileinfo->{filenew};
+		}
+	}
+	if (int(@acpi_testexpected) > 0 and int(@acpi_nontestexpected) > 0) {
+		ERROR("Do not add expected files together with tests, " .
+		      "follow instructions in " .
+		      "tests/qtest/bios-tables-test.c. Files\n\n  " .
+		      join("\n  ", @acpi_testexpected) .
+		      "\n\nand\n\n  " .
+		      join("\n  ", @acpi_nontestexpected) .
+		      "\n\nfound in the same patch\n");
+	}
 }
 
 # Called at the start of processing a diff hunk for a file
@@ -1501,9 +1506,6 @@ sub process {
 	my %suppress_whiletrailers;
 	my %suppress_export;
 
-        my $acpi_testexpected;
-        my $acpi_nontestexpected;
-
 	# Pre-scan the patch sanitizing the lines.
 
 	sanitise_line_reset();
@@ -1642,7 +1644,6 @@ sub process {
 			$fileold =~ s@^([^/]*)/@@ if (!$file);
 			$filenew =~ s@^([^/]*)/@@ if (!$file);
 			$realfile = $filenew;
-	                checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
 
 			$fileinfo = {
 				"isgit" => 1,
@@ -1676,8 +1677,6 @@ sub process {
 			$realfile = $1;
 			$realfile =~ s@^([^/]*)/@@ if (!$file);
 
-	                checkfilename($realfile, \$acpi_testexpected, \$acpi_nontestexpected);
-
 			$p1_prefix = $1;
 			if (!$file && $tree && $p1_prefix ne '' &&
 			    -e "$root/$p1_prefix") {
@@ -1770,9 +1769,7 @@ sub process {
 		     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
 		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
 		      (defined($1) || defined($2)))) &&
-                      !(($realfile ne '') &&
-                        defined($acpi_testexpected) &&
-                        ($realfile eq $acpi_testexpected))) {
+		    $realfile !~ m#^tests/data/acpi/#) {
 			$reported_maintainer_file = 1;
 			WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
 		}
-- 
2.49.0



  parent reply	other threads:[~2025-05-15 14:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15 13:59 [PATCH v3 0/9] scripts/checkpatch: fix SPDX-License-Identifier detection Daniel P. Berrangé
2025-05-15 13:59 ` [PATCH v3 1/9] Revert "scripts: mandate that new files have SPDX-License-Identifier" Daniel P. Berrangé
2025-05-19 12:06   ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 2/9] scripts/checkpatch.pl: fix various indentation mistakes Daniel P. Berrangé
2025-05-19 12:12   ` Peter Maydell
2025-05-19 16:08     ` Daniel P. Berrangé
2025-05-19 16:27   ` Alex Bennée
2025-05-19 16:36     ` Daniel P. Berrangé
2025-05-19 16:39     ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 3/9] scripts/checkpatch: introduce tracking of file start/end Daniel P. Berrangé
2025-05-19 12:17   ` Peter Maydell
2025-05-15 13:59 ` Daniel P. Berrangé [this message]
2025-05-15 16:55   ` [PATCH v3 4/9] scripts/checkpatch: use new hook for ACPI test data check Cédric Le Goater
2025-05-19 12:29   ` Peter Maydell
2025-05-19 16:21     ` Daniel P. Berrangé
2025-05-15 13:59 ` [PATCH v3 5/9] scripts/checkpatch: use new hook for file permissions check Daniel P. Berrangé
2025-05-19 12:19   ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 6/9] scripts/checkpatch: expand pattern for matching makefiles Daniel P. Berrangé
2025-05-15 16:20   ` Cédric Le Goater
2025-05-19 12:22   ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 7/9] scripts/checkpatch: use new hook for MAINTAINERS update check Daniel P. Berrangé
2025-05-19 12:21   ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 8/9] scripts/checkpatch: reimplement mandate for SPDX-License-Identifier Daniel P. Berrangé
2025-05-19 12:21   ` Peter Maydell
2025-05-15 13:59 ` [PATCH v3 9/9] scripts/checkpatch: reject license boilerplate on new files Daniel P. Berrangé
2025-05-15 15:42   ` Cédric Le Goater
2025-05-15 16:05   ` Daniel P. Berrangé
2025-05-15 16:06     ` Cédric Le Goater
2025-05-15 16:19       ` Cédric Le Goater
2025-05-15 16:36         ` Daniel P. Berrangé
2025-05-19 12:41   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250515135936.86760-5-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=clg@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.