From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AE893B388D for ; Tue, 28 Jul 2026 05:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785216306; cv=none; b=kBl8MLJ1eaEIM3ACkVROrmM9FFs/FVV1wdbcet6XAZFtaKfA8TTEb0V/MH6dj+iM6PyGlFO7GsHIaSnpgbei4X2U1XpmKDL13WHSKEr9DX9ak5XXvHr0IduN6La+ggB0mKyMA5tKP5MPrGJ8wdRtM7Xzf8z0E58trG1nsKDp+5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785216306; c=relaxed/simple; bh=/59R314bV7u6J/Q1dvT6ZHgghOW2ELDIohu1mKc79A4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=F62e0DHffYaFbPjW4GrGEESmf9XycX+Ou9AhWlTf3/WnyaGP/m1rcVgoNo5xIYgGvuE79uDB4G2JsKcI3TtJ7SoO5FCu3sSwxiWCm/HNUn60Cbbm+70BLpt3fgrlxyk8cYLSqRi/CBNWfyLG4RrjNhJiHCfKFmmdpS0lC6Ebr6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zh62n61O; arc=none smtp.client-ip=209.85.160.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zh62n61O" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-44cb057311bso1816726fac.0 for ; Mon, 27 Jul 2026 22:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785216302; x=1785821102; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=RViZYt3H1G9bUgjeW/M7ulmxBOpprcrBPJ5sg941ehA=; b=Zh62n61OeWIv8XNOyZI0PhUYNCa7jq1B2IXjAU2Czmt3XPLT/jgcDk6gPU0MvjjAKZ aGVo/HptCJxYRIY1Cz7RBkJP/3h9s0vC48KOLrD8b2cQnnlR2/1SUcUXy9bAt81IpU2q o/y12W2MNAnGDkv9ExRvq8SwEgxm/N8f4CljMfcmfBGNttkaRz1sNhuCiTujGENGUSvJ jowEO7ozFAGibBrRMMLDRvCDRHlEwaBBwjf8ebcRljQH2p6u/92Bezqxn5+c/k1iMXbD a8WgM/awD/j4cg9iTIbWpVay49Y3eBU6QcVDFkkrw9bLmTU/cH9BhAoRcy/na8ov1inz i5lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785216302; x=1785821102; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RViZYt3H1G9bUgjeW/M7ulmxBOpprcrBPJ5sg941ehA=; b=Czqho1CFKGilimiJ686zAos6MKyvYFtsjZSdEXSe0wf9zBFDrPeyI0oMVEGNa2zjm9 3my5zdJ9k1qf92TynVXhNHAqiF/6L6cXyVFoV8FZrmLU9TAg6yM2hOOKt4PEg5ga/+ur 0XCalStq0y+nyf0P3+4HOuAaog4WMjTSU/sqCzKN8naQrEWm5wLozSoE56Wik8jKEl+8 sX2dV2YRMtSxTE6xeP51ZLlvkezqiv0t4KBfQSunebFobxe6IkttK3r8nfe0aJQBPFDT seuUZmmaceuqAabsfMv8aLPPGnTd7OvaAwxlTvkwBVE89hiK1IXFKAuyrENDdlzxGl+G xJPg== X-Forwarded-Encrypted: i=1; AHgh+Rpl97N6pCiyfrojJHmtumtdwwy52ptGzMXtZBtGOVgKRkYqfrgEc5lgPwi4MyGOIhX5pHHMfRksYTTcpSM=@vger.kernel.org X-Gm-Message-State: AOJu0YwILgzm+hcBMvAI2YXWtbqJRCVy4MhwzAnIsgPij6jnFwuqbUjK z5/hoJIbaxmwlpsF2UR5/UAz6Lles8dgdKt08bczXxbit9C9jK0yXm3r X-Gm-Gg: AR+sD12w68yuNuSp9SjNAWvCFRP03y5R+E23Vo2o5Vi19jeStyiD7YCluaFEHOEamwn jMya2gXo4iNXoWNHL3bJJk7kIcV3JJkRb996oA+AO4HNxVJqvb4d4QMCA5cjcW0tE0Yvjse9xuE 1emPg/uSVRK4nquxmpq1wtVFvAH8P4s6yi6EzxGo7ee9Z5WExUQqDoLp2NjjtsMxvUqfJ9jhxAt gTYQPndeHZ35b1sWp/FKQgrExDXE2Z5FccAhqQ4q4OIIiAczazYYos93foq8V/qx9VyRFxfQ5aG hMB4Wv3S3Dj+hSBlHX3aoOlM6SfYhLlhpQ6ZMSmZ3gu+dWIUdl1WWOWE/jU1xLysG93oyF2UvQ+ FGwab6aRcLAfQmywYNYfOHWm4eznCV+slyU7v9uGas0W8nk7plcUMh+MQg0qm7mtrV7VBFRE= X-Received: by 2002:a05:6871:c91e:b0:448:c1f5:90f7 with SMTP id 586e51a60fabf-4586c8c1af7mr705437fac.19.1785216301583; Mon, 27 Jul 2026 22:25:01 -0700 (PDT) Received: from fedora ([187.170.33.67]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-45767488299sm18014036fac.16.2026.07.27.22.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 22:25:00 -0700 (PDT) From: Cihan Karadag To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Jonathan Corbet Cc: Cihan Karadag , Shuah Khan , linux-kernel@vger.kernel.org, workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH] checkpatch: warn about possible missing gitignore coverage in selftests Date: Mon, 27 Jul 2026 23:24:41 -0600 Message-ID: <20260728052442.626076-1-cihan.cihan@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Per selftests documentation [1], every generated test binary must be added to gitignore to prevent leaving untracked files in the kernel tree. This is an easy mistake to make when adding a new test. In fact, a search of selftests history turns up dozens of standalone follow-up patches with titles like "add missing gitignore for ", each needed only because the original patch adding a new test didn't also update gitignore. Add a SELFTESTS_GITIGNORE check that warns about gitignore coverage whenever a patch adds a new file under tools/testing/selftests/, the same way FILE_PATH_CHANGES warns about MAINTAINERS on any added, moved, or deleted file. The warning fires once per patch via a $reported_selftests_gitignore guard, even when a patch adds several new files under tools/testing/selftests/ at once, mirroring $reported_maintainer_file's per patch dedup for FILE_PATH_CHANGES. Link: https://docs.kernel.org/dev-tools/kselftest.html#contributing-new-tests-details [1] Signed-off-by: Cihan Karadag --- Documentation/dev-tools/checkpatch.rst | 7 +++++++ scripts/checkpatch.pl | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst index 6139a08c34cd8..9201d1cda0d44 100644 --- a/Documentation/dev-tools/checkpatch.rst +++ b/Documentation/dev-tools/checkpatch.rst @@ -1293,6 +1293,13 @@ Others **PRINTF_0XDECIMAL** Prefixing 0x with decimal output is defective and should be corrected. + **SELFTESTS_GITIGNORE** + Warn that, if the new file(s) added under tools/testing/selftests/ + generate any test objects, those objects need to be added to + .gitignore. + + See: https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html + **SPDX_LICENSE_TAG** The source file is missing or has an improper SPDX identifier tag. The Linux kernel requires the precise SPDX identifier in all source files, diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2b7a42bbdd94f..a4ead4677e3c6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2701,6 +2701,7 @@ sub process { my $commit_log_long_line = 0; my $commit_log_has_diff = 0; my $reported_maintainer_file = 0; + my $reported_selftests_gitignore = 0; my $non_utf8_charset = 0; my $last_git_commit_id_linenr = -1; @@ -3492,6 +3493,15 @@ sub process { "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); } +# Check for new files added under kselftests + if (!$reported_selftests_gitignore && !$in_commit_log && + ($line =~ /^new file mode\s*\d+\s*$/) && + ($realfile =~ m@^tools/testing/selftests/@)) { + $reported_selftests_gitignore = 1; + WARN("SELFTESTS_GITIGNORE", + "Added file(s) under tools/testing/selftests/, if they generate any test objects make sure they are added to .gitignore. See: Documentation/dev-tools/kselftest.rst\n"); + } + # Check for adding new DT bindings not in schema format if (!$in_commit_log && ($line =~ /^new file mode\s*\d+\s*$/) && -- 2.54.0