WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / prog_tests / hash_large_key.c
blob34684c0fc76d3eb81cf7d5ca5cc32cd71a7d4d37
1 // SPDX-License-Identifier: GPL-2.0
3 #include <test_progs.h>
4 #include "test_hash_large_key.skel.h"
6 void test_hash_large_key(void)
8 int err, value = 21, duration = 0, hash_map_fd;
9 struct test_hash_large_key *skel;
11 struct bigelement {
12 int a;
13 char b[4096];
14 long long c;
15 } key;
16 bzero(&key, sizeof(key));
18 skel = test_hash_large_key__open_and_load();
19 if (CHECK(!skel, "skel_open_and_load", "skeleton open/load failed\n"))
20 return;
22 hash_map_fd = bpf_map__fd(skel->maps.hash_map);
23 if (CHECK(hash_map_fd < 0, "bpf_map__fd", "failed\n"))
24 goto cleanup;
26 err = test_hash_large_key__attach(skel);
27 if (CHECK(err, "attach_raw_tp", "err %d\n", err))
28 goto cleanup;
30 err = bpf_map_update_elem(hash_map_fd, &key, &value, BPF_ANY);
31 if (CHECK(err, "bpf_map_update_elem", "errno=%d\n", errno))
32 goto cleanup;
34 key.c = 1;
35 err = bpf_map_lookup_elem(hash_map_fd, &key, &value);
36 if (CHECK(err, "bpf_map_lookup_elem", "errno=%d\n", errno))
37 goto cleanup;
39 CHECK_FAIL(value != 42);
41 cleanup:
42 test_hash_large_key__destroy(skel);