tools/testing/selftests/bpf/prog_tests/lookup_and_delete.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/lookup_and_delete.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/lookup_and_delete.c
Extension
.c
Size
7373 bytes
Lines
292
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (val) {
			if (CHECK(val != NEW_VALUE, "map value",
				  "unexpected for cpu %d: %lld\n", i, val))
				goto cleanup;
			cpucnt++;
		}
	}
	if (CHECK(cpucnt != 1, "map value", "set for %d CPUs instead of 1!\n",
		  cpucnt))
		goto cleanup;

	/* Check that entries 3 and 1 are non existent. */
	err = bpf_map_lookup_elem(map_fd, &key, &value);
	if (!ASSERT_ERR(err, "bpf_map_lookup_elem"))
		goto cleanup;

	key = 1;
	err = bpf_map_lookup_elem(map_fd, &key, &value);
	if (!ASSERT_ERR(err, "bpf_map_lookup_elem"))
		goto cleanup;

cleanup:
	test_lookup_and_delete__destroy(skel);
}

void test_lookup_and_delete(void)
{
	nr_cpus = bpf_num_possible_cpus();

	if (test__start_subtest("lookup_and_delete"))
		test_lookup_and_delete_hash();
	if (test__start_subtest("lookup_and_delete_percpu"))
		test_lookup_and_delete_percpu_hash();
	if (test__start_subtest("lookup_and_delete_lru"))
		test_lookup_and_delete_lru_hash();
	if (test__start_subtest("lookup_and_delete_lru_percpu"))
		test_lookup_and_delete_lru_percpu_hash();
}

Annotation

Implementation Notes