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

Function TestStackwalkDecorator

pkg/event/stackwalk_test.go:32–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestStackwalkDecorator(t *testing.T) {
33 q := NewQueue(50, false, true)
34 cd := NewStackwalkDecorator(q)
35
36 e := &Event{
37 Type: CreateFile,
38 Tid: 2484,
39 PID: 859,
40 CPU: 1,
41 Seq: 2,
42 Name: "CreateFile",
43 Timestamp: time.Now(),
44 Category: File,
45 Params: Params{
46 params.FileObject: {Name: params.FileObject, Type: params.Uint64, Value: uint64(12456738026482168384)},
47 params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\system32\\user32.dll"},
48 params.FileType: {Name: params.FileType, Type: params.AnsiString, Value: "file"},
49 params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(1), Enum: fs.FileCreateDispositions},
50 },
51 }
52
53 e1 := &Event{
54 Type: CreateFile,
55 Tid: 2484,
56 PID: 859,
57 CPU: 1,
58 Seq: 3,
59 Name: "CreateFile",
60 Timestamp: time.Now(),
61 Category: File,
62 Params: Params{
63 params.FileObject: {Name: params.FileObject, Type: params.Uint64, Value: uint64(12456738026482168384)},
64 params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\system32\\kernel32.dll"},
65 params.FileType: {Name: params.FileType, Type: params.AnsiString, Value: "file"},
66 params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(1), Enum: fs.FileCreateDispositions},
67 },
68 }
69
70 cd.Push(e)
71 cd.Push(e1)
72
73 assert.Len(t, cd.buckets[e.StackID()], 2)
74
75 sw := &Event{
76 Type: StackWalk,
77 Tid: 2484,
78 PID: 859,
79 CPU: 1,
80 Seq: 4,
81 Name: "StackWalk",
82 Timestamp: time.Now(),
83 Params: Params{
84 params.Callstack: {Name: params.Callstack, Type: params.Slice, Value: []va.Address{0x7ffb5eb70dc4, 0x7ffb5c191deb, 0x7ffb3138592e}},
85 },
86 }
87
88 evt := cd.Pop(sw)
89 assert.Len(t, cd.buckets[e.StackID()], 1)

Callers

nothing calls this directly

Calls 9

PushMethod · 0.95
StackIDMethod · 0.95
PopMethod · 0.95
NewStackwalkDecoratorFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
GetParamAsStringMethod · 0.80
NewQueueFunction · 0.70
LenMethod · 0.45

Tested by

no test coverage detected