From 0ff97e56c0986ea6633083c3487d9231bbbd881b Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Sat, 27 Jul 2019 20:25:28 -0700 Subject: selftests/bpf: abstract away test log output This patch changes how test output is printed out. By default, if test had no errors, the only output will be a single line with test number, name, and verdict at the end, e.g.: #31 xdp:OK If test had any errors, all log output captured during test execution will be output after test completes. It's possible to force output of log with `-v` (`--verbose`) option, in which case output won't be buffered and will be output immediately. To support this, individual tests are required to use helper methods for logging: `test__printf()` and `test__vprintf()`. Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/prog_tests/map_lock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tools/testing/selftests/bpf/prog_tests/map_lock.c') diff --git a/tools/testing/selftests/bpf/prog_tests/map_lock.c b/tools/testing/selftests/bpf/prog_tests/map_lock.c index ee99368c595c..2e78217ed3fd 100644 --- a/tools/testing/selftests/bpf/prog_tests/map_lock.c +++ b/tools/testing/selftests/bpf/prog_tests/map_lock.c @@ -9,12 +9,12 @@ static void *parallel_map_access(void *arg) for (i = 0; i < 10000; i++) { err = bpf_map_lookup_elem_flags(map_fd, &key, vars, BPF_F_LOCK); if (err) { - printf("lookup failed\n"); + test__printf("lookup failed\n"); error_cnt++; goto out; } if (vars[0] != 0) { - printf("lookup #%d var[0]=%d\n", i, vars[0]); + test__printf("lookup #%d var[0]=%d\n", i, vars[0]); error_cnt++; goto out; } @@ -22,8 +22,8 @@ static void *parallel_map_access(void *arg) for (j = 2; j < 17; j++) { if (vars[j] == rnd) continue; - printf("lookup #%d var[1]=%d var[%d]=%d\n", - i, rnd, j, vars[j]); + test__printf("lookup #%d var[1]=%d var[%d]=%d\n", + i, rnd, j, vars[j]); error_cnt++; goto out; } @@ -43,7 +43,7 @@ void test_map_lock(void) err = bpf_prog_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd); if (err) { - printf("test_map_lock:bpf_prog_load errno %d\n", errno); + test__printf("test_map_lock:bpf_prog_load errno %d\n", errno); goto close_prog; } map_fd[0] = bpf_find_map(__func__, obj, "hash_map"); -- cgit v1.2.3-59-g8ed1b