Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
ac91576
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
accounting
arch
bpf
build
cgroup
crypto
debugging
firewire
firmware
gpio
hv
iio
include
io_uring
kvm
laptop
leds
lib
memory-model
nfsd
objtool
pci
pcmcia
perf
power
scripts
spi
testing
fault-injection
ktest
nvdimm
radix-tree
scatterlist
selftests
android
bpf
gnu
include
map_tests
prog_tests
progs
verifier
.gitignore
Makefile
bpf_endian.h
bpf_helpers.h
bpf_rand.h
bpf_rlimit.h
bpf_util.h
cgroup_helpers.c
cgroup_helpers.h
config
flow_dissector_load.c
flow_dissector_load.h
get_cgroup_id_user.c
netcnt_common.h
tcp_client.py
tcp_server.py
test_align.c
test_bpftool_build.sh
test_btf.c
test_btf.h
test_btf_dump.c
test_cgroup_attach.c
test_cgroup_storage.c
test_dev_cgroup.c
test_flow_dissector.c
test_flow_dissector.sh
test_hashmap.c
test_iptunnel_common.h
test_kmod.sh
test_libbpf.sh
test_libbpf_open.c
test_lirc_mode2.sh
test_lirc_mode2_user.c
test_lpm_map.c
test_lru_map.c
test_lwt_ip_encap.sh
test_lwt_seg6local.sh
test_maps.c
test_maps.h
test_netcnt.c
test_offload.py
test_progs.c
test_progs.h
test_queue_stack_map.h
test_section_names.c
test_select_reuseport.c
test_select_reuseport_common.h
test_skb_cgroup_id.sh
test_skb_cgroup_id_user.c
test_sock.c
test_sock_addr.c
test_sock_addr.sh
test_sock_fields.c
test_socket_cookie.c
test_sockmap.c
test_sockmap_kern.h
test_sockopt.c
test_sockopt_inherit.c
test_sockopt_multi.c
test_sockopt_sk.c
test_stub.c
test_sysctl.c
test_tag.c
test_tc_edt.sh
test_tc_tunnel.sh
test_tcp_check_syncookie.sh
test_tcp_check_syncookie_user.c
test_tcp_rtt.c
test_tcpbpf.h
test_tcpbpf_user.c
test_tcpnotify.h
test_tcpnotify_user.c
test_tunnel.sh
test_verifier.c
test_verifier_log.c
test_xdp_meta.sh
test_xdp_redirect.sh
test_xdp_veth.sh
test_xdp_vlan.sh
test_xdp_vlan_mode_generic.sh
test_xdp_vlan_mode_native.sh
test_xdping.sh
trace_helpers.c
trace_helpers.h
urandom_read.c
with_addr.sh
with_tunnels.sh
xdping.c
xdping.h
breakpoints
capabilities
cgroup
cpu-hotplug
cpufreq
drivers
efivarfs
exec
filesystems
firmware
ftrace
futex
gpio
ia64
intel_pstate
ipc
ir
kcmp
kexec
kmod
kselftest
kvm
lib
livepatch
locking
media_tests
membarrier
memfd
memory-hotplug
mount
mqueue
net
netfilter
networking
nsfs
ntb
pidfd
powerpc
prctl
proc
pstore
ptp
ptrace
rcutorture
rseq
rtc
safesetid
seccomp
sigaltstack
size
sparc64
splice
static_keys
sync
sysctl
tc-testing
timers
tmpfs
tpm2
uevent
user
vDSO
vm
watchdog
x86
zram
.gitignore
Makefile
gen_kselftest_tar.sh
kselftest.h
kselftest_harness.h
kselftest_install.sh
kselftest_module.h
kselftest_module.sh
lib.mk
vsock
thermal
time
usb
virtio
vm
wmi
Makefile
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
test_progs.h
Copy path
Blame
Blame
Latest commit
Stanislav Fomichev
and
Daniel Borkmann
selftests/bpf: test_progs: add missing \n to CHECK_FAIL
Sep 3, 2019
ac91576
·
Sep 3, 2019
History
History
141 lines (121 loc) · 3.18 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
test_progs.h
Top
File metadata and controls
Code
Blame
141 lines (121 loc) · 3.18 KB
Raw
/* SPDX-License-Identifier: GPL-2.0 */ #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <assert.h> #include <stdlib.h> #include <stdarg.h> #include <time.h> #include <signal.h> #include <linux/types.h> typedef __u16 __sum16; #include <arpa/inet.h> #include <linux/if_ether.h> #include <linux/if_packet.h> #include <linux/ip.h> #include <linux/ipv6.h> #include <linux/tcp.h> #include <linux/filter.h> #include <linux/perf_event.h> #include <linux/unistd.h> #include <sys/ioctl.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/time.h> #include <fcntl.h> #include <pthread.h> #include <linux/bpf.h> #include <linux/err.h> #include <bpf/bpf.h> #include <bpf/libbpf.h> #include "test_iptunnel_common.h" #include "bpf_util.h" #include "bpf_endian.h" #include "trace_helpers.h" #include "flow_dissector_load.h" struct test_selector { const char *name; bool *num_set; int num_set_len; }; struct test_env { struct test_selector test_selector; struct test_selector subtest_selector; bool verifier_stats; bool verbose; bool very_verbose; bool jit_enabled; struct prog_test_def *test; FILE *stdout; FILE *stderr; char *log_buf; size_t log_cnt; int succ_cnt; /* successful tests */ int sub_succ_cnt; /* successful sub-tests */ int fail_cnt; /* total failed tests + sub-tests */ int skip_cnt; /* skipped tests */ }; extern struct test_env env; extern void test__force_log(); extern bool test__start_subtest(const char *name); extern void test__skip(void); extern void test__fail(void); #define MAGIC_BYTES 123 /* ipv4 test vector */ struct ipv4_packet { struct ethhdr eth; struct iphdr iph; struct tcphdr tcp; } __packed; extern struct ipv4_packet pkt_v4; /* ipv6 test vector */ struct ipv6_packet { struct ethhdr eth; struct ipv6hdr iph; struct tcphdr tcp; } __packed; extern struct ipv6_packet pkt_v6; #define _CHECK(condition, tag, duration, format...) ({ \ int __ret = !!(condition); \ if (__ret) { \ test__fail(); \ printf("%s:FAIL:%s ", __func__, tag); \ printf(format); \ } else { \ printf("%s:PASS:%s %d nsec\n", \ __func__, tag, duration); \ } \ __ret; \ }) #define CHECK_FAIL(condition) ({ \ int __ret = !!(condition); \ if (__ret) { \ test__fail(); \ printf("%s:FAIL:%d\n", __func__, __LINE__); \ } \ __ret; \ }) #define CHECK(condition, tag, format...) \ _CHECK(condition, tag, duration, format) #define CHECK_ATTR(condition, tag, format...) \ _CHECK(condition, tag, tattr.duration, format) #define MAGIC_VAL 0x1234 #define NUM_ITER 100000 #define VIP_NUM 5 static inline __u64 ptr_to_u64(const void *ptr) { return (__u64) (unsigned long) ptr; } int bpf_find_map(const char *test, struct bpf_object *obj, const char *name); int compare_map_keys(int map1_fd, int map2_fd); int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len); int extract_build_id(char *build_id, size_t size); void *spin_lock_thread(void *arg); #ifdef __x86_64__ #define SYS_NANOSLEEP_KPROBE_NAME "__x64_sys_nanosleep" #elif defined(__s390x__) #define SYS_NANOSLEEP_KPROBE_NAME "__s390x_sys_nanosleep" #else #define SYS_NANOSLEEP_KPROBE_NAME "sys_nanosleep" #endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
You can’t perform that action at this time.
While the code is focused, press Alt+F1 for a menu of operations.