Skip to content

Commit 8080c67

Browse files
Carlos Llamasshuahkh
authored andcommitted
kunit: prevent log overwrite in param_tests
When running parameterized tests, each test case is initialized with kunit_init_test(). This function takes the test_case->log as a parameter but it clears it via string_stream_clear() on each iteration. This results in only the log from the last parameter being preserved in the test_case->log and the results from the previous parameters are lost from the debugfs entry. Fix this by manually setting the param_test.log to the test_case->log after it has been initialized. This prevents kunit_init_test() from clearing the log on each iteration. Link: https://lore.kernel.org/r/[email protected] Fixes: 4b59300 ("kunit: Add parent kunit for parameterized test context") Signed-off-by: Carlos Llamas <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 2551a1e commit 8080c67

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/kunit/test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ int kunit_run_tests(struct kunit_suite *suite)
745745
.param_index = ++test.param_index,
746746
.parent = &test,
747747
};
748-
kunit_init_test(&param_test, test_case->name, test_case->log);
748+
kunit_init_test(&param_test, test_case->name, NULL);
749+
param_test.log = test_case->log;
749750
kunit_run_case_catch_errors(suite, test_case, &param_test);
750751

751752
if (param_desc[0] == '\0') {

0 commit comments

Comments
 (0)