MCPcopy Index your code
hub / github.com/coder/envbox / assertInnerFiles

Function assertInnerFiles

integration/gpu_test.go:178–195  ·  view source on GitHub ↗

assertInnerFiles checks that all the files matching the given pattern exist in the inner container.

(ctx context.Context, t *testing.T, containerID, pattern string, expected ...string)

Source from the content-addressed store, hash-verified

176// assertInnerFiles checks that all the files matching the given pattern exist in the
177// inner container.
178func assertInnerFiles(ctx context.Context, t *testing.T, containerID, pattern string, expected ...string) {
179 t.Helper()
180
181 // Get the list of files in the inner container.
182 // We need to use /bin/sh -c to avoid the shell interpreting the glob.
183 out, err := execContainerCmd(ctx, t, containerID, "docker", "exec", "workspace_cvm", "/bin/sh", "-c", "ls -1 "+pattern)
184 require.NoError(t, err, "failed to list inner container files")
185 innerFiles := strings.Split(strings.TrimSpace(out), "\n")
186
187 // Check that the expected files exist in the inner container.
188 missingFiles := make([]string, 0)
189 for _, expectedFile := range expected {
190 if !slices.Contains(innerFiles, expectedFile) {
191 missingFiles = append(missingFiles, expectedFile)
192 }
193 }
194 require.Empty(t, missingFiles, "missing files in inner container: %s", strings.Join(missingFiles, ", "))
195}
196
197// assertInnerNvidiaSMI checks that nvidia-smi runs successfully in the inner
198// container.

Callers 1

TestDocker_NvidiaFunction · 0.85

Calls 1

execContainerCmdFunction · 0.85

Tested by

no test coverage detected