MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestBitSets

Function TestBitSets

pkg/event/bitset_test.go:60–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestBitSets(t *testing.T) {
61 var tests = []struct {
62 evt *Event
63 expected bool
64 }{
65 {&Event{Type: TerminateThread}, true},
66 {&Event{Type: TerminateProcess}, true},
67 {&Event{Type: CreateThread, Category: Thread}, true},
68 {&Event{Type: CreateFile}, false},
69 {&Event{Type: WriteFile}, false},
70 {&Event{Type: LoadModule}, false},
71 {&Event{Type: MapFileRundown}, true},
72 {&Event{Type: ProcessRundown}, true},
73 }
74
75 var bitsets BitSets
76
77 bitsets.SetBit(BitmaskBitSet, TerminateThread)
78 bitsets.SetBit(TypeBitSet, TerminateProcess)
79 bitsets.SetBit(CategoryBitSet, CreateThread)
80 bitsets.SetBit(TypeBitSet, MapFileRundown)
81 bitsets.SetBit(BitmaskBitSet, ProcessRundown)
82
83 for _, tt := range tests {
84 t.Run(tt.evt.Type.String(), func(t *testing.T) {
85 assert.Equal(t, tt.expected, bitsets.IsBitSet(tt.evt))
86 })
87 }
88}
89
90func BenchmarkBitmask(b *testing.B) {
91 b.ReportAllocs()

Callers

nothing calls this directly

Calls 5

SetBitMethod · 0.95
IsBitSetMethod · 0.95
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected