blob: 427869e3e62503ee69d56dcccb8fafc542c071d3 (
plain)
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
|
package internal
import (
"os"
"testing"
)
func TestSeedTrackedPidCommCachesTrackedPidComm(t *testing.T) {
pid := uint32(os.Getpid())
want := resolveCommFromProc(pid)
if want == "" {
t.Fatalf("expected comm for pid %d", pid)
}
el := &eventLoop{
cfg: eventLoopConfig{
pidFilter: int(pid),
},
commResolver: newCommResolver(make(map[uint32]string)),
}
el.seedTrackedPidComm()
got, ok := el.cachedComm(pid)
if !ok {
t.Fatalf("expected pid %d to be seeded", pid)
}
if got != want {
t.Fatalf("seeded comm = %q, want %q", got, want)
}
}
func TestSeedTrackedPidCommSeedsCurrentProcessWhenPidFilterDisabled(t *testing.T) {
el := &eventLoop{
cfg: eventLoopConfig{
pidFilter: -1,
},
commResolver: newCommResolver(make(map[uint32]string)),
}
el.seedTrackedPidComm()
if _, ok := el.cachedComm(uint32(os.Getpid())); !ok {
t.Fatalf("expected current process pid to be seeded")
}
}
|