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.
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package plugin
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestReconcileStartIntentsForDriverUsesOwnershipNotPrefix(t *testing.T) {
|
|
const owner = "vendor.guest.macos"
|
|
frag := func(key string) ArgFragment {
|
|
return ArgFragment{Key: key, Tokens: []string{"-drive", "file=" + key + ".img,if=none,id=" + key}, Priority: 1}
|
|
}
|
|
intents := []StartIntent{
|
|
{PluginID: owner, Args: []ArgFragment{frag("owner-disk")}, Env: map[string]string{"REIMS_VGPU_LOG": "debug"}, PostStart: []PostStartAction{{Kind: "qmp.watch_cold_reboot"}}},
|
|
{PluginID: "vendor.other", Args: []ArgFragment{frag("other-disk")}, Env: map[string]string{"REIMS_VGPU_LOG": "other"}},
|
|
}
|
|
ledger := &ArgLedger{Version: 1, Owners: map[string][]ArgFragment{}}
|
|
res := ReconcileStartIntentsForDriver("", ledger, map[string]bool{owner: true, "vendor.other": true}, owner, intents)
|
|
if !strings.Contains(res.ExtraArgs, "owner-disk.img") || strings.Contains(res.ExtraArgs, "other-disk.img") {
|
|
t.Fatalf("extra args = %q; warnings = %+v", res.ExtraArgs, res.Warnings)
|
|
}
|
|
if len(ledger.Owners[owner]) != 1 || !ledger.Owners[owner][0].Builtin {
|
|
t.Fatalf("owner ledger = %+v", ledger.Owners)
|
|
}
|
|
if len(res.PostStart) != 1 {
|
|
t.Fatalf("post start = %+v", res.PostStart)
|
|
}
|
|
foundEnv := false
|
|
for _, env := range res.Env {
|
|
if env == "REIMS_VGPU_LOG=debug" {
|
|
foundEnv = true
|
|
}
|
|
}
|
|
if !foundEnv {
|
|
t.Fatalf("owner env missing: %+v", res.Env)
|
|
}
|
|
}
|