Files
go-worm/lib/instance/kill_test.go
T
kato 536ea9a53e fix(core): take over agent, reuse callbacks
- Kill running agents before replace
- Retry copy with backoff while locked
- Reuse syscall callbacks at package scope
- Add callback regression test
2026-09-02 00:00:24 +03:00

32 lines
869 B
Go

package instance
import "testing"
func TestShouldKill(t *testing.T) {
t.Parallel()
const (
self uint32 = 10
selfPath = `C:\Users\me\Downloads\win64_mp.exe`
installed = `C:\Users\me\AppData\Roaming\win64_mp\win64_mp.exe`
)
cases := []struct {
pid uint32
image string
exeName string
want bool
}{
{self, selfPath, "win64_mp.exe", false},
{11, installed, "win64_mp.exe", true},
{11, `C:\Temp\win64_mp.exe`, "win64_mp.exe", true},
{11, "", "win64_mp.exe", true},
{11, `C:\Windows\System32\notepad.exe`, "notepad.exe", false},
{0, installed, "win64_mp.exe", false},
}
for _, tc := range cases {
got := shouldKill(self, tc.pid, selfPath, tc.image, installed, tc.exeName)
if got != tc.want {
t.Fatalf("shouldKill pid=%d image=%q name=%q = %v, want %v", tc.pid, tc.image, tc.exeName, got, tc.want)
}
}
}