Repository navigation
Expand file tree
/
Copy pathgenerated_values_test.go
More file actions
59 lines (54 loc) · 2.1 KB
/
Copy pathgenerated_values_test.go
File metadata and controls
59 lines (54 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//go:build darwin
package vz
import (
"runtime"
"testing"
pureobjc "github.com/ebitengine/purego/objc"
)
func TestGeneratedValueMigration(t *testing.T) {
for _, tt := range []struct {
selector string
got uint64
}{
{"minimumAllowedMemorySize", VirtualMachineConfigurationMinimumAllowedMemorySize()},
{"maximumAllowedMemorySize", VirtualMachineConfigurationMaximumAllowedMemorySize()},
{"minimumAllowedCPUCount", uint64(VirtualMachineConfigurationMinimumAllowedCPUCount())},
{"maximumAllowedCPUCount", uint64(VirtualMachineConfigurationMaximumAllowedCPUCount())},
} {
want := pureobjc.Send[uint64](pureobjc.ID(pureobjc.GetClass("VZVirtualMachineConfiguration")), pureobjc.RegisterName(tt.selector))
if tt.got != want {
t.Errorf("%s: got %d, want %d", tt.selector, tt.got, want)
}
}
if macOSAvailable(13) == nil {
for _, tt := range []struct {
name, class, selector string
call func() (string, error)
}{
{"automount", "VZVirtioFileSystemDeviceConfiguration", "macOSGuestAutomountTag", MacOSGuestAutomountTag},
{"clipboard", "VZSpiceAgentPortAttachment", "spiceAgentPortName", SpiceAgentPortAttachmentName},
} {
got, err := tt.call()
if err != nil {
t.Fatal(err)
}
if want := nativeClassString(tt.class, tt.selector); got != want {
t.Errorf("%s: got %q, want %q", tt.name, got, want)
}
}
}
if macOSAvailable(15) == nil {
want := pureobjc.Send[bool](pureobjc.ID(pureobjc.GetClass("VZGenericPlatformConfiguration")), pureobjc.RegisterName("isNestedVirtualizationSupported"))
if got := IsNestedVirtualizationSupported(); got != want {
t.Errorf("nested virtualization: got %v, want %v", got, want)
}
}
}
func nativeClassString(class, selector string) string {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
pool := pureobjc.ID(pureobjc.GetClass("NSAutoreleasePool")).Send(pureobjc.RegisterName("new"))
defer pool.Send(pureobjc.RegisterName("release"))
value := pureobjc.Send[pureobjc.ID](pureobjc.ID(pureobjc.GetClass(class)), pureobjc.RegisterName(selector))
return pureobjc.Send[string](value, pureobjc.RegisterName("UTF8String"))
}