From 95cf51a304659079405d1943022f0de1ea57dbf7 Mon Sep 17 00:00:00 2001
From: jkim <jkim@FreeBSD.org>
Date: Mon, 18 Aug 2008 23:05:19 +0000
Subject: [PATCH] Add test case for 'divide by 0' with BPF_ALU|BPF_DIV|BPF_X
 instruction.

---
 tools/regression/bpf/bpf_filter/Makefile      |  2 +-
 .../bpf/bpf_filter/tests/test0074.h           | 33 +++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 tools/regression/bpf/bpf_filter/tests/test0074.h

diff --git a/tools/regression/bpf/bpf_filter/Makefile b/tools/regression/bpf/bpf_filter/Makefile
index 6c668d5c49a0..ea12e53a609b 100644
--- a/tools/regression/bpf/bpf_filter/Makefile
+++ b/tools/regression/bpf/bpf_filter/Makefile
@@ -18,7 +18,7 @@ TEST_CASES=	test0001 test0002 test0003 test0004	\
 		test0061 test0062 test0063 test0064	\
 		test0065 test0066 test0067 test0068	\
 		test0069 test0070 test0071 test0072	\
-		test0073
+		test0073 test0074
 
 SYSDIR?=	${.CURDIR}/../../../../sys
 
diff --git a/tools/regression/bpf/bpf_filter/tests/test0074.h b/tools/regression/bpf/bpf_filter/tests/test0074.h
new file mode 100644
index 000000000000..8ab73a16260e
--- /dev/null
+++ b/tools/regression/bpf/bpf_filter/tests/test0074.h
@@ -0,0 +1,33 @@
+/*-
+ * Test 0074:	Divide by 0 (BPF_ALU|BPF_DIV|BPF_X)
+ *
+ * $FreeBSD$
+ */
+
+/* BPF program */
+struct bpf_insn pc[] = {
+	BPF_STMT(BPF_LD|BPF_IMM, 0xa7c2da06),
+	BPF_STMT(BPF_LDX|BPF_IMM, 0),
+	BPF_STMT(BPF_ALU|BPF_DIV|BPF_X, 0),
+	BPF_STMT(BPF_RET|BPF_A, 0),
+};
+
+/* Packet */
+u_char	pkt[] = {
+	0x00,
+};
+
+/* Packet length seen on wire */
+u_int	wirelen =	sizeof(pkt);
+
+/* Packet length passed on buffer */
+u_int	buflen =	sizeof(pkt);
+
+/* Invalid instruction */
+int	invalid =	0;
+
+/* Expected return value */
+u_int	expect =	0;
+
+/* Expeced signal */
+int	expect_signal =	0;