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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user