-
Notifications
You must be signed in to change notification settings - Fork 3
/
features_test.go
63 lines (52 loc) · 1.49 KB
/
features_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package skbtrace
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
type mockBPFTraceProvider struct {
BPFTraceVersionProvider
versionStr string
}
func (m mockBPFTraceProvider) Get() ([]byte, error) {
return []byte(m.versionStr), nil
}
func TestBPFTraceFeatures(t *testing.T) {
runTest := func(verStr, maskArg string) (mask FeatureFlagMask, err error) {
spec := FeatureComponentSpec{
Component: FeatureComponentBPFTrace,
Provider: mockBPFTraceProvider{
versionStr: verStr,
},
}
return spec.ProcessFeatures("", maskArg)
}
t.Run("oldest", func(t *testing.T) {
m, err := runTest("bpftrace build-0.9.2", "")
require.NoError(t, err)
assert.False(t, m.Supports(FeatureStructKeyword))
})
t.Run("newer", func(t *testing.T) {
m, err := runTest("bpftrace v0.9.4", "")
require.NoError(t, err)
assert.True(t, m.Supports(FeatureStructKeyword))
})
t.Run("newest", func(t *testing.T) {
m, err := runTest("bpftrace build-0.18.0-733.230919-dirty", "")
require.NoError(t, err)
assert.True(t, m.Supports(FeatureStructKeyword))
})
t.Run("mask-override", func(t *testing.T) {
m, err := runTest("bpftrace build-0.9.2", "struct")
require.NoError(t, err)
assert.True(t, m.Supports(FeatureStructKeyword))
})
t.Run("invalid", func(t *testing.T) {
_, err := runTest("2.6.32", "")
assert.Error(t, err)
})
t.Run("mask-invalid", func(t *testing.T) {
_, err := runTest("bpftrace build-0.9.2", "invalid")
assert.Error(t, err)
})
}