Skip to content

Commit

Permalink
chore(selftest): Add tc Query test case
Browse files Browse the repository at this point in the history
The bpf_tc_query interface should init the parameter first, sometimes
it may be confused for us, so add the case to reduce the confusion.

#421

Signed-off-by: Tao Chen <[email protected]>
  • Loading branch information
chentao-kernel committed Apr 8, 2024
1 parent 7371781 commit cbf8697
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions selftest/tc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,27 @@ func main() {

var tcOpts bpf.TcOpts
tcOpts.ProgFd = int(tcProg.GetFd())
tcOpts.Flags = bpf.BpfTcFReplace
tcOpts.Handle = 1
err = hook.Attach(&tcOpts)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}

tcOpts.Flags = 0
tcOpts.ProgFd = 0
tcOpts.ProgId = 0
err = hook.Query(&tcOpts)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
if tcOpts.Handle != 1 {
fmt.Fprintln(os.Stderr, "query info error, handle:%d", tcOpts.Handle)
os.Exit(-1)
}

eventsChannel := make(chan []byte)
rb, err := bpfModule.InitRingBuf("events", eventsChannel)
if err != nil {
Expand Down

0 comments on commit cbf8697

Please sign in to comment.