Skip to content

Commit 1499ac2

Browse files
[no-relnote] Add test to check CDI injection by default
Now that the NVIDIA Container Toolkit uses CDI injection by default. This does not trigger the code in the nvidia-container-cli that creates the empty files on the host. Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent b442fe8 commit 1499ac2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

tests/e2e/nvidia-container-toolkit_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,32 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
257257
Expect(libs).To(ContainElements([]string{"libcuda.so", "libcuda.so.1"}))
258258
})
259259
})
260+
261+
When("A container tries to create firmware files on the host", Ordered, func() {
262+
BeforeAll(func(ctx context.Context) {
263+
_, _, err := runner.Run("docker pull ubuntu")
264+
Expect(err).ToNot(HaveOccurred())
265+
266+
_, _, err = runner.Run(`docker build -t firmware-test --build-arg RM_VERSION="$(basename $(ls -d /lib/firmware/nvidia/*.*))" --build-arg CURRENT_DIR="$(pwd)" - <<EOF
267+
FROM ubuntu
268+
RUN mkdir -p /lib/firmware/nvidia/
269+
ARG RM_VERSION
270+
ARG CURRENT_DIR
271+
RUN ln -s /../../../../../../../../\$CURRENT_DIR /lib/firmware/nvidia/\$RM_VERSION
272+
EOF`)
273+
Expect(err).ToNot(HaveOccurred())
274+
})
275+
276+
It("should not fail when using CDI", func(ctx context.Context) {
277+
output, _, err := runner.Run("docker run --rm --runtime=nvidia --gpus=all firmware-test")
278+
Expect(err).ToNot(HaveOccurred())
279+
Expect(output).To(BeEmpty())
280+
})
281+
282+
It("should fail when using the nvidia-container-runtime-hook", Label("legacy"), func(ctx context.Context) {
283+
_, stderr, err := runner.Run("docker run --rm --runtime=runc --gpus=all firmware-test")
284+
Expect(err).To(HaveOccurred())
285+
Expect(stderr).To(ContainSubstring("nvidia-container-cli.real: mount error: path error:"))
286+
})
287+
})
260288
})

tests/e2e/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (r remoteRunner) Run(script string) (string, string, error) {
124124
// Run the script
125125
err = session.Run(script)
126126
if err != nil {
127-
return "", "", fmt.Errorf("script execution failed: %v\nSTDOUT: %s\nSTDERR: %s", err, stdout.String(), stderr.String())
127+
return "", stderr.String(), fmt.Errorf("script execution failed: %v\nSTDOUT: %s\nSTDERR: %s", err, stdout.String(), stderr.String())
128128
}
129129

130130
// Return stdout as string if no errors

0 commit comments

Comments
 (0)