diff options
| author | Andrii Nakryiko <[email protected]> | 2021-04-26 19:29:45 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2021-04-27 01:37:13 +0000 |
| commit | 7a2fa70aaffc2f8823feca22709a00f5c069a8a9 (patch) | |
| tree | c1b6ec1d78c4d6cdcc24fb8920a97c20393d9a2d /tools/testing/selftests/bpf/prog_tests/snprintf_btf.c | |
| parent | Merge branch 'bpf: Tracing and lsm programs re-attach' (diff) | |
| download | kernel-7a2fa70aaffc2f8823feca22709a00f5c069a8a9.tar.gz kernel-7a2fa70aaffc2f8823feca22709a00f5c069a8a9.zip | |
selftests/bpf: Add remaining ASSERT_xxx() variants
Add ASSERT_TRUE/ASSERT_FALSE for conditions calculated with custom logic to
true/false. Also add remaining arithmetical assertions:
- ASSERT_LE -- less than or equal;
- ASSERT_GT -- greater than;
- ASSERT_GE -- greater than or equal.
This should cover most scenarios where people fall back to error-prone
CHECK()s.
Also extend ASSERT_ERR() to print out errno, in addition to direct error.
Also convert few CHECK() instances to ensure new ASSERT_xxx() variants work as
expected. Subsequent patch will also use ASSERT_TRUE/ASSERT_FALSE more
extensively.
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Lorenz Bauer <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/snprintf_btf.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/snprintf_btf.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/snprintf_btf.c b/tools/testing/selftests/bpf/prog_tests/snprintf_btf.c index 686b40f11a45..76e1f5fe18fa 100644 --- a/tools/testing/selftests/bpf/prog_tests/snprintf_btf.c +++ b/tools/testing/selftests/bpf/prog_tests/snprintf_btf.c @@ -42,9 +42,7 @@ void test_snprintf_btf(void) * and it set expected return values from bpf_trace_printk()s * and all tests ran. */ - if (CHECK(bss->ret <= 0, - "bpf_snprintf_btf: got return value", - "ret <= 0 %ld test %d\n", bss->ret, bss->ran_subtests)) + if (!ASSERT_GT(bss->ret, 0, "bpf_snprintf_ret")) goto cleanup; if (CHECK(bss->ran_subtests == 0, "check if subtests ran", |
