Skip to content

Commit

Permalink
test: test cases for the new wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
rscampos committed Jul 1, 2024
1 parent 314f8b2 commit 558440f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions helpers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package libbpfgo

import (
"testing"

"github.com/aquasecurity/libbpfgo/helpers"
)

func TestFuncSupportbyType(t *testing.T) {
tt := []struct {
progType BPFProgType
funcId helpers.BPFFunc
supported bool
}{
{
progType: BPFProgTypeKprobe,
funcId: helpers.BPFFuncMapLookupElem,
supported: true,
},
{
progType: BPFProgTypeKprobe,
funcId: helpers.BPFFuncLoop,
supported: true,
},
{
progType: BPFProgTypeKprobe,
funcId: helpers.BPFFuncKtimeGetNs,
supported: true,
},
{
progType: BPFProgTypeKprobe,
funcId: helpers.BPFFuncSysBpf,
supported: false,
},
{
progType: BPFProgTypeLsm,
funcId: helpers.BPFFuncGetCurrentCgroupId,
supported: false,
},
{
progType: BPFProgTypeSkLookup,
funcId: helpers.BPFFuncGetCurrentCgroupId,
supported: true,
},
{
progType: BPFProgTypeKprobe,
funcId: helpers.BPFFuncSockMapUpdate,
supported: false,
},
}

for _, tc := range tt {
support, _ := BPFFuncTypeIsSupported(tc.progType, tc.funcId)

if support != tc.supported {
t.Errorf("expected %v, got %v", tc.supported, support)
}
}
}

0 comments on commit 558440f

Please sign in to comment.