75 lines
2.5 KiB
Go
75 lines
2.5 KiB
Go
package host
|
|
|
|
import "testing"
|
|
|
|
func findOpt(t *testing.T, opts []Optimization, id string) Optimization {
|
|
t.Helper()
|
|
for _, o := range opts {
|
|
if o.ID == id {
|
|
return o
|
|
}
|
|
}
|
|
t.Fatalf("optimization %q not found", id)
|
|
return Optimization{}
|
|
}
|
|
|
|
func TestEvaluateOptimizationsWin10AndWin11(t *testing.T) {
|
|
// Win10 hybrid CPU without startup-ipis patch.
|
|
win10 := Report{
|
|
WHPX: WHPXReady,
|
|
HasHybridCores: true,
|
|
PCoreCount: 8,
|
|
ECoreCount: 4,
|
|
NeedsColdRebootWorkaround: true,
|
|
WHPXCaps: WHPXCapabilities{
|
|
APICEmulation: true,
|
|
KernelIrqchipAvailable: true,
|
|
},
|
|
RecommendedGPU: &GPUInfo{Name: "NVIDIA GeForce RTX 4070 Ti", Kind: GPUDiscrete, VulkanICD: "nv-vk64.json"},
|
|
}
|
|
opts := EvaluateOptimizations(win10, []string{"qemu-whpx-win10-compat.patch"})
|
|
if o := findOpt(t, opts, "pcore_pin"); o.Status != "recommended" || !o.Supported {
|
|
t.Fatalf("pcore_pin = %+v", o)
|
|
}
|
|
if o := findOpt(t, opts, "kernel_irqchip"); o.Status != "unavailable" || o.Detail != "win10-needs-patch" {
|
|
t.Fatalf("kernel_irqchip without patch = %+v", o)
|
|
}
|
|
if o := findOpt(t, opts, "cold_reboot"); o.Status != "auto" {
|
|
t.Fatalf("cold_reboot = %+v", o)
|
|
}
|
|
|
|
// Win10 with startup-ipis patch -> experimental.
|
|
optsPatched := EvaluateOptimizations(win10, []string{"qemu-whpx-win10-compat.patch", "qemu-whpx-win10-startup-ipis.patch"})
|
|
if o := findOpt(t, optsPatched, "kernel_irqchip"); o.Status != "experimental" || !o.Supported {
|
|
t.Fatalf("kernel_irqchip with patch = %+v", o)
|
|
}
|
|
|
|
// Win11 where NestedVirtualization probe fails with 0x80370302.
|
|
win11BrokenNested := Report{
|
|
WHPX: WHPXReady,
|
|
NeedsColdRebootWorkaround: false,
|
|
WHPXCaps: WHPXCapabilities{
|
|
ModernOS: true,
|
|
APICEmulation: true,
|
|
KernelIrqchipAvailable: true,
|
|
NestedVirtProperty: false,
|
|
NestedVirtProbeError: "0x80370302",
|
|
},
|
|
}
|
|
opts11 := EvaluateOptimizations(win11BrokenNested, nil)
|
|
if o := findOpt(t, opts11, "kernel_irqchip"); o.Status != "unavailable" || o.Detail != "0x80370302" {
|
|
t.Fatalf("win11 broken nested = %+v", o)
|
|
}
|
|
if o := findOpt(t, opts11, "cold_reboot"); o.Status != "unavailable" {
|
|
t.Fatalf("win11 cold_reboot = %+v", o)
|
|
}
|
|
|
|
// Win11 with full support.
|
|
win11BrokenNested.WHPXCaps.NestedVirtProperty = true
|
|
win11BrokenNested.WHPXCaps.NestedVirtProbeError = ""
|
|
opts11Ok := EvaluateOptimizations(win11BrokenNested, nil)
|
|
if o := findOpt(t, opts11Ok, "kernel_irqchip"); o.Status != "recommended" || !o.Supported {
|
|
t.Fatalf("win11 full support = %+v", o)
|
|
}
|
|
}
|