0001
0002
0003 #include <test_progs.h>
0004 #include "test_hash_large_key.skel.h"
0005
0006 void test_hash_large_key(void)
0007 {
0008 int err, value = 21, duration = 0, hash_map_fd;
0009 struct test_hash_large_key *skel;
0010
0011 struct bigelement {
0012 int a;
0013 char b[4096];
0014 long long c;
0015 } key;
0016 bzero(&key, sizeof(key));
0017
0018 skel = test_hash_large_key__open_and_load();
0019 if (CHECK(!skel, "skel_open_and_load", "skeleton open/load failed\n"))
0020 return;
0021
0022 hash_map_fd = bpf_map__fd(skel->maps.hash_map);
0023 if (CHECK(hash_map_fd < 0, "bpf_map__fd", "failed\n"))
0024 goto cleanup;
0025
0026 err = test_hash_large_key__attach(skel);
0027 if (CHECK(err, "attach_raw_tp", "err %d\n", err))
0028 goto cleanup;
0029
0030 err = bpf_map_update_elem(hash_map_fd, &key, &value, BPF_ANY);
0031 if (CHECK(err, "bpf_map_update_elem", "errno=%d\n", errno))
0032 goto cleanup;
0033
0034 key.c = 1;
0035 err = bpf_map_lookup_elem(hash_map_fd, &key, &value);
0036 if (CHECK(err, "bpf_map_lookup_elem", "errno=%d\n", errno))
0037 goto cleanup;
0038
0039 CHECK_FAIL(value != 42);
0040
0041 cleanup:
0042 test_hash_large_key__destroy(skel);
0043 }