-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wrapper creation for libbpf_probe_bpf_helper (#446)
* feat: wrapper creation for libbpf_probe_bpf_helper * test: test cases for the new wrapper
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, _ := BPFHelperIsSupported(tc.progType, tc.funcId) | ||
// This may fail if the bpf helper support for a specific program changes in future. | ||
if support != tc.supported { | ||
t.Errorf("expected %v, got %v", tc.supported, support) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters