| 1 | package workbench |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "runtime" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/google/uuid" |
| 10 | "github.com/sylvinus/agent-vm/internal/guestos" |
| 11 | ) |
| 12 | |
| 13 | func TestWindowsControllerCannotTreatUnknownVMAsIdle(t *testing.T) { |
| 14 | if runtime.GOOS == "windows" { |
| 15 | t.Skip("native Hyper-V state is covered by the opt-in Windows E2E") |
| 16 | } |
| 17 | profile := t.TempDir() |
| 18 | binding := guestos.WindowsProfile{Version: 1, VMID: uuid.New(), GUIUserSID: "S-1-5-21-1-2-3-1001", InstanceDirectory: filepath.Join(profile, "hyperv"), RelayExecutable: filepath.Join(profile, "relay.exe"), PairingFile: filepath.Join(profile, "pairing.bin")} |
| 19 | if err := guestos.BindWindowsProfile(profile, binding); err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | legacy := filepath.Join(profile, "state", "lima", "unrelated") |
| 23 | if err := os.MkdirAll(legacy, 0700); err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | if err := writePrivate(filepath.Join(legacy, "cage-running.json"), map[string]int{"pid": os.Getpid()}); err != nil { |
| 27 | t.Fatal(err) |
| 28 | } |
| 29 | if _, err := controllerVMOwners(profile); err == nil { |
| 30 | t.Fatal("unsupported Hyper-V probe became an idle or unrelated Lima workload") |
| 31 | } |
| 32 | } |