github.com/cilium/cilium@v1.16.2/bpf/tests/jhash_test.c (about) 1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 /* Copyright Authors of Cilium */ 3 4 #include "common.h" 5 6 #include <bpf/ctx/xdp.h> 7 #include <lib/jhash.h> 8 #include "bpf/section.h" 9 10 CHECK("xdp", "jhash") 11 int bpf_test(__maybe_unused struct xdp_md *ctx) 12 { 13 test_init(); 14 15 TEST("Non-zero", { 16 unsigned int hash = jhash_3words(123, 234, 345, 456); 17 18 if (hash != 2698615579) 19 test_fatal("expected '2698615579' got '%lu'", hash); 20 }); 21 22 TEST("Zero", { 23 unsigned int hash = jhash_3words(0, 0, 0, 0); 24 25 if (hash != 459859287) 26 test_fatal("expected '459859287' got '%lu'", hash); 27 }); 28 29 test_finish(); 30 } 31 32 BPF_LICENSE("Dual BSD/GPL");