We have started printing more and more intentional stack traces. Whether it's testing KASAN is able to detect use after frees or it's part of a kunit test. These stack traces can be problematic. They suddenly show up as a new failure. Now the test team has to contact the developers. A bunch of people have to investigate the bug. We finally decide that it's intentional so now the test team has to update their filter scripts to mark it as intentional. These filters are ad-hoc because there is no standard format for warnings. A better way would be to mark it as intentional from the start. Here, I have marked the beginning and the end of the trace. It's more tricky for things like lkdtm_FORTIFY_MEM_MEMBER() where the flow doesn't reach the end of the function. I guess I would print a different warning for stack traces that can't have a "Intentional warning finished\n" message at the end. I haven't actually tested this patch... Daniel, do you have a list of intentional stack traces we could annotate? Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> --- drivers/gpu/drm/tests/drm_rect_test.c | 2 ++ include/kunit/test.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 76332cd2ead8..367738254493 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -409,8 +409,10 @@ static void drm_test_rect_calc_hscale(struct kunit *test) const struct drm_rect_scale_case *params = test->param_value; int scaling_factor; + START_INTENTIONAL_WARNING(); scaling_factor = drm_rect_calc_hscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + END_INTENTIONAL_WARNING(); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } diff --git a/include/kunit/test.h b/include/kunit/test.h index 20ed9f9275c9..1f01d4c81055 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -337,6 +337,9 @@ void __kunit_test_suites_exit(struct kunit_suite **suites, int num_suites); void kunit_exec_run_tests(struct kunit_suite_set *suite_set, bool builtin); void kunit_exec_list_tests(struct kunit_suite_set *suite_set, bool include_attr); +#define START_INTENTIONAL_WARNING() pr_info("Triggering a stack trace\n") +#define END_INTENTIONAL_WARNING() pr_info("Intentional warning finished\n") + #if IS_BUILTIN(CONFIG_KUNIT) int kunit_run_all_tests(void); #else -- 2.42.0