Skip test if bpf syscall is unavailable

This commit is contained in:
Brenden Blanco 2016-02-28 23:52:26 -08:00
parent 17b1e35dbc
commit 719d8ca65a
2 changed files with 8 additions and 2 deletions

View File

@ -3,10 +3,12 @@ package netlink
/*
#include <asm/types.h>
#include <asm/unistd.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
static int load_simple_bpf(int prog_type) {
#ifdef __NR_bpf
// { return 1; }
__u64 __attribute__((aligned(8))) insns[] = {
0x00000001000000b7ull,
@ -32,6 +34,10 @@ static int load_simple_bpf(int prog_type) {
.license = (__u64)&license,
};
return syscall(__NR_bpf, 5, &attr, sizeof(attr));
#else
errno = EINVAL;
return -1;
#endif
}
*/
import "C"

View File

@ -294,7 +294,7 @@ func TestFilterU32BpfAddDel(t *testing.T) {
fd, err := loadSimpleBpf(BPF_PROG_TYPE_SCHED_ACT)
if err != nil {
t.Fatal(err)
t.Skipf("Loading bpf program failed: %s", err)
}
filter := &U32{
FilterAttrs: FilterAttrs{
@ -415,7 +415,7 @@ func TestFilterClsActBpfAddDel(t *testing.T) {
}
fd, err := loadSimpleBpf(BPF_PROG_TYPE_SCHED_CLS)
if err != nil {
t.Fatal(err)
t.Skipf("Loading bpf program failed: %s", err)
}
filter := &BpfFilter{
FilterAttrs: filterattrs,