Patch "bpf/tests: Do not PASS tests without actually testing the result" has been added to the 4.19-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

    bpf/tests: Do not PASS tests without actually testing the result

to the 4.19-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:
     bpf-tests-do-not-pass-tests-without-actually-testing.patch
and it can be found in the queue-4.19 subdirectory.

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



commit 13ec889013a6b7a98f59fc532f3d4d9081894b8f
Author: Johan Almbladh <johan.almbladh@xxxxxxxxxxxxxxxxx>
Date:   Wed Jul 21 12:38:22 2021 +0200

    bpf/tests: Do not PASS tests without actually testing the result
    
    [ Upstream commit 2b7e9f25e590726cca76700ebdb10e92a7a72ca1 ]
    
    Each test case can have a set of sub-tests, where each sub-test can
    run the cBPF/eBPF test snippet with its own data_size and expected
    result. Before, the end of the sub-test array was indicated by both
    data_size and result being zero. However, most or all of the internal
    eBPF tests has a data_size of zero already. When such a test also had
    an expected value of zero, the test was never run but reported as
    PASS anyway.
    
    Now the test runner always runs the first sub-test, regardless of the
    data_size and result values. The sub-test array zero-termination only
    applies for any additional sub-tests.
    
    There are other ways fix it of course, but this solution at least
    removes the surprise of eBPF tests with a zero result always succeeding.
    
    Signed-off-by: Johan Almbladh <johan.almbladh@xxxxxxxxxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20210721103822.3755111-1-johan.almbladh@xxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 98074a3bc161..49d79079e8b3 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -6687,7 +6687,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
 		u64 duration;
 		u32 ret;
 
-		if (test->test[i].data_size == 0 &&
+		/*
+		 * NOTE: Several sub-tests may be present, in which case
+		 * a zero {data_size, result} tuple indicates the end of
+		 * the sub-test array. The first test is always run,
+		 * even if both data_size and result happen to be zero.
+		 */
+		if (i > 0 &&
+		    test->test[i].data_size == 0 &&
 		    test->test[i].result == 0)
 			break;
 



[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