Patch "kunit: Reset test->priv after each param iteration" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kunit: Reset test->priv after each param iteration

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kunit-reset-test-priv-after-each-param-iteration.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0d4f466a6dae533c9c5aeffdf39b3d54662c1719
Author: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
Date:   Fri Dec 15 16:13:27 2023 +0100

    kunit: Reset test->priv after each param iteration
    
    [ Upstream commit 342fb9789267ee3908959bfa136b82e88e2ce918 ]
    
    If we run parameterized test that uses test->priv to prepare some
    custom data, then value of test->priv will leak to the next param
    iteration and may be unexpected.  This could be easily seen if
    we promote example_priv_test to parameterized test as then only
    first test iteration will be successful:
    
    $ ./tools/testing/kunit/kunit.py run \
            --kunitconfig ./lib/kunit/.kunitconfig *.example_priv*
    
    [ ] Starting KUnit Kernel (1/1)...
    [ ] ============================================================
    [ ] =================== example (1 subtest) ====================
    [ ] ==================== example_priv_test  ====================
    [ ] [PASSED] example value 3
    [ ] # example_priv_test: initializing
    [ ] # example_priv_test: ASSERTION FAILED at lib/kunit/kunit-example-test.c:230
    [ ] Expected test->priv == ((void *)0), but
    [ ]     test->priv == 0000000060dfe290
    [ ]     ((void *)0) == 0000000000000000
    [ ] # example_priv_test: cleaning up
    [ ] [FAILED] example value 2
    [ ] # example_priv_test: initializing
    [ ] # example_priv_test: ASSERTION FAILED at lib/kunit/kunit-example-test.c:230
    [ ] Expected test->priv == ((void *)0), but
    [ ]     test->priv == 0000000060dfe290
    [ ]     ((void *)0) == 0000000000000000
    [ ] # example_priv_test: cleaning up
    [ ] [FAILED] example value 1
    [ ] # example_priv_test: initializing
    [ ] # example_priv_test: ASSERTION FAILED at lib/kunit/kunit-example-test.c:230
    [ ] Expected test->priv == ((void *)0), but
    [ ]     test->priv == 0000000060dfe290
    [ ]     ((void *)0) == 0000000000000000
    [ ] # example_priv_test: cleaning up
    [ ] [FAILED] example value 0
    [ ] # example_priv_test: initializing
    [ ] # example_priv_test: cleaning up
    [ ] # example_priv_test: pass:1 fail:3 skip:0 total:4
    [ ] ================ [FAILED] example_priv_test ================
    [ ]     # example: initializing suite
    [ ]     # module: kunit_example_test
    [ ]     # example: exiting suite
    [ ] # Totals: pass:1 fail:3 skip:0 total:4
    [ ] ===================== [FAILED] example =====================
    
    Fix that by resetting test->priv after each param iteration, in
    similar way what we did for the test->status.
    
    Signed-off-by: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
    Cc: David Gow <davidgow@xxxxxxxxxx>
    Cc: Rae Moar <rmoar@xxxxxxxxxx>
    Reviewed-by: David Gow <davidgow@xxxxxxxxxx>
    Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 7aceb07a1af9..1cdc405daa30 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -660,6 +660,7 @@ int kunit_run_tests(struct kunit_suite *suite)
 				test.param_index++;
 				test.status = KUNIT_SUCCESS;
 				test.status_comment[0] = '\0';
+				test.priv = NULL;
 			}
 		}
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux