From 55236137ca29c538b1ec0b1f956d8e17edccb7a1 Mon Sep 17 00:00:00 2001 From: Anthony Cui Date: Tue, 13 Aug 2024 16:58:20 -0700 Subject: [PATCH] Update nvproxy parity tests to run in parallel. This test file now takes ~30 seconds instead of ~4 minutes. PiperOrigin-RevId: 662702276 --- .../devices/nvproxy/nvproxy_driver_parity_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go b/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go index 9203349d1..79f0c666c 100644 --- a/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go +++ b/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go @@ -81,13 +81,15 @@ func getDriverDefs(t *testing.T, runner *parser.Runner, version nvproxy.DriverVe // TestSupportedStructNames tests that all the structs listed in nvproxy are found in the driver // source code. func TestSupportedStructNames(t *testing.T) { - f, runner := createParserRunner(t) - defer f.Close() nvproxy.Init() // Run the parser on all supported driver versions nvproxy.ForEachSupportDriver(func(version nvproxy.DriverVersion, checksum string) { t.Run(version.String(), func(t *testing.T) { + t.Parallel() + f, runner := createParserRunner(t) + defer f.Close() + structNames, defs := getDriverDefs(t, runner, version) // Check that every struct is found in the parser output. @@ -102,13 +104,17 @@ func TestSupportedStructNames(t *testing.T) { }) } +// TestStructDefinitionParity tests that the struct definitions in nvproxy are the same as the +// definitions in the driver source code. func TestStructDefinitionParity(t *testing.T) { - f, runner := createParserRunner(t) - defer f.Close() nvproxy.Init() nvproxy.ForEachSupportDriver(func(version nvproxy.DriverVersion, checksum string) { t.Run(version.String(), func(t *testing.T) { + t.Parallel() + f, runner := createParserRunner(t) + defer f.Close() + _, defs := getDriverDefs(t, runner, version) nvproxyDefs, ok := nvproxy.SupportedStructTypes(version)