Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyoush committed Sep 10, 2024
1 parent 5188cf8 commit a9a7eeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func TestRead(t *testing.T) {
pid: uint64(os.Getpid()),
fd: uint32(conn.TgidFd),
funcName: "syscall",
ignoreFuncName: true,
dataLen: uint32(len(sendMsg)),
seq: 1,
step: bpf.AgentStepTSYSCALL_IN,
Expand Down Expand Up @@ -463,6 +464,7 @@ func TestWrite(t *testing.T) {
pid: uint64(os.Getpid()),
fd: uint32(conn.TgidFd),
funcName: "syscall",
ignoreFuncName: true,
dataLen: uint32(len(sendMsg)),
seq: 1,
step: bpf.AgentStepTSYSCALL_OUT,
Expand Down Expand Up @@ -523,6 +525,7 @@ func TestSendto(t *testing.T) {
pid: uint64(os.Getpid()),
fd: uint32(conn.TgidFd),
funcName: "syscall",
ignoreFuncName: true,
dataLen: uint32(len(sendMsg)),
seq: 1,
step: bpf.AgentStepTSYSCALL_OUT,
Expand Down Expand Up @@ -782,13 +785,14 @@ func TestDevQueueXmit(t *testing.T) {
findDataLenGtZeroEvent: true,
findByDirect: true,
direct: bpf.AgentTrafficDirectionTKEgress,
findByFuncName: true,
funcName: "dev_queue_xmit",
findByStep: true,
step: bpf.AgentStepTQDISC_OUT,
}, KernDataEventAssertConditions{

connIdDirect: bpf.AgentTrafficDirectionTKEgress,
pid: uint64(os.Getpid()),
funcName: "dev_queue_xmit",
ignoreFuncName: true,
seq: 1,
step: bpf.AgentStepTQDISC_OUT,
tsAssertFunction: func(u uint64) bool { return u > 0 },
Expand Down Expand Up @@ -842,13 +846,14 @@ func TestTracepointNetifReceiveSkb(t *testing.T) {
findDataLenGtZeroEvent: true,
findByDirect: true,
direct: bpf.AgentTrafficDirectionTKIngress,
findByFuncName: true,
funcName: "netif_receive_skb",
findByStep: true,
step: bpf.AgentStepTDEV_IN,
}, KernDataEventAssertConditions{

connIdDirect: bpf.AgentTrafficDirectionTKIngress,
pid: uint64(os.Getpid()),
funcName: "netif_receive_skb",
ignoreFuncName: true,
seq: 1,
step: bpf.AgentStepTDEV_IN,
ignoreDataLen: true,
Expand Down Expand Up @@ -913,13 +918,14 @@ func TestTcpV4DoRcv(t *testing.T) {
findDataLenGtZeroEvent: true,
findByDirect: true,
direct: bpf.AgentTrafficDirectionTKIngress,
findByFuncName: true,
funcName: "tcp_v4_do_rcv",
findByStep: true,
step: bpf.AgentStepTTCP_IN,
}, KernDataEventAssertConditions{

connIdDirect: bpf.AgentTrafficDirectionTKIngress,
pid: uint64(os.Getpid()),
funcName: "tcp_v4_do_rcv",
ignoreFuncName: true,
seq: 1,
step: bpf.AgentStepTTCP_IN,
ignoreDataLen: true,
Expand Down
2 changes: 1 addition & 1 deletion agent/agent_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func MayBeXdpFunction(defaultFunc bpf.AttachBpfProgFunction) bpf.AttachBpfProgFu
}
}

var compatilbeMode bool = true
var compatilbeMode bool = false

func SetCompatibleMode(b bool) {
compatilbeMode = b
Expand Down

0 comments on commit a9a7eeb

Please sign in to comment.