From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 7846443D50B for ; Thu, 8 Jan 2026 10:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868448; cv=none; b=Yc9erYpcBklSyqSUv96gMZcBX7bUDc2YdDLvlm9aGXrkUrtt3I4Zh122/tPW4tidQzMeR2gevfOdj4cUBbdOm+z4TRSJFV8zexzhXHHKZX6guIT6iXov81LSiAkXqqb7uZx3kPQY83NG/bdoE077lUn9Xse3D0auL21PZ9nkboA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868448; c=relaxed/simple; bh=/NZz8vYe4Dx4e39kN0eturw0woAyZfUPdWZDBqIivw0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=vCnlqQzh5Ci8yK0GTt9QFFiEGqgXnO3ldIV3+BRC28KLqdsRaabw7003FKC0YFdhnY0rvmLzhVK4RV4PIQFSAmwZ6HZSmYRn2DJFNJstsaAhNqo7TrUlxu44F3iYeVhWVyjvp9Pf4TBqaRBZ7Jd8sKP1N5RQGjxMWEGDT0hAa+E= 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=QEahjHl2; arc=none smtp.client-ip=209.85.219.48 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="QEahjHl2" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-8888a16d243so27455626d6.1 for ; Thu, 08 Jan 2026 02:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767868439; x=1768473239; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WvXLF/+sDtlU60C1OsJPdIvbCy4JgG2IqLtR8nMU3dM=; b=QEahjHl2uCkpxpxeGUbC9V0xMmgP+sc4jMGEORAdpP24aeyB6B0R/LsNeI7CoPY9hD 96X+deU5r6ftaodx8oHtQnciL6mQIFWcn/A1Tmvr33cYls8kkDH4YZp2ooQ/FCTuIFm9 P+hdQ87ydSI2NZSB/LqWLi9lALZVfmTMrUdRmeXkJO5ksUYeCqHiO6ZQYn8mKCspLrh0 agtueWk+RaocrKsPx1+aMUZGuhppCCv4eEhLSplSAVf7p6oeYwHYfjV01r9Y+puF5uPy htVNvh9ZT6xkZncv6StTm0wv5LpkXYVomqEzHKHmDw4NI6pYNUlfDH17b5GQQdkCeQvE sIpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767868439; x=1768473239; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WvXLF/+sDtlU60C1OsJPdIvbCy4JgG2IqLtR8nMU3dM=; b=OPV8+rWeCZK1rWJBIPmlAzpt38STMQ7w1GaRx5FnVdoUjV8yAiw7WMMMdXJ+50Gbfy 0obKcFRfkDu+TaJcwmw+2Ei4h0ijNIhFDxcjyA0AOcGJtleiFRyYRx2BLIstQefQ6JlO 1Nxsnwne6fT4/3/ZvSRMuEJmbuEY5Ca4tqNLSDcrQ+DIogEtWfiQMsryEduCqmqlp5md 6UgIwlYapivjD5nLz/98u4OdPpSFk6ShzjEje90RIhnRRGuf4AtLBH1oQUrqxNlAMXSQ yZ8zPzJcKPTZe3W+da92ECCdjLUDSDdJ8e/JCPEYhcqeIeIp6MQb1lsEOzjy3TbQOqM3 OGXQ== X-Forwarded-Encrypted: i=1; AJvYcCUZrRV9Be/wztB24UCuzsheA/cicXBH4CRrLCYs6zW6hJkRjPt0/T2oGTkifhXTBmYqV9PM6Vb0jzGGW/o=@vger.kernel.org X-Gm-Message-State: AOJu0YxvJTYdPq1aIEGO+05f10sh0UNKqHzx8gtplI2LKYWzvnqPzxbw OsxIHE4rKzI1UyeJ0I5XTYwUAnj5rarrgjjTOOJ6zTVyTMGYK4b+uf5Q7bo5lQ== X-Gm-Gg: AY/fxX7Sxxrg+/Flt/o6ZCp/cRi6FtbkxikHHa33CujweWz99jWPrCMFpxP1xTuTtLd H9Ghrx48NIim5s6SNYSdFz75w4ogbQY+ZcymcP3VZOWoF3lm+ENHqnsiad/mLVoVfFVZ1RfVmJH lOdBulvEh5HRZxvgzJdDkHz9DBJl7FiI2d4osLvVASb0cq2zm8IELHcZP5tECSBOlF+LNNx+D1n j8Ob/OI3nFwrNW/ONf0EvoMK+G0EERLA9JHx4cWm5GQ6YsjLwl8W9me+YxZndO+uVe/BJtzxHrG X5248w5HpCv8wC7SD7yuaIlyzLp4Y260W6s/nqqmcKY/+DAAd74s/WQhyllzRwW6VD1m11q14u2 eAqVBgLGtc6sI6K1Aa6kS18fkURvK88zutc4iGBkVB1Llb8hAbeIKXfJF+A5TZ9Ow/SUa+8Mow7 zpaZRVT965QTudCYgs4Zo= X-Google-Smtp-Source: AGHT+IHZ/e/9MRP0LhYoIMzqNf8baO/CNi6HGD9URb21j0msGo+xTT0NXqavKnYmSn7lb/sewf/nzQ== X-Received: by 2002:a17:902:e952:b0:29f:2f40:76c4 with SMTP id d9443c01a7336-2a3ee48ace2mr49153895ad.34.1767862419899; Thu, 08 Jan 2026 00:53:39 -0800 (PST) Received: from google.com ([2401:fa00:95:201:bac6:7809:4716:2fd6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cb2eabsm70662015ad.49.2026.01.08.00.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 00:53:39 -0800 (PST) Date: Thu, 8 Jan 2026 16:53:35 +0800 From: Kuan-Wei Chiu To: Kir Chou Cc: akpm@linux-foundation.org, geert@linux-m68k.org, linux-kernel@vger.kernel.org, davidgow@google.com, brendan.higgins@linux.dev, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, kirchou@google.com Subject: Re: [PATCH v3] lib/glob: convert selftest to KUnit Message-ID: References: <20260107051903.35039-1-note351@hotmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260107051903.35039-1-note351@hotmail.com> Hi Kir, On Wed, Jan 07, 2026 at 02:19:03PM +0900, Kir Chou wrote: > This patch converts the existing glob selftest (lib/globtest.c) to use > the KUnit framework (lib/tests/glob_kunit.c). > > The new test: > > - Migrates all 64 test cases from the original test to the KUnit suite. > - Removes the custom 'verbose' module parameter as KUnit handles logging. > - Updates Kconfig.debug and Makefile to support the new KUnit test. > - Updates Kconfig and Makefile to remove the original selftest. > - Updates GLOB_SELFTEST to GLOB_KUNIT_TEST for arch/m68k/configs. > > This commit is verified by `./tools/testing/kunit/kunit.py run` > with the .kunit/.kunitconfig: > > ``` > CONFIG_KUNIT=y > CONFIG_GLOB_KUNIT_TEST=y > ``` > > Signed-off-by: Kir Chou Thanks for the patch. However, it seems you missed carrying forward David's Reviewed-by and Geert's Acked-by tags. Please include them in the next version. If you dropped them intentionally (e.g., due to changes in v3), please explain why under --- line. > --- > v2: > - Remove CONFIG_GLOB_KUNIT_TEST from defconfigs as it's implicitly enabled > by CONFIG_KUNIT_ALL_TESTS. (Suggested by Geert) > v3: > - Move lib/glob_kunit.c to lib/tests/glob_kunit.c. > - Update Makefile accordingly. > --- > arch/m68k/configs/amiga_defconfig | 1 - > arch/m68k/configs/apollo_defconfig | 1 - > arch/m68k/configs/atari_defconfig | 1 - > arch/m68k/configs/bvme6000_defconfig | 1 - > arch/m68k/configs/hp300_defconfig | 1 - > arch/m68k/configs/mac_defconfig | 1 - > arch/m68k/configs/multi_defconfig | 1 - > arch/m68k/configs/mvme147_defconfig | 1 - > arch/m68k/configs/mvme16x_defconfig | 1 - > arch/m68k/configs/q40_defconfig | 1 - > arch/m68k/configs/sun3_defconfig | 1 - > arch/m68k/configs/sun3x_defconfig | 1 - > lib/Kconfig | 13 --- > lib/Kconfig.debug | 13 +++ > lib/Makefile | 1 - > lib/globtest.c | 167 --------------------------- > lib/tests/Makefile | 1 + > lib/tests/glob_kunit.c | 122 +++++++++++++++++++ > 18 files changed, 136 insertions(+), 193 deletions(-) > delete mode 100644 lib/globtest.c > create mode 100644 lib/tests/glob_kunit.c > ... > @@ -430,19 +430,6 @@ config GLOB > are compiling an out-of tree driver which tells you that it > depends on this. > > -config GLOB_SELFTEST > - tristate "glob self-test on init" > - depends on GLOB > - help > - This option enables a simple self-test of the glob_match > - function on startup. It is primarily useful for people > - working on the code to ensure they haven't introduced any > - regressions. > - > - It only adds a little bit of code and slows kernel boot (or > - module load) by a small amount, so you're welcome to play with > - it, but you probably don't need it. > - > # > # Netlink attribute parsing support is select'ed if needed > # > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index ba36939fd..e4347e145 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -3354,6 +3354,19 @@ config PRIME_NUMBERS_KUNIT_TEST > > If unsure, say N > > +config GLOB_KUNIT_TEST > + tristate "Glob matching test" if !KUNIT_ALL_TESTS > + depends on KUNIT > + default KUNIT_ALL_TESTS > + select GLOB The original test used depends on GLOB. Any specific reason for switching to select GLOB? Ideally, tests should not select functionality, to prevent increasing the attack vector. > + help > + Enable this option to test the glob functions at runtime. > + > + This test suite verifies the correctness of glob_match() across various > + scenarios, including edge cases. > + > + If unsure, say N > + > endif # RUNTIME_TESTING_MENU > > config ARCH_USE_MEMTEST ... > diff --git a/lib/tests/glob_kunit.c b/lib/tests/glob_kunit.c > new file mode 100644 > index 000000000..797e32a8c > --- /dev/null > +++ b/lib/tests/glob_kunit.c > @@ -0,0 +1,122 @@ > +// SPDX-License-Identifier: GPL-2.0 The original file lib/globtest.c (and lib/glob.c) is dual-licensed (MIT/GPL), and your MODULE_LICENSE at the end of this file also states "Dual MIT/GPL". However, this SPDX identifier marks the file as GPL-2.0 only. > +/* > + * Test cases for glob functions. > + */ > + > +#include > +#include > +#include > + > +struct glob_test_case { > + // Pattern to match. > + const char *pat; > + // String to match against. > + const char *str; > + // Expected glob_match result, true is matched. If you want to document the struct members, the standard kernel-doc format [1] would be preferred over C++-style comments. [1]: https://origin.kernel.org/doc/html/v6.18/doc-guide/kernel-doc.html#structure-union-and-enumeration-documentation > + bool expected; > +}; > + > +static const struct glob_test_case glob_test_cases[] = { > + /* Some basic tests */ > + { .pat = "a", .str = "a", .expected = true }, > + { .pat = "a", .str = "b", .expected = false }, > + { .pat = "a", .str = "aa", .expected = false }, > + { .pat = "a", .str = "", .expected = false }, > + { .pat = "", .str = "", .expected = true }, > + { .pat = "", .str = "a", .expected = false }, > + /* Simple character class tests */ > + { .pat = "[a]", .str = "a", .expected = true }, > + { .pat = "[a]", .str = "b", .expected = false }, > + { .pat = "[!a]", .str = "a", .expected = false }, > + { .pat = "[!a]", .str = "b", .expected = true }, > + { .pat = "[ab]", .str = "a", .expected = true }, > + { .pat = "[ab]", .str = "b", .expected = true }, > + { .pat = "[ab]", .str = "c", .expected = false }, > + { .pat = "[!ab]", .str = "c", .expected = true }, > + { .pat = "[a-c]", .str = "b", .expected = true }, > + { .pat = "[a-c]", .str = "d", .expected = false }, > + /* Corner cases in character class parsing */ > + { .pat = "[a-c-e-g]", .str = "-", .expected = true }, > + { .pat = "[a-c-e-g]", .str = "d", .expected = false }, > + { .pat = "[a-c-e-g]", .str = "f", .expected = true }, > + { .pat = "[]a-ceg-ik[]", .str = "a", .expected = true }, > + { .pat = "[]a-ceg-ik[]", .str = "]", .expected = true }, > + { .pat = "[]a-ceg-ik[]", .str = "[", .expected = true }, > + { .pat = "[]a-ceg-ik[]", .str = "h", .expected = true }, > + { .pat = "[]a-ceg-ik[]", .str = "f", .expected = false }, > + { .pat = "[!]a-ceg-ik[]", .str = "h", .expected = false }, > + { .pat = "[!]a-ceg-ik[]", .str = "]", .expected = false }, > + { .pat = "[!]a-ceg-ik[]", .str = "f", .expected = true }, > + /* Simple wild cards */ > + { .pat = "?", .str = "a", .expected = true }, > + { .pat = "?", .str = "aa", .expected = false }, > + { .pat = "??", .str = "a", .expected = false }, > + { .pat = "?x?", .str = "axb", .expected = true }, > + { .pat = "?x?", .str = "abx", .expected = false }, > + { .pat = "?x?", .str = "xab", .expected = false }, > + /* Asterisk wild cards (backtracking) */ > + { .pat = "*??", .str = "a", .expected = false }, > + { .pat = "*??", .str = "ab", .expected = true }, > + { .pat = "*??", .str = "abc", .expected = true }, > + { .pat = "*??", .str = "abcd", .expected = true }, > + { .pat = "??*", .str = "a", .expected = false }, > + { .pat = "??*", .str = "ab", .expected = true }, > + { .pat = "??*", .str = "abc", .expected = true }, > + { .pat = "??*", .str = "abcd", .expected = true }, > + { .pat = "?*?", .str = "a", .expected = false }, > + { .pat = "?*?", .str = "ab", .expected = true }, > + { .pat = "?*?", .str = "abc", .expected = true }, > + { .pat = "?*?", .str = "abcd", .expected = true }, > + { .pat = "*b", .str = "b", .expected = true }, > + { .pat = "*b", .str = "ab", .expected = true }, > + { .pat = "*b", .str = "ba", .expected = false }, > + { .pat = "*b", .str = "bb", .expected = true }, > + { .pat = "*b", .str = "abb", .expected = true }, > + { .pat = "*b", .str = "bab", .expected = true }, > + { .pat = "*bc", .str = "abbc", .expected = true }, > + { .pat = "*bc", .str = "bc", .expected = true }, > + { .pat = "*bc", .str = "bbc", .expected = true }, > + { .pat = "*bc", .str = "bcbc", .expected = true }, > + /* Multiple asterisks (complex backtracking) */ > + { .pat = "*ac*", .str = "abacadaeafag", .expected = true }, > + { .pat = "*ac*ae*ag*", .str = "abacadaeafag", .expected = true }, > + { .pat = "*a*b*[bc]*[ef]*g*", .str = "abacadaeafag", .expected = true }, > + { .pat = "*a*b*[ef]*[cd]*g*", .str = "abacadaeafag", .expected = false }, > + { .pat = "*abcd*", .str = "abcabcabcabcdefg", .expected = true }, > + { .pat = "*ab*cd*", .str = "abcabcabcabcdefg", .expected = true }, > + { .pat = "*abcd*abcdef*", .str = "abcabcdabcdeabcdefg", .expected = true }, > + { .pat = "*abcd*", .str = "abcabcabcabcefg", .expected = false }, > + { .pat = "*ab*cd*", .str = "abcabcabcabcefg", .expected = false }, > +}; > + > +static void glob_case_to_desc(const struct glob_test_case *t, char *desc) > +{ > + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "pat:\"%s\" str:\"%s\"", t->pat, t->str); > +} > + > +KUNIT_ARRAY_PARAM(glob, glob_test_cases, glob_case_to_desc); > + > +static void glob_test_match(struct kunit *test) > +{ > + const struct glob_test_case *params = test->param_value; > + > + KUNIT_EXPECT_EQ_MSG(test, checkpatch.pl reports an alignment issue here: CHECK: Alignment should match open parenthesis #632: FILE: lib/tests/glob_kunit.c:104: + KUNIT_EXPECT_EQ_MSG(test, + glob_match(params->pat, params->str), Regards, Kuan-Wei > + glob_match(params->pat, params->str), > + params->expected, > + "Pattern: \"%s\", String: \"%s\", Expected: %d", > + params->pat, params->str, params->expected); > +} > + > +static struct kunit_case glob_kunit_test_cases[] = { > + KUNIT_CASE_PARAM(glob_test_match, glob_gen_params), > + {} > +}; > + > +static struct kunit_suite glob_test_suite = { > + .name = "glob", > + .test_cases = glob_kunit_test_cases, > +}; > + > +kunit_test_suite(glob_test_suite); > +MODULE_DESCRIPTION("Test cases for glob functions"); > +MODULE_LICENSE("Dual MIT/GPL"); > -- > 2.52.0.351.gbe84eed79e-goog > >