Adjust BPF JIT compiler regression tests to catch up with r199603.
This commit is contained in:
parent
5ecf77367c
commit
448a7ff2ec
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199604
@ -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}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user