tools/llvm: Do not build with symbols
[minix3.git] / tests / net / bpf / t_div-by-zero.c
blob542d08a793d46f81cd308da50968618b034fcdd6
1 #include <sys/types.h>
2 #include <sys/ioctl.h>
4 #include <net/bpf.h>
6 #include <atf-c.h>
7 #include <fcntl.h>
9 #include <rump/rump.h>
10 #include <rump/rump_syscalls.h>
12 ATF_TC(div_by_zero);
13 ATF_TC_HEAD(div_by_zero, tc)
16 atf_tc_set_md_var(tc, "descr", "Check that BPF rejects a filter "
17 "which divides by 0");
20 ATF_TC_BODY(div_by_zero, tc)
22 struct bpf_program bp;
23 int fd;
26 * Source code for following program:
27 * link[0:4]/0 = 2
29 struct bpf_insn bins[] = {
30 { 0x20, 0, 0, 0x00000000 },
31 { 0x34, 0, 0, 0x00000000 },
32 { 0x15, 0, 1, 0x00000002 },
33 { 0x6, 0, 0, 0x00000060 },
34 { 0x6, 0, 0, 0x00000000 },
37 bp.bf_len = __arraycount(bins);
38 bp.bf_insns = bins;
40 rump_init();
41 fd = rump_sys_open("/dev/bpf", O_RDWR);
42 ATF_CHECK(fd != -1);
43 ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(fd, BIOCSETF, &bp), -1,
44 "bpf accepted program with division by zero");
47 ATF_TP_ADD_TCS(tp)
50 ATF_TP_ADD_TC(tp, div_by_zero);
51 return atf_no_error();