diff mbox series

bpf/tests: Enhance output on error and fix typos

Message ID ZN6ZAAVoWZpsD1Jf@p100 (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series bpf/tests: Enhance output on error and fix typos | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-PR success PR summary
bpf/vmtest-bpf-VM_Test-3 pending Logs for build for s390x with gcc
bpf/vmtest-bpf-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-VM_Test-2 success Logs for build for aarch64 with gcc

Commit Message

Helge Deller Aug. 17, 2023, 10:02 p.m. UTC
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 <deller@gmx.de>

---

Comments

Daniel Borkmann Aug. 18, 2023, 3:18 p.m. UTC | #1
On 8/18/23 12:02 AM, Helge Deller wrote:
> 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 <deller@gmx.de>
> 
> ---
> 
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index fa0833410ac1..2c01932524b3 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -596,8 +596,8 @@ static int __bpf_fill_alu_shift(struct bpf_test *self, u8 op,
>   {
>   	static const s64 regs[] = {
>   		0x0123456789abcdefLL, /* dword > 0, word < 0 */
> -		0xfedcba9876543210LL, /* dowrd < 0, word > 0 */
> -		0xfedcba0198765432LL, /* dowrd < 0, word < 0 */
> +		0xfedcba9876543210LL, /* dword < 0, word > 0 */
> +		0xfedcba0198765432LL, /* dword < 0, word < 0 */
>   		0x0123458967abcdefLL, /* dword > 0, word > 0 */
>   	};
>   	int bits = alu32 ? 32 : 64;
> @@ -14577,8 +14577,9 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
>   		if (ret == test->test[i].result) {
>   			pr_cont("%lld ", duration);
>   		} else {
> -			pr_cont("ret %d != %d ", ret,
> -				test->test[i].result);
> +			s32 res = test->test[i].result;

Added a newline in here while applying to bpf-next, thanks for the patch!

> +			pr_cont("ret %d != %d (%#x != %#x)",
> +				ret, res, ret, res);
>   			err_cnt++;
>   		}
>   	}
> @@ -15055,7 +15056,7 @@ static __init int prepare_tail_call_tests(struct bpf_array **pprogs)
>   	struct bpf_array *progs;
>   	int which, err;
>   
> -	/* Allocate the table of programs to be used for tall calls */
> +	/* Allocate the table of programs to be used for tail calls */
>   	progs = kzalloc(struct_size(progs, ptrs, ntests + 1), GFP_KERNEL);
>   	if (!progs)
>   		goto out_nomem;
>
diff mbox series

Patch

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index fa0833410ac1..2c01932524b3 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -596,8 +596,8 @@  static int __bpf_fill_alu_shift(struct bpf_test *self, u8 op,
 {
 	static const s64 regs[] = {
 		0x0123456789abcdefLL, /* dword > 0, word < 0 */
-		0xfedcba9876543210LL, /* dowrd < 0, word > 0 */
-		0xfedcba0198765432LL, /* dowrd < 0, word < 0 */
+		0xfedcba9876543210LL, /* dword < 0, word > 0 */
+		0xfedcba0198765432LL, /* dword < 0, word < 0 */
 		0x0123458967abcdefLL, /* dword > 0, word > 0 */
 	};
 	int bits = alu32 ? 32 : 64;
@@ -14577,8 +14577,9 @@  static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
 		if (ret == test->test[i].result) {
 			pr_cont("%lld ", duration);
 		} else {
-			pr_cont("ret %d != %d ", ret,
-				test->test[i].result);
+			s32 res = test->test[i].result;
+			pr_cont("ret %d != %d (%#x != %#x)",
+				ret, res, ret, res);
 			err_cnt++;
 		}
 	}
@@ -15055,7 +15056,7 @@  static __init int prepare_tail_call_tests(struct bpf_array **pprogs)
 	struct bpf_array *progs;
 	int which, err;
 
-	/* Allocate the table of programs to be used for tall calls */
+	/* Allocate the table of programs to be used for tail calls */
 	progs = kzalloc(struct_size(progs, ptrs, ntests + 1), GFP_KERNEL);
 	if (!progs)
 		goto out_nomem;