@@ -18,6 +18,7 @@ package e2e
1818
1919import (
2020 "context"
21+ "fmt"
2122 "path/filepath"
2223 "strings"
2324
@@ -297,4 +298,54 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
297298 Expect (err ).ToNot (HaveOccurred ())
298299 })
299300 })
301+
302+ When ("Running a container where the firmware folder resolves outside the container root" , Ordered , func () {
303+ var outputDir string
304+ BeforeAll (func (ctx context.Context ) {
305+ pwd , _ , err := runner .Run ("pwd" )
306+ Expect (err ).ToNot (HaveOccurred ())
307+ outputDir = filepath .Join (strings .TrimSpace (pwd ), "test-output" )
308+
309+ _ , _ , err = runner .Run (fmt .Sprintf ("mkdir -p %s" , outputDir ))
310+ Expect (err ).ToNot (HaveOccurred ())
311+
312+ _ , _ , err = runner .Run ("docker pull ubuntu" )
313+ Expect (err ).ToNot (HaveOccurred ())
314+
315+ dockerBuildCmd := fmt .Sprintf (`docker build -t firmware-test --build-arg RM_VERSION="$(basename $(ls -d /lib/firmware/nvidia/*.*))" --build-arg CURRENT_DIR=%q - <<EOF` , outputDir )
316+ dockerBuildDockerfile := `
317+ FROM ubuntu
318+ RUN mkdir -p /lib/firmware/nvidia/
319+ ARG RM_VERSION
320+ ARG CURRENT_DIR
321+ RUN ln -s /../../../../../../../../\$CURRENT_DIR /lib/firmware/nvidia/\$RM_VERSION
322+ EOF`
323+ _ , _ , err = runner .Run (dockerBuildCmd + dockerBuildDockerfile )
324+ Expect (err ).ToNot (HaveOccurred ())
325+ })
326+
327+ AfterAll (func (ctx context.Context ) {
328+ if outputDir != "" {
329+ runner .Run (fmt .Sprintf ("rm -rf %s" , outputDir ))
330+ }
331+ })
332+
333+ It ("should not fail when using CDI" , func (ctx context.Context ) {
334+ output , _ , err := runner .Run ("docker run --rm --runtime=nvidia --gpus=all firmware-test" )
335+ Expect (err ).ToNot (HaveOccurred ())
336+ Expect (output ).To (BeEmpty ())
337+
338+ output , _ , _ = runner .Run (fmt .Sprintf ("ls -A %s" , outputDir ))
339+ Expect (output ).To (BeEmpty ())
340+ })
341+
342+ It ("should fail when using the nvidia-container-runtime-hook" , Label ("legacy" ), func (ctx context.Context ) {
343+ _ , stderr , err := runner .Run ("docker run --rm --runtime=runc --gpus=all firmware-test" )
344+ Expect (err ).To (HaveOccurred ())
345+ Expect (stderr ).To (ContainSubstring ("nvidia-container-cli.real: mount error: path error:" ))
346+
347+ output , _ , _ := runner .Run (fmt .Sprintf ("ls -A %s" , outputDir ))
348+ Expect (output ).To (BeEmpty ())
349+ })
350+ })
300351})
0 commit comments