Change Driver.Start to StartRequest/StartResult with a compile-time macOS adapter assertion and registry-to-router coverage. Keep legacy Sidecar name alongside VMRef and grant argument privileges by driver ownership. Move macOS preparation into ReimsMacOSDriver after hook veto, fail preparation errors before launch, and verify veto leaves OpenCore, recovery markers and ledgers unchanged. Unify GUI, CLI and window list/start/stop through internal/lifecycle, select frontend VMs by VMRef, lazily initialize reims only in legacy CLI branches, and cover a second driver through App user entry points.
66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
package macosdriver
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/config"
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
"github.com/Nwflower/reims-go/internal/macos/reims"
|
|
"github.com/Nwflower/reims-go/internal/plugin"
|
|
rt "github.com/Nwflower/reims-go/internal/runtime"
|
|
)
|
|
|
|
func argKeys(in plugin.StartIntent) []string {
|
|
keys := make([]string, 0, len(in.Args))
|
|
for _, arg := range in.Args {
|
|
keys = append(keys, arg.Key)
|
|
}
|
|
return keys
|
|
}
|
|
|
|
func TestPrepareWorkaroundsHonourSettingsAndRuntime(t *testing.T) {
|
|
whpx, cold := true, true
|
|
d := &ReimsMacOSDriver{opts: Options{OwnerID: "test.macos",
|
|
WHPXFallbackEnabled: func() bool { return whpx }, ColdRebootEnabled: func() bool { return cold }}}
|
|
rep := host.Report{WHPXCaps: host.WHPXCapabilities{KernelIrqchipAvailable: true, NestedVirtProperty: false}}
|
|
var in plugin.StartIntent
|
|
d.prepareWHPXFallback(config.Config{}, rt.Installed{}, reims.VMDetail{}, rep, &in)
|
|
if !slices.Equal(argKeys(in), []string{keyKernelIrqchip}) {
|
|
t.Fatalf("WHPX args = %+v", in.Args)
|
|
}
|
|
for _, key := range []string{keyOfflineHelper, keyWin10ColdReboot} {
|
|
in.ClearKeys = append(in.ClearKeys, key)
|
|
}
|
|
in = plugin.StartIntent{}
|
|
d.prepareWHPXFallback(config.Config{}, rt.Installed{Manifest: rt.Manifest{Capabilities: []string{"nested-virt-nonfatal"}}}, reims.VMDetail{}, rep, &in)
|
|
if len(in.Args) != 0 || !slices.Contains(in.ClearKeys, keyKernelIrqchip) {
|
|
t.Fatalf("capable runtime = %+v", in)
|
|
}
|
|
whpx = false
|
|
in = plugin.StartIntent{}
|
|
d.prepareWHPXFallback(config.Config{}, rt.Installed{}, reims.VMDetail{}, rep, &in)
|
|
if len(in.Args) != 0 {
|
|
t.Fatalf("disabled WHPX fallback = %+v", in)
|
|
}
|
|
|
|
rep.NeedsColdRebootWorkaround = true
|
|
root := t.TempDir()
|
|
cfg := config.Config{DataRoot: root}
|
|
in = plugin.StartIntent{}
|
|
if err := d.prepareColdReboot(cfg, "mac", root, rep, &in); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !slices.Contains(argKeys(in), keyWin10ColdReboot) || len(in.PostStart) != 1 {
|
|
t.Fatalf("cold reboot = %+v", in)
|
|
}
|
|
cold = false
|
|
in = plugin.StartIntent{}
|
|
if err := d.prepareColdReboot(cfg, "mac", root, rep, &in); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(in.Args) != 0 || len(in.PostStart) != 0 {
|
|
t.Fatalf("disabled cold reboot = %+v", in)
|
|
}
|
|
}
|