* [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma
[not found] <cover.1796351229.git.3514767322@qq.com>
@ 2026-12-04 2:57 ` Miao Tianzhong
2026-12-04 5:27 ` Aveline Noir
2026-12-04 2:57 ` [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module Miao Tianzhong
2026-12-04 2:57 ` [PATCH 3/3] kunit: add tests for the test attribute API Miao Tianzhong
2 siblings, 1 reply; 6+ messages in thread
From: Miao Tianzhong @ 2026-12-04 2:57 UTC (permalink / raw)
To: brendan.higgins, david
Cc: raemoar63, linux-kselftest, kunit-dev, linux-kernel,
Miao Tianzhong, stable
kunit.filter_attr= takes a comma separated list of attribute filters.
When the list ends with a comma (e.g. "kunit.filter_attr=speed=slow,")
kunit_get_filter_count() counts the empty trailing segment as an extra
filter, and kunit_next_attr_filter() then leaves the cursor pointing at
the beginning of the string instead of terminating the list, so the same
filter is parsed and applied twice.
Only count segments that contain a filter, and terminate the list in
kunit_next_attr_filter() when nothing but whitespace follows the last
comma.
Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Miao Tianzhong <3514767322@qq.com>
---
lib/kunit/attributes.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/lib/kunit/attributes.c b/lib/kunit/attributes.c
index 6d7a53af94a9..9d368a2844d8 100644
--- a/lib/kunit/attributes.c
+++ b/lib/kunit/attributes.c
@@ -319,17 +319,21 @@ void kunit_print_attr(void *test_or_suite, bool is_test, unsigned int test_level
int kunit_get_filter_count(char *input)
{
- int i, comma_index = 0, count = 0;
+ int i, count = 0;
+ bool has_content = false;
for (i = 0; input[i]; i++) {
if (input[i] == ',') {
- if ((i - comma_index) > 1)
+ if (has_content)
count++;
- comma_index = i;
+ has_content = false;
+ } else if (input[i] != ' ') {
+ has_content = true;
}
}
- if ((i - comma_index) > 0)
+ if (has_content)
count++;
+
return count;
}
@@ -383,7 +387,14 @@ struct kunit_attr_filter kunit_next_attr_filter(char **filters, int *err)
if (comma_index > 0) {
input[comma_index] = '\0';
filter.input = input + op_index;
- input = input + new_start_index;
+ /*
+ * Nothing but whitespace after the last comma: the filter
+ * list ends here.
+ */
+ if (new_start_index > comma_index)
+ input = input + new_start_index;
+ else
+ input = NULL;
} else {
filter.input = input + op_index;
input = NULL;
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module
[not found] <cover.1796351229.git.3514767322@qq.com>
2026-12-04 2:57 ` [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma Miao Tianzhong
@ 2026-12-04 2:57 ` Miao Tianzhong
2026-12-04 5:22 ` Aveline Noir
2026-12-04 2:57 ` [PATCH 3/3] kunit: add tests for the test attribute API Miao Tianzhong
2 siblings, 1 reply; 6+ messages in thread
From: Miao Tianzhong @ 2026-12-04 2:57 UTC (permalink / raw)
To: brendan.higgins, david
Cc: raemoar63, linux-kselftest, kunit-dev, linux-kernel,
Miao Tianzhong, stable
kunit_filter_attr_tests() evaluates the attribute filter for the test,
suite and default attribute values. A test case that has no module_name
(or a suite whose first test case has none) produces a NULL attribute
value, and attr_string_filter() passes it to strcmp(), which dereferences
NULL and panics the kernel.
Treat a NULL string attribute as an empty string, which matches the
default value used for the module attribute.
Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Miao Tianzhong <3514767322@qq.com>
---
lib/kunit/attributes.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/kunit/attributes.c b/lib/kunit/attributes.c
index 9d368a2844d8..1b26374a018f 100644
--- a/lib/kunit/attributes.c
+++ b/lib/kunit/attributes.c
@@ -158,6 +158,9 @@ static int attr_string_filter(void *attr, const char *input, int *err)
{
char *str = attr;
+ if (!str)
+ str = "";
+
if (!strncmp(input, "<", 1)) {
*err = -EINVAL;
pr_err("kunit executor: invalid filter input: %s\n", input);
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] kunit: add tests for the test attribute API
[not found] <cover.1796351229.git.3514767322@qq.com>
2026-12-04 2:57 ` [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma Miao Tianzhong
2026-12-04 2:57 ` [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module Miao Tianzhong
@ 2026-12-04 2:57 ` Miao Tianzhong
2026-12-04 5:32 ` Aveline Noir
2 siblings, 1 reply; 6+ messages in thread
From: Miao Tianzhong @ 2026-12-04 2:57 UTC (permalink / raw)
To: brendan.higgins, david
Cc: raemoar63, linux-kselftest, kunit-dev, linux-kernel, Miao Tianzhong
Add parameterized unit tests for lib/kunit/attributes.c covering filter
parsing (including the error paths and the trailing comma case), the
filtering semantics of the speed, module and is_init attributes including
the test case -> suite -> default fallback, and the print path.
The tests also cover the two issues fixed by the preceding patches: a
trailing comma in the filter list, and filtering on the module attribute
when a test case has no module name.
The executor level tests in executor_test.c already cover the integration
path through kunit_filter_suites(); these tests add the unit level
coverage that was missing.
Signed-off-by: Miao Tianzhong <3514767322@qq.com>
---
lib/kunit/Makefile | 1 +
lib/kunit/attributes_test.c | 492 ++++++++++++++++++++++++++++++++++++
2 files changed, 493 insertions(+)
create mode 100644 lib/kunit/attributes_test.c
diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile
index 204e02b10eba..90fb2305772a 100644
--- a/lib/kunit/Makefile
+++ b/lib/kunit/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_KUNIT_TEST) += backtrace-suppression-test.o
ifeq ($(CONFIG_KUNIT_TEST),y)
obj-$(CONFIG_KUNIT_TEST) += string-stream-test.o
obj-$(CONFIG_KUNIT_TEST) += assert_test.o
+obj-$(CONFIG_KUNIT_TEST) += attributes_test.o
endif
obj-$(CONFIG_KUNIT_EXAMPLE_TEST) += kunit-example-test.o
diff --git a/lib/kunit/attributes_test.c b/lib/kunit/attributes_test.c
new file mode 100644
index 000000000000..88866b1f9061
--- /dev/null
+++ b/lib/kunit/attributes_test.c
@@ -0,0 +1,492 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * KUnit tests for the test attribute API.
+ */
+
+#include <kunit/test.h>
+#include <kunit/attributes.h>
+#include <linux/string.h>
+
+#define ATTR_BUF_SIZE 64
+
+static void dummy_test(struct kunit *test)
+{
+}
+
+/* Attribute filtering never runs the test cases, only their attributes. */
+static struct kunit_case plain_cases[] = {
+ { .name = "plain", .run_case = dummy_test },
+ {}
+};
+
+static int parse_filter(char *input, struct kunit_attr_filter *filter)
+{
+ char *cursor = input;
+ int err = 0;
+
+ *filter = kunit_next_attr_filter(&cursor, &err);
+ return err;
+}
+
+static void free_filtered_suite(struct kunit_suite *suite)
+{
+ if (!suite || IS_ERR(suite))
+ return;
+
+ kfree(suite->test_cases);
+ kfree(suite);
+}
+
+static int count_bits(int mask)
+{
+ int count = 0;
+
+ while (mask) {
+ count += mask & 1;
+ mask >>= 1;
+ }
+
+ return count;
+}
+
+struct count_case {
+ const char *input;
+ int expected;
+};
+
+static const struct count_case count_cases[] = {
+ { "speed=slow", 1 },
+ { "speed>slow,module=foo", 2 },
+ { "speed>slow, module=foo,is_init=true", 3 },
+ { "", 0 },
+ { "speed=slow,", 1 },
+ { "speed=slow,module=foo,", 2 },
+ { ",", 0 },
+};
+
+static void count_desc(const struct count_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s -> %d", param->input, param->expected);
+}
+
+KUNIT_ARRAY_PARAM(count, count_cases, count_desc);
+
+static void filter_count_test(struct kunit *test)
+{
+ const struct count_case *param = test->param_value;
+ char buf[ATTR_BUF_SIZE];
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->input, sizeof(buf));
+ KUNIT_EXPECT_EQ(test, kunit_get_filter_count(buf), param->expected);
+}
+
+struct parse_case {
+ const char *input;
+ const char *name;
+ const char *value;
+};
+
+static const struct parse_case parse_cases[] = {
+ { "speed>slow", "speed", ">slow" },
+ { "module!=dummy", "module", "!=dummy" },
+ { "is_init=true", "is_init", "=true" },
+ { "speed=slow, module=foo", "speed", "=slow" },
+};
+
+static void parse_desc(const struct parse_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->input);
+}
+
+KUNIT_ARRAY_PARAM(parse, parse_cases, parse_desc);
+
+static void parse_filter_test(struct kunit *test)
+{
+ const struct parse_case *param = test->param_value;
+ struct kunit_attr_filter filter;
+ char buf[ATTR_BUF_SIZE];
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->input, sizeof(buf));
+
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+ KUNIT_EXPECT_STREQ(test, kunit_attr_filter_name(filter), param->name);
+ KUNIT_EXPECT_STREQ(test, filter.input, param->value);
+}
+
+struct iterate_case {
+ const char *input;
+ int count;
+ const char *names[3];
+};
+
+static const struct iterate_case iterate_cases[] = {
+ { "speed=slow,module=foo", 2, { "speed", "module" } },
+ { "speed=slow,", 1, { "speed" } },
+ { "speed=slow, module=foo,is_init=true", 3, { "speed", "module", "is_init" } },
+};
+
+static void iterate_desc(const struct iterate_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->input);
+}
+
+KUNIT_ARRAY_PARAM(iterate, iterate_cases, iterate_desc);
+
+static void parse_multiple_test(struct kunit *test)
+{
+ const struct iterate_case *param = test->param_value;
+ struct kunit_attr_filter filter;
+ char buf[ATTR_BUF_SIZE];
+ char *cursor = buf;
+ int i;
+ int err = 0;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->input, sizeof(buf));
+
+ for (i = 0; i < param->count; i++) {
+ filter = kunit_next_attr_filter(&cursor, &err);
+ KUNIT_ASSERT_EQ_MSG(test, err, 0, "filter %d of %s", i, param->input);
+ KUNIT_ASSERT_NOT_NULL(test, filter.attr);
+ KUNIT_EXPECT_STREQ(test, kunit_attr_filter_name(filter), param->names[i]);
+ }
+
+ KUNIT_EXPECT_NULL(test, cursor);
+}
+
+struct error_case {
+ const char *input;
+};
+
+static const struct error_case parse_error_cases[] = {
+ { "speed" },
+ { "=slow" },
+ { "foobar=1" },
+};
+
+static void error_desc(const struct error_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->input);
+}
+
+KUNIT_ARRAY_PARAM(parse_error, parse_error_cases, error_desc);
+
+static void parse_error_test(struct kunit *test)
+{
+ const struct error_case *param = test->param_value;
+ struct kunit_attr_filter filter;
+ char buf[ATTR_BUF_SIZE];
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->input, sizeof(buf));
+
+ KUNIT_EXPECT_EQ(test, parse_filter(buf, &filter), -EINVAL);
+ KUNIT_EXPECT_NULL(test, filter.attr);
+}
+
+struct speed_case {
+ const char *filter;
+ enum kunit_speed case_speed[2];
+ enum kunit_speed suite_speed;
+ int expected;
+};
+
+static const struct speed_case speed_cases[] = {
+ { "speed=slow", { KUNIT_SPEED_SLOW, KUNIT_SPEED_NORMAL }, KUNIT_SPEED_UNSET, 0x1 },
+ { "speed>slow", { KUNIT_SPEED_SLOW, KUNIT_SPEED_NORMAL }, KUNIT_SPEED_UNSET, 0x2 },
+ { "speed<=slow", { KUNIT_SPEED_SLOW, KUNIT_SPEED_NORMAL }, KUNIT_SPEED_UNSET, 0x1 },
+ /* Fallback to the attribute default value. */
+ { "speed=normal", { KUNIT_SPEED_UNSET, KUNIT_SPEED_UNSET }, KUNIT_SPEED_UNSET, 0x3 },
+ /* Fallback to the suite value. */
+ { "speed=slow", { KUNIT_SPEED_UNSET, KUNIT_SPEED_UNSET }, KUNIT_SPEED_SLOW, 0x3 },
+ /* The test case value overrides the suite value. */
+ { "speed=normal", { KUNIT_SPEED_SLOW, KUNIT_SPEED_NORMAL }, KUNIT_SPEED_SLOW, 0x2 },
+ { "speed=very_slow", { KUNIT_SPEED_SLOW, KUNIT_SPEED_NORMAL }, KUNIT_SPEED_UNSET, 0x0 },
+};
+
+static void speed_desc(const struct speed_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->filter);
+}
+
+KUNIT_ARRAY_PARAM(speed, speed_cases, speed_desc);
+
+static void filter_speed_test(struct kunit *test)
+{
+ const struct speed_case *param = test->param_value;
+ struct kunit_case cases[] = {
+ { .name = "case0", .run_case = dummy_test, .attr.speed = param->case_speed[0] },
+ { .name = "case1", .run_case = dummy_test, .attr.speed = param->case_speed[1] },
+ {}
+ };
+ struct kunit_suite suite = {
+ .name = "fake",
+ .test_cases = cases,
+ .attr.speed = param->suite_speed,
+ };
+ struct kunit_attr_filter filter;
+ struct kunit_suite *result;
+ char buf[ATTR_BUF_SIZE];
+ int i;
+ int kept = 0;
+ int err = 0;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->filter, sizeof(buf));
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+
+ result = kunit_filter_attr_tests(&suite, filter, NULL, &err);
+ KUNIT_ASSERT_EQ(test, err, 0);
+
+ if (!param->expected) {
+ KUNIT_EXPECT_NULL(test, result);
+ return;
+ }
+
+ KUNIT_ASSERT_NOT_NULL(test, result);
+ KUNIT_EXPECT_EQ(test, kunit_suite_num_test_cases(result),
+ (size_t)count_bits(param->expected));
+
+ for (i = 0; i < 2; i++) {
+ if (!(param->expected & (1 << i)))
+ continue;
+ KUNIT_EXPECT_STREQ(test, result->test_cases[kept++].name, cases[i].name);
+ }
+
+ free_filtered_suite(result);
+}
+
+struct module_case {
+ const char *filter;
+ const char *case_module[2];
+ int expected;
+};
+
+static const struct module_case module_cases[] = {
+ { "module=foo", { "foo", "foo" }, 2 },
+ { "module=bar", { "foo", "foo" }, 0 },
+ { "module=foo", { "foo", "bar" }, 1 },
+ { "module=foo", { "foo", NULL }, 2 }, /* suite value fallback */
+ { "module=foo", { NULL, NULL }, 0 }, /* default value fallback */
+};
+
+static void module_desc(const struct module_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->filter);
+}
+
+KUNIT_ARRAY_PARAM(module, module_cases, module_desc);
+
+static void filter_module_test(struct kunit *test)
+{
+ const struct module_case *param = test->param_value;
+ struct kunit_case cases[] = {
+ { .name = "case0", .run_case = dummy_test,
+ .module_name = (char *)param->case_module[0] },
+ { .name = "case1", .run_case = dummy_test,
+ .module_name = (char *)param->case_module[1] },
+ {}
+ };
+ struct kunit_suite suite = { .name = "fake", .test_cases = cases };
+ struct kunit_attr_filter filter;
+ struct kunit_suite *result;
+ char buf[ATTR_BUF_SIZE];
+ int err = 0;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->filter, sizeof(buf));
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+
+ result = kunit_filter_attr_tests(&suite, filter, NULL, &err);
+ KUNIT_ASSERT_EQ(test, err, 0);
+
+ if (!param->expected) {
+ KUNIT_EXPECT_NULL(test, result);
+ return;
+ }
+
+ KUNIT_ASSERT_NOT_NULL(test, result);
+ KUNIT_EXPECT_EQ(test, kunit_suite_num_test_cases(result),
+ (size_t)param->expected);
+
+ free_filtered_suite(result);
+}
+
+struct is_init_case {
+ const char *filter;
+ bool is_init;
+ int expected;
+};
+
+static const struct is_init_case is_init_cases[] = {
+ { "is_init=true", true, 1 },
+ { "is_init=true", false, 0 },
+ { "is_init=false", false, 1 },
+};
+
+static void is_init_desc(const struct is_init_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s (is_init=%s)",
+ param->filter, param->is_init ? "true" : "false");
+}
+
+KUNIT_ARRAY_PARAM(is_init, is_init_cases, is_init_desc);
+
+static void filter_is_init_test(struct kunit *test)
+{
+ const struct is_init_case *param = test->param_value;
+ struct kunit_suite suite = {
+ .name = "fake",
+ .test_cases = plain_cases,
+ .is_init = param->is_init,
+ };
+ struct kunit_attr_filter filter;
+ struct kunit_suite *result;
+ char buf[ATTR_BUF_SIZE];
+ int err = 0;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->filter, sizeof(buf));
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+
+ result = kunit_filter_attr_tests(&suite, filter, NULL, &err);
+ KUNIT_ASSERT_EQ(test, err, 0);
+
+ if (!param->expected) {
+ KUNIT_EXPECT_NULL(test, result);
+ return;
+ }
+
+ KUNIT_ASSERT_NOT_NULL(test, result);
+ KUNIT_EXPECT_EQ(test, kunit_suite_num_test_cases(result), (size_t)1);
+
+ free_filtered_suite(result);
+}
+
+struct invalid_case {
+ const char *filter;
+};
+
+static const struct invalid_case invalid_cases[] = {
+ { "speed=foobar" },
+ { "module<foo" },
+ { "is_init!true" },
+};
+
+static void invalid_desc(const struct invalid_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->filter);
+}
+
+KUNIT_ARRAY_PARAM(invalid, invalid_cases, invalid_desc);
+
+static void filter_invalid_test(struct kunit *test)
+{
+ const struct invalid_case *param = test->param_value;
+ struct kunit_suite suite = { .name = "fake", .test_cases = plain_cases };
+ struct kunit_attr_filter filter;
+ struct kunit_suite *result;
+ char buf[ATTR_BUF_SIZE];
+ int err = 0;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+ strscpy(buf, param->filter, sizeof(buf));
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+
+ result = kunit_filter_attr_tests(&suite, filter, NULL, &err);
+ KUNIT_EXPECT_EQ(test, err, -EINVAL);
+ KUNIT_EXPECT_NULL(test, result);
+}
+
+static void filter_action_skip_test(struct kunit *test)
+{
+ struct kunit_case cases[] = {
+ { .name = "slow", .run_case = dummy_test, .attr.speed = KUNIT_SPEED_SLOW },
+ { .name = "normal", .run_case = dummy_test, .attr.speed = KUNIT_SPEED_NORMAL },
+ {}
+ };
+ struct kunit_suite suite = { .name = "fake", .test_cases = cases };
+ struct kunit_attr_filter filter;
+ struct kunit_suite *result;
+ char buf[ATTR_BUF_SIZE];
+ int err = 0;
+
+ strscpy(buf, "speed=slow", sizeof(buf));
+ KUNIT_ASSERT_EQ(test, parse_filter(buf, &filter), 0);
+
+ result = kunit_filter_attr_tests(&suite, filter, "skip", &err);
+ KUNIT_ASSERT_EQ(test, err, 0);
+ KUNIT_ASSERT_NOT_NULL(test, result);
+
+ KUNIT_EXPECT_EQ(test, kunit_suite_num_test_cases(result), (size_t)2);
+ KUNIT_EXPECT_STREQ(test, result->test_cases[0].name, "slow");
+ KUNIT_EXPECT_EQ(test, result->test_cases[0].status, KUNIT_SUCCESS);
+ KUNIT_EXPECT_STREQ(test, result->test_cases[1].name, "normal");
+ KUNIT_EXPECT_EQ(test, result->test_cases[1].status, KUNIT_SKIPPED);
+ KUNIT_EXPECT_EQ(test, cases[1].status, KUNIT_SKIPPED);
+
+ free_filtered_suite(result);
+}
+
+struct print_case {
+ bool is_test;
+};
+
+static const struct print_case print_cases[] = {
+ { true },
+ { false },
+};
+
+static void print_desc(const struct print_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->is_test ? "test case" : "suite");
+}
+
+KUNIT_ARRAY_PARAM(print, print_cases, print_desc);
+
+static void print_attr_test(struct kunit *test)
+{
+ const struct print_case *param = test->param_value;
+
+ KUNIT_ASSERT_NOT_NULL(test, param);
+
+ if (param->is_test) {
+ struct kunit_case test_case = {
+ .name = "fake_case",
+ .run_case = dummy_test,
+ .attr.speed = KUNIT_SPEED_NORMAL,
+ };
+
+ kunit_print_attr(&test_case, true, 0);
+ } else {
+ struct kunit_suite suite = { .name = "fake", .test_cases = plain_cases };
+
+ kunit_print_attr(&suite, false, 0);
+ }
+}
+
+static struct kunit_case attr_test_cases[] = {
+ KUNIT_CASE_PARAM(filter_count_test, count_gen_params),
+ KUNIT_CASE_PARAM(parse_filter_test, parse_gen_params),
+ KUNIT_CASE_PARAM(parse_multiple_test, iterate_gen_params),
+ KUNIT_CASE_PARAM(parse_error_test, parse_error_gen_params),
+ KUNIT_CASE_PARAM(filter_speed_test, speed_gen_params),
+ KUNIT_CASE_PARAM(filter_module_test, module_gen_params),
+ KUNIT_CASE_PARAM(filter_is_init_test, is_init_gen_params),
+ KUNIT_CASE_PARAM(filter_invalid_test, invalid_gen_params),
+ KUNIT_CASE(filter_action_skip_test),
+ KUNIT_CASE_PARAM(print_attr_test, print_gen_params),
+ {}
+};
+
+static struct kunit_suite attr_test_suite = {
+ .name = "kunit-attributes",
+ .test_cases = attr_test_cases,
+};
+
+kunit_test_suite(attr_test_suite);
+
+MODULE_DESCRIPTION("KUnit tests for the test attribute API");
+MODULE_LICENSE("GPL");
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module
2026-12-04 2:57 ` [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module Miao Tianzhong
@ 2026-12-04 5:22 ` Aveline Noir
0 siblings, 0 replies; 6+ messages in thread
From: Aveline Noir @ 2026-12-04 5:22 UTC (permalink / raw)
To: Miao Tianzhong
Cc: brendan.higgins, david, kunit-dev, linux-kernel, linux-kselftest,
raemoar63, stable
Hi Tianzhong,
On Fri, 04 Dec 2026 10:57:21 +0800 Miao Tianzhong wrote:
> A test case that has no module_name (or a suite whose first test case
> has none) produces a NULL attribute value, and attr_string_filter()
> passes it to strcmp(), which dereferences NULL and panics the kernel.
The handshake tests and Rust KUnit tests both leave module_name NULL, so
booting with kunit.filter=module=<name> panics when they are built in.
Maybe worth mentioning in the commit message.
Tests passed on UML with both. Looks good to me.
Reviewed-by: Aveline Noir <jm5905938@gmail.com>
Tested-by: Aveline Noir <jm5905938@gmail.com>
Thanks,
Aveline Noir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma
2026-12-04 2:57 ` [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma Miao Tianzhong
@ 2026-12-04 5:27 ` Aveline Noir
0 siblings, 0 replies; 6+ messages in thread
From: Aveline Noir @ 2026-12-04 5:27 UTC (permalink / raw)
To: Miao Tianzhong
Cc: brendan.higgins, david, kunit-dev, linux-kernel, linux-kselftest,
raemoar63, stable
Hi Tianzhong,
On Fri, 04 Dec 2026 10:57:20 +0800 Miao Tianzhong wrote:
> kunit.filter_attr= takes a comma separated list of attribute filters.
The parameter is kunit.filter=, same in the cover letter.
> Cc: stable@vger.kernel.org
Applying the same filter twice gives the same result, so this probably
doesn't need stable.
> + else
> + input = NULL;
kunit_filter_suites() keeps parsing after an error, so kunit.filter=speed,=
now passes NULL to kunit_next_attr_filter() and panics. It returned -EINVAL
before. Maybe stop that loop on the first error?
Thanks,
Aveline Noir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] kunit: add tests for the test attribute API
2026-12-04 2:57 ` [PATCH 3/3] kunit: add tests for the test attribute API Miao Tianzhong
@ 2026-12-04 5:32 ` Aveline Noir
0 siblings, 0 replies; 6+ messages in thread
From: Aveline Noir @ 2026-12-04 5:32 UTC (permalink / raw)
To: Miao Tianzhong
Cc: brendan.higgins, david, kunit-dev, linux-kernel, linux-kselftest,
raemoar63
Hi Tianzhong,
On Fri, 04 Dec 2026 10:57:22 +0800 Miao Tianzhong wrote:
> +static int count_bits(int mask)
hweight32() already does this.
> + { ",", 0 },
kunit.filter=, used to fail with -EINVAL, and now it runs every test. Is
that intended?
> +static void module_desc(const struct module_case *param, char *desc)
> +{
> + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", param->filter);
> +}
Four of these cases are named module=foo, so a failure doesn't show which
one it was. Same for some of the speed ones.
> + kunit_print_attr(&suite, false, 0);
This prints nothing, since no attribute is set on the suite, and the test
has no expectations either. Maybe check the output, or drop it?
Thanks,
Aveline Noir
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-04 5:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1796351229.git.3514767322@qq.com>
2026-12-04 2:57 ` [PATCH 1/3] kunit: fix filter attribute list parsing with a trailing comma Miao Tianzhong
2026-12-04 5:27 ` Aveline Noir
2026-12-04 2:57 ` [PATCH 2/3] kunit: fix NULL pointer dereference when filtering on module Miao Tianzhong
2026-12-04 5:22 ` Aveline Noir
2026-12-04 2:57 ` [PATCH 3/3] kunit: add tests for the test attribute API Miao Tianzhong
2026-12-04 5:32 ` Aveline Noir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®