Commit 7bc7d838 authored by Daniel Borkmann's avatar Daniel Borkmann
Browse files

Merge branch 'bpf-misc-test-fixes'



Stanislav Fomichev says:

====================
* add test__skip to indicate skipped tests
* remove global success/error counts (use environment)
* remove asserts from the tests
* remove unused ret from send_signal test

v3:
* QCHECK -> CHECK_FAIL (Daniel Borkmann)

v2:
* drop patch that changes output to keep consistent with test_verifier
  (Alexei Starovoitov)
* QCHECK instead of test__fail (Andrii Nakryiko)
* test__skip count number of subtests (Andrii Nakryiko)
====================

Cc: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parents 08eea4f3 86ccc384
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -48,16 +48,17 @@ void test_bpf_obj_id(void)
		/* test_obj_id.o is a dumb prog. It should never fail
		 * to load.
		 */
		if (err)
			error_cnt++;
		assert(!err);
		if (CHECK_FAIL(err))
			continue;

		/* Insert a magic value to the map */
		map_fds[i] = bpf_find_map(__func__, objs[i], "test_map_id");
		assert(map_fds[i] >= 0);
		if (CHECK_FAIL(map_fds[i] < 0))
			goto done;
		err = bpf_map_update_elem(map_fds[i], &array_key,
					  &array_magic_value, 0);
		assert(!err);
		if (CHECK_FAIL(err))
			goto done;

		/* Check getting map info */
		info_len = sizeof(struct bpf_map_info) * 2;
@@ -96,9 +97,11 @@ void test_bpf_obj_id(void)
		prog_infos[i].map_ids = ptr_to_u64(map_ids + i);
		prog_infos[i].nr_map_ids = 2;
		err = clock_gettime(CLOCK_REALTIME, &real_time_ts);
		assert(!err);
		if (CHECK_FAIL(err))
			goto done;
		err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts);
		assert(!err);
		if (CHECK_FAIL(err))
			goto done;
		err = bpf_obj_get_info_by_fd(prog_fds[i], &prog_infos[i],
					     &info_len);
		load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec)
@@ -224,7 +227,8 @@ void test_bpf_obj_id(void)
		nr_id_found++;

		err = bpf_map_lookup_elem(map_fd, &array_key, &array_value);
		assert(!err);
		if (CHECK_FAIL(err))
			goto done;

		err = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len);
		CHECK(err || info_len != sizeof(struct bpf_map_info) ||
+1 −8
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ static int check_load(const char *file, enum bpf_prog_type type)
	attr.prog_flags = BPF_F_TEST_RND_HI32;
	err = bpf_prog_load_xattr(&attr, &obj, &prog_fd);
	bpf_object__close(obj);
	if (err)
		error_cnt++;
	return err;
}

@@ -105,12 +103,7 @@ void test_bpf_verif_scale(void)
			continue;

		err = check_load(test->file, test->attach_type);
		if (test->fails) { /* expected to fail */
			if (err)
				error_cnt--;
			else
				error_cnt++;
		}
		CHECK_FAIL(err && !test->fails);
	}

	if (env.verifier_stats)
+1 −3
Original line number Diff line number Diff line
@@ -452,10 +452,8 @@ void test_flow_dissector(void)

	err = bpf_flow_load(&obj, "./bpf_flow.o", "flow_dissector",
			    "jmp_table", "last_dissection", &prog_fd, &keys_fd);
	if (err) {
		error_cnt++;
	if (CHECK_FAIL(err))
		return;
	}

	for (i = 0; i < ARRAY_SIZE(tests); i++) {
		struct bpf_flow_keys flow_keys;
+0 −3
Original line number Diff line number Diff line
@@ -135,10 +135,7 @@ void test_get_stack_raw_tp(void)
		exp_cnt -= err;
	}

	goto close_prog_noerr;
close_prog:
	error_cnt++;
close_prog_noerr:
	if (!IS_ERR_OR_NULL(link))
		bpf_link__destroy(link);
	if (!IS_ERR_OR_NULL(pb))
+5 −15
Original line number Diff line number Diff line
@@ -7,10 +7,8 @@ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
	uint64_t num;

	map_fd = bpf_find_map(__func__, obj, "result_number");
	if (map_fd < 0) {
		error_cnt++;
	if (CHECK_FAIL(map_fd < 0))
		return;
	}

	struct {
		char *name;
@@ -44,10 +42,8 @@ static void test_global_data_string(struct bpf_object *obj, __u32 duration)
	char str[32];

	map_fd = bpf_find_map(__func__, obj, "result_string");
	if (map_fd < 0) {
		error_cnt++;
	if (CHECK_FAIL(map_fd < 0))
		return;
	}

	struct {
		char *name;
@@ -81,10 +77,8 @@ static void test_global_data_struct(struct bpf_object *obj, __u32 duration)
	struct foo val;

	map_fd = bpf_find_map(__func__, obj, "result_struct");
	if (map_fd < 0) {
		error_cnt++;
	if (CHECK_FAIL(map_fd < 0))
		return;
	}

	struct {
		char *name;
@@ -112,16 +106,12 @@ static void test_global_data_rdonly(struct bpf_object *obj, __u32 duration)
	__u8 *buff;

	map = bpf_object__find_map_by_name(obj, "test_glo.rodata");
	if (!map || !bpf_map__is_internal(map)) {
		error_cnt++;
	if (CHECK_FAIL(!map || !bpf_map__is_internal(map)))
		return;
	}

	map_fd = bpf_map__fd(map);
	if (map_fd < 0) {
		error_cnt++;
	if (CHECK_FAIL(map_fd < 0))
		return;
	}

	buff = malloc(bpf_map__def(map)->value_size);
	if (buff)
Loading