Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Nov 2009 18:53:38 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199604 - in head/tools/regression/bpf/bpf_filter: . tests
Message-ID:  <200911201853.nAKIrcoZ053217@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Fri Nov 20 18:53:38 2009
New Revision: 199604
URL: http://svn.freebsd.org/changeset/base/199604

Log:
  Adjust BPF JIT compiler regression tests to catch up with r199603.

Modified:
  head/tools/regression/bpf/bpf_filter/Makefile
  head/tools/regression/bpf/bpf_filter/bpf_test.c
  head/tools/regression/bpf/bpf_filter/tests/test0075.h
  head/tools/regression/bpf/bpf_filter/tests/test0076.h
  head/tools/regression/bpf/bpf_filter/tests/test0077.h
  head/tools/regression/bpf/bpf_filter/tests/test0078.h
  head/tools/regression/bpf/bpf_filter/tests/test0080.h

Modified: head/tools/regression/bpf/bpf_filter/Makefile
==============================================================================
--- head/tools/regression/bpf/bpf_filter/Makefile	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/Makefile	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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}

Modified: head/tools/regression/bpf/bpf_filter/bpf_test.c
==============================================================================
--- head/tools/regression/bpf/bpf_filter/bpf_test.c	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/bpf_test.c	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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);

Modified: head/tools/regression/bpf/bpf_filter/tests/test0075.h
==============================================================================
--- head/tools/regression/bpf/bpf_filter/tests/test0075.h	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/tests/test0075.h	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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

Modified: head/tools/regression/bpf/bpf_filter/tests/test0076.h
==============================================================================
--- head/tools/regression/bpf/bpf_filter/tests/test0076.h	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/tests/test0076.h	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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

Modified: head/tools/regression/bpf/bpf_filter/tests/test0077.h
==============================================================================
--- head/tools/regression/bpf/bpf_filter/tests/test0077.h	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/tests/test0077.h	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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

Modified: head/tools/regression/bpf/bpf_filter/tests/test0078.h
==============================================================================
--- head/tools/regression/bpf/bpf_filter/tests/test0078.h	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/tests/test0078.h	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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

Modified: head/tools/regression/bpf/bpf_filter/tests/test0080.h
==============================================================================
--- head/tools/regression/bpf/bpf_filter/tests/test0080.h	Fri Nov 20 18:49:20 2009	(r199603)
+++ head/tools/regression/bpf/bpf_filter/tests/test0080.h	Fri Nov 20 18:53:38 2009	(r199604)
@@ -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),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911201853.nAKIrcoZ053217>