hash_large_key.c (1038B)
1// SPDX-License-Identifier: GPL-2.0 2 3#include <test_progs.h> 4#include "test_hash_large_key.skel.h" 5 6void test_hash_large_key(void) 7{ 8 int err, value = 21, duration = 0, hash_map_fd; 9 struct test_hash_large_key *skel; 10 11 struct bigelement { 12 int a; 13 char b[4096]; 14 long long c; 15 } key; 16 bzero(&key, sizeof(key)); 17 18 skel = test_hash_large_key__open_and_load(); 19 if (CHECK(!skel, "skel_open_and_load", "skeleton open/load failed\n")) 20 return; 21 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; 25 26 err = test_hash_large_key__attach(skel); 27 if (CHECK(err, "attach_raw_tp", "err %d\n", err)) 28 goto cleanup; 29 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; 33 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; 38 39 CHECK_FAIL(value != 42); 40 41cleanup: 42 test_hash_large_key__destroy(skel); 43}