Commit 682cdbdc authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'test_progs-stdio'



Stanislav Fomichev says:

====================
I was looking into converting test_sockops* to test_progs framework
and that requires using cgroup_helpers.c which rely on stdio/stderr.
Let's use open_memstream to override stdout into buffer during
subtests instead of custom test_{v,}printf wrappers. That lets
us continue to use stdio in the subtests and dump it on failure
if required.

That would also fix bpf_find_map which currently uses printf to
signal failure (missed during test_printf conversion).
====================

Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 8c303960 16e910d4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,13 +5,13 @@ static int libbpf_debug_print(enum libbpf_print_level level,
			      const char *format, va_list args)
{
	if (level != LIBBPF_DEBUG) {
		test__vprintf(format, args);
		vprintf(format, args);
		return 0;
	}

	if (!strstr(format, "verifier log"))
		return 0;
	test__vprintf("%s", args);
	vprintf("%s", args);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ static void test_l4lb(const char *file)
	}
	if (bytes != MAGIC_BYTES * NUM_ITER * 2 || pkts != NUM_ITER * 2) {
		error_cnt++;
		test__printf("test_l4lb:FAIL:stats %lld %lld\n", bytes, pkts);
		printf("test_l4lb:FAIL:stats %lld %lld\n", bytes, pkts);
	}
out:
	bpf_object__close(obj);
+5 −5
Original line number Diff line number Diff line
@@ -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) {
			test__printf("lookup failed\n");
			printf("lookup failed\n");
			error_cnt++;
			goto out;
		}
		if (vars[0] != 0) {
			test__printf("lookup #%d var[0]=%d\n", i, vars[0]);
			printf("lookup #%d var[0]=%d\n", i, vars[0]);
			error_cnt++;
			goto out;
		}
@@ -22,7 +22,7 @@ static void *parallel_map_access(void *arg)
		for (j = 2; j < 17; j++) {
			if (vars[j] == rnd)
				continue;
			test__printf("lookup #%d var[1]=%d var[%d]=%d\n",
			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) {
		test__printf("test_map_lock:bpf_prog_load errno %d\n", errno);
		printf("test_map_lock:bpf_prog_load errno %d\n", errno);
		goto close_prog;
	}
	map_fd[0] = bpf_find_map(__func__, obj, "hash_map");
+2 −2
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ static int test_send_signal_nmi(void)
			 -1 /* cpu */, -1 /* group_fd */, 0 /* flags */);
	if (pmu_fd == -1) {
		if (errno == ENOENT) {
			test__printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n",
			printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n",
			       __func__);
			return 0;
		}
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ void test_spinlock(void)

	err = bpf_prog_load(file, BPF_PROG_TYPE_CGROUP_SKB, &obj, &prog_fd);
	if (err) {
		test__printf("test_spin_lock:bpf_prog_load errno %d\n", errno);
		printf("test_spin_lock:bpf_prog_load errno %d\n", errno);
		goto close_prog;
	}
	for (i = 0; i < 4; i++)
Loading