返回 DeepSeek-Reasonix
tree_windows_test.go
根目录 / internal / proc / tree_windows_test.go
1 //go:build windows
2
3 package proc
4
5 import (
6 "testing"
7
8 "golang.org/x/sys/windows"
9 )
10
11 func TestSameProcessIdentityUsesCreationTime(t *testing.T) {
12 recorded := processRecord{
13 pid: 123,
14 exe: "python.exe",
15 created: windows.Filetime{LowDateTime: 1, HighDateTime: 2},
16 hasTimes: true,
17 }
18 current := recorded
19 if !sameProcessIdentity(recorded, current) {
20 t.Fatal("same process record should match")
21 }
22 current.created.LowDateTime++
23 if sameProcessIdentity(recorded, current) {
24 t.Fatal("same pid/exe with different creation time should not match")
25 }
26 }
27
28 func TestSameProcessIdentityFallsBackToExecutableName(t *testing.T) {
29 recorded := processRecord{pid: 123, exe: "Git-Bash.exe"}
30 current := processRecord{pid: 123, exe: "git-bash.exe"}
31 if !sameProcessIdentity(recorded, current) {
32 t.Fatal("same pid/exe should match when creation times are unavailable")
33 }
34 current.exe = "powershell.exe"
35 if sameProcessIdentity(recorded, current) {
36 t.Fatal("different executable names should not match when creation times are unavailable")
37 }
38 }
39
39 lines GO