Skip to content

Commit

Permalink
clean up network tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 24, 2024
1 parent 3d052ac commit e43c601
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
49 changes: 7 additions & 42 deletions testing/testrunner/ebpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,7 @@ func TtyWrite(t *testing.T, et *Runner) {
}

func Tcpv4ConnectionAttempt(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv4_connect", &binOutput)

var ev NetConnAttemptEvent
Expand All @@ -435,12 +430,7 @@ func Tcpv4ConnectionAttempt(t *testing.T, et *Runner) {
}

func Tcpv4ConnectionAccept(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv4_connect", &binOutput)

var ev NetConnAcceptEvent
Expand All @@ -463,12 +453,7 @@ func Tcpv4ConnectionAccept(t *testing.T, et *Runner) {
}

func Tcpv4ConnectionClose(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv4_connect", &binOutput)

var ev NetConnCloseEvent
Expand Down Expand Up @@ -511,12 +496,7 @@ func Tcpv4ConnectionClose(t *testing.T, et *Runner) {
}

func Tcpv6ConnectionAttempt(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv6_connect", &binOutput)

var ev NetConnAttemptEvent
Expand All @@ -539,12 +519,7 @@ func Tcpv6ConnectionAttempt(t *testing.T, et *Runner) {
}

func Tcpv6ConnectionAccept(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv6_connect", &binOutput)

var ev NetConnAttemptEvent
Expand All @@ -567,12 +542,7 @@ func Tcpv6ConnectionAccept(t *testing.T, et *Runner) {
}

func Tcpv6ConnectionClose(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "tcpv6_connect", &binOutput)

var ev NetConnCloseEvent
Expand All @@ -595,12 +565,7 @@ func Tcpv6ConnectionClose(t *testing.T, et *Runner) {
}

func DNSMonitor(t *testing.T, et *Runner) {
var binOutput struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}
binOutput := NetBinOut{}
runTestUnmarshalOutput(t, "udp_send", &binOutput)
type dnsOutput struct {
Data []uint8 `json:"data"`
Expand Down
8 changes: 7 additions & 1 deletion testing/testrunner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ type NetConnAcceptEvent struct {
Comm string `json:"comm"`
}

type NetBinOut struct {
PidInfo TestPidInfo `json:"pid_info"`
ClientPort int64 `json:"client_port"`
ServerPort int64 `json:"server_port"`
NetNs int64 `json:"netns"`
}

type NetConnCloseEvent struct {
Pids PidInfo `json:"pids"`
Net NetInfo `json:"net"`
Expand All @@ -189,7 +196,6 @@ var eventsTracePath = "/EventsTrace"

// Path to the TC filter test binary and probe. This one is weird and lives outside the rest of the test binaries
var tcTestPath = "/BPFTcFilterTests"

var tcObjPath = "/TcFilter.bpf.o"

// init will run at startup and figure out if we're running in the bluebox test env or not,
Expand Down

0 comments on commit e43c601

Please sign in to comment.