Skip to content

Commit b6594a1

Browse files
hdellerborkmann
authored andcommitted
bpf/tests: Enhance output on error and fix typos
If a testcase returns a wrong (unexpected) value, print the expected and returned value in hex notation in addition to the decimal notation. This is very useful in tests which bit-shift hex values left or right and helped me a lot while developing the JIT compiler for the hppa architecture. Additionally fix two typos: dowrd -> dword, tall calls -> tail calls. Signed-off-by: Helge Deller <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/ZN6ZAAVoWZpsD1Jf@p100
1 parent 6c77997 commit b6594a1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/test_bpf.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ static int __bpf_fill_alu_shift(struct bpf_test *self, u8 op,
596596
{
597597
static const s64 regs[] = {
598598
0x0123456789abcdefLL, /* dword > 0, word < 0 */
599-
0xfedcba9876543210LL, /* dowrd < 0, word > 0 */
600-
0xfedcba0198765432LL, /* dowrd < 0, word < 0 */
599+
0xfedcba9876543210LL, /* dword < 0, word > 0 */
600+
0xfedcba0198765432LL, /* dword < 0, word < 0 */
601601
0x0123458967abcdefLL, /* dword > 0, word > 0 */
602602
};
603603
int bits = alu32 ? 32 : 64;
@@ -14567,8 +14567,10 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
1456714567
if (ret == test->test[i].result) {
1456814568
pr_cont("%lld ", duration);
1456914569
} else {
14570-
pr_cont("ret %d != %d ", ret,
14571-
test->test[i].result);
14570+
s32 res = test->test[i].result;
14571+
14572+
pr_cont("ret %d != %d (%#x != %#x)",
14573+
ret, res, ret, res);
1457214574
err_cnt++;
1457314575
}
1457414576
}
@@ -15045,7 +15047,7 @@ static __init int prepare_tail_call_tests(struct bpf_array **pprogs)
1504515047
struct bpf_array *progs;
1504615048
int which, err;
1504715049

15048-
/* Allocate the table of programs to be used for tall calls */
15050+
/* Allocate the table of programs to be used for tail calls */
1504915051
progs = kzalloc(struct_size(progs, ptrs, ntests + 1), GFP_KERNEL);
1505015052
if (!progs)
1505115053
goto out_nomem;

0 commit comments

Comments
 (0)