summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-11-20 18:53:38 +0000
committerjkim <jkim@FreeBSD.org>2009-11-20 18:53:38 +0000
commitad0b2feb64f1c8a8675d6b4a9374ae41038de42d (patch)
treefe03e2b6995058134ffac8324c69a92d4ae944eb /tools
parent052bc52af74a5ae4eb6c288f7377bef9d10902cf (diff)
downloadFreeBSD-src-ad0b2feb64f1c8a8675d6b4a9374ae41038de42d.zip
FreeBSD-src-ad0b2feb64f1c8a8675d6b4a9374ae41038de42d.tar.gz
Adjust BPF JIT compiler regression tests to catch up with r199603.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bpf/bpf_filter/Makefile3
-rw-r--r--tools/regression/bpf/bpf_filter/bpf_test.c16
-rw-r--r--tools/regression/bpf/bpf_filter/tests/test0075.h8
-rw-r--r--tools/regression/bpf/bpf_filter/tests/test0076.h8
-rw-r--r--tools/regression/bpf/bpf_filter/tests/test0077.h8
-rw-r--r--tools/regression/bpf/bpf_filter/tests/test0078.h8
-rw-r--r--tools/regression/bpf/bpf_filter/tests/test0080.h4
7 files changed, 35 insertions, 20 deletions
diff --git a/tools/regression/bpf/bpf_filter/Makefile b/tools/regression/bpf/bpf_filter/Makefile
index 792be64..79a2e0c 100644
--- a/tools/regression/bpf/bpf_filter/Makefile
+++ b/tools/regression/bpf/bpf_filter/Makefile
@@ -43,6 +43,7 @@ CFLAGS+= -DBPF_VALIDATE
SRCS+= ${SYSDIR}/net/bpf_jitter.c \
${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c
CFLAGS+= -DBPF_JIT_COMPILER
+LIBS+= -lutil
WARNS?= 6
.else
SRCS+= ${SYSDIR}/net/bpf_filter.c
@@ -52,7 +53,7 @@ WARNS?= 2
.for TEST in ${TEST_CASES}
${TEST}: ${.CURDIR}/tests/${TEST}.h ${SRCS}
@${CC} ${CFLAGS} -DBPF_TEST_H=\"${TEST}.h\" \
- -o ${.CURDIR}/${TEST} ${SRCS}
+ -o ${.CURDIR}/${TEST} ${SRCS} ${LIBS}
.endfor
all: ${TEST_CASES}
diff --git a/tools/regression/bpf/bpf_filter/bpf_test.c b/tools/regression/bpf/bpf_filter/bpf_test.c
index cd16fd6..853095a 100644
--- a/tools/regression/bpf/bpf_filter/bpf_test.c
+++ b/tools/regression/bpf/bpf_filter/bpf_test.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (C) 2008 Jung-uk Kim <jkim@FreeBSD.org>. All rights reserved.
+ * Copyright (C) 2009 Jung-uk Kim <jkim@FreeBSD.org>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -57,6 +57,8 @@ static int verbose = LOG_LEVEL;
#ifdef BPF_JIT_COMPILER
+#include <libutil.h>
+
#include <net/bpf_jitter.h>
static u_int
@@ -73,6 +75,10 @@ bpf_compile_and_filter(void)
printf("FATAL\n");
exit(FATAL);
}
+ if (verbose > 2) {
+ printf("\n");
+ hexdump(filter->func, filter->size, NULL, HD_OMIT_CHARS);
+ }
for (i = 0; i < BPF_NRUNS; i++)
ret = (*(filter->func))(pkt, wirelen, buflen);
@@ -222,6 +228,14 @@ main(void)
for (i = 0; i < BPF_NRUNS; i++)
ret = bpf_filter(nins != 0 ? pc : NULL, pkt, wirelen, buflen);
#endif
+ if (expect_signal != 0) {
+ if (verbose > 1)
+ printf("Expected signal %d but got none:\t",
+ expect_signal);
+ if (verbose > 0)
+ printf("FAILED\n");
+ return (FAILED);
+ }
if (ret != expect) {
if (verbose > 1)
printf("Expected 0x%x but got 0x%x:\t", expect, ret);
diff --git a/tools/regression/bpf/bpf_filter/tests/test0075.h b/tools/regression/bpf/bpf_filter/tests/test0075.h
index 0d94c7a..fa85dd0 100644
--- a/tools/regression/bpf/bpf_filter/tests/test0075.h
+++ b/tools/regression/bpf/bpf_filter/tests/test0075.h
@@ -7,7 +7,7 @@
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD+BPF_IMM, 0xdeadc0de),
- BPF_STMT(BPF_LD+BPF_MEM, 0xffffffff),
+ BPF_STMT(BPF_LD+BPF_MEM, 0x8fffffff),
BPF_STMT(BPF_RET+BPF_A, 0),
};
@@ -29,8 +29,8 @@ int invalid = 1;
u_int expect = 0xdeadc0de;
/* Expected signal */
-#ifdef BPF_JIT_COMPILER
-int expect_signal = SIGSEGV;
-#else
+#ifdef __amd64__
int expect_signal = SIGBUS;
+#else
+int expect_signal = SIGSEGV;
#endif
diff --git a/tools/regression/bpf/bpf_filter/tests/test0076.h b/tools/regression/bpf/bpf_filter/tests/test0076.h
index 6513459..318cbea 100644
--- a/tools/regression/bpf/bpf_filter/tests/test0076.h
+++ b/tools/regression/bpf/bpf_filter/tests/test0076.h
@@ -7,7 +7,7 @@
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD+BPF_IMM, 0xdeadc0de),
- BPF_STMT(BPF_LDX+BPF_MEM, 0xffffffff),
+ BPF_STMT(BPF_LDX+BPF_MEM, 0x8fffffff),
BPF_STMT(BPF_MISC+BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
@@ -30,8 +30,8 @@ int invalid = 1;
u_int expect = 0xdeadc0de;
/* Expected signal */
-#ifdef BPF_JIT_COMPILER
-int expect_signal = SIGSEGV;
-#else
+#ifdef __amd64__
int expect_signal = SIGBUS;
+#else
+int expect_signal = SIGSEGV;
#endif
diff --git a/tools/regression/bpf/bpf_filter/tests/test0077.h b/tools/regression/bpf/bpf_filter/tests/test0077.h
index 6ac1e51..2af70cc 100644
--- a/tools/regression/bpf/bpf_filter/tests/test0077.h
+++ b/tools/regression/bpf/bpf_filter/tests/test0077.h
@@ -7,7 +7,7 @@
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD+BPF_IMM, 0xdeadc0de),
- BPF_STMT(BPF_ST, 0xffffffff),
+ BPF_STMT(BPF_ST, 0x8fffffff),
BPF_STMT(BPF_RET+BPF_A, 0),
};
@@ -29,8 +29,8 @@ int invalid = 1;
u_int expect = 0xdeadc0de;
/* Expected signal */
-#ifdef BPF_JIT_COMPILER
-int expect_signal = SIGSEGV;
-#else
+#ifdef __amd64__
int expect_signal = SIGBUS;
+#else
+int expect_signal = SIGSEGV;
#endif
diff --git a/tools/regression/bpf/bpf_filter/tests/test0078.h b/tools/regression/bpf/bpf_filter/tests/test0078.h
index 8803073..3146de2 100644
--- a/tools/regression/bpf/bpf_filter/tests/test0078.h
+++ b/tools/regression/bpf/bpf_filter/tests/test0078.h
@@ -7,7 +7,7 @@
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD+BPF_IMM, 0xdeadc0de),
- BPF_STMT(BPF_STX, 0xffffffff),
+ BPF_STMT(BPF_STX, 0x8fffffff),
BPF_STMT(BPF_MISC+BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
@@ -30,8 +30,8 @@ int invalid = 1;
u_int expect = 0xdeadc0de;
/* Expected signal */
-#ifdef BPF_JIT_COMPILER
-int expect_signal = SIGSEGV;
-#else
+#ifdef __amd64__
int expect_signal = SIGBUS;
+#else
+int expect_signal = SIGSEGV;
#endif
diff --git a/tools/regression/bpf/bpf_filter/tests/test0080.h b/tools/regression/bpf/bpf_filter/tests/test0080.h
index 69bed73..65ae6c5 100644
--- a/tools/regression/bpf/bpf_filter/tests/test0080.h
+++ b/tools/regression/bpf/bpf_filter/tests/test0080.h
@@ -1,12 +1,12 @@
/*-
- * Test 0080: Check uninitialized scratch memory (only for JIT compiler).
+ * Test 0080: Check uninitialized scratch memory (obsolete).
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
-#ifdef BPF_JIT_COMPILER
+#ifdef BPF_JIT_COMPILER_OBSOLETE
BPF_STMT(BPF_LDX+BPF_IMM, 0xffffffff),
BPF_STMT(BPF_LD+BPF_MEM, 0),
BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 29, 0),
OpenPOWER on IntegriCloud