Skip to content

Commit

Permalink
Add nvproxy test to ensure ABI and struct name maps cover the same io…
Browse files Browse the repository at this point in the history
…ctls.

PiperOrigin-RevId: 658078138
  • Loading branch information
AC-Dap authored and gvisor-bot committed Jul 31, 2024
1 parent 4542eb5 commit 5b47d13
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/sentry/devices/nvproxy/nvproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,36 @@ func TestAllSupportedHashesPresent(t *testing.T) {
}
}
}

// TestABIStructNamesInSync tests that all the supported ioctls in an ABI version are also mapped
// by GetStructNames.
func TestABIStructNamesInSync(t *testing.T) {
Init()
for version, abiCons := range abis {
t.Run(version.String(), func(t *testing.T) {
abi := abiCons.cons()
structNames := abi.getStructNames()

for ioctl := range abi.frontendIoctl {
if _, ok := structNames.frontendNames[ioctl]; !ok {
t.Errorf("Frontend ioctl %#x not found in struct names for version %v", ioctl, version.String())
}
}
for ioctl := range abi.uvmIoctl {
if _, ok := structNames.uvmNames[ioctl]; !ok {
t.Errorf("UVM ioctl %#x not found in struct names for version %v", ioctl, version.String())
}
}
for ioctl := range abi.controlCmd {
if _, ok := structNames.controlNames[ioctl]; !ok {
t.Errorf("Control command %#x not found in struct names for version %v", ioctl, version.String())
}
}
for ioctl := range abi.allocationClass {
if _, ok := structNames.allocationNames[ioctl]; !ok {
t.Errorf("Alloc class %#x not found in struct names for version %v", ioctl, version.String())
}
}
})
}
}

0 comments on commit 5b47d13

Please sign in to comment.