Skip to content

Commit

Permalink
adding coverage of nvidia
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoote committed Feb 8, 2019
1 parent 92f9ded commit 6f8121f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rocker/templates/nvidia_snippet.Dockerfile.em
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu:/usr/local/lib/i386-linux-gn
COPY --from=glvnd /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json
@[else if image_distro_version == '18.04']@
RUN apt-get update && apt-get install -y --no-install-recommends \
libglvnd0\
libgl1 \
libglx0 \
libegl1 \
libgles2 \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libgles2 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=glvnd /usr/share/glvnd/egl_vendor.d/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json
@[end if]@
Expand Down
33 changes: 33 additions & 0 deletions test/test_nvidia.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@ def test_nvidia_extension_basic(self):
nvidia_plugin = plugins['nvidia']
self.assertEqual(nvidia_plugin.get_name(), 'nvidia')
self.assertTrue(plugin_load_parser_correctly(nvidia_plugin))

p = nvidia_plugin()
mock_cliargs = {'base_image': 'ubuntu:xenial'}
snippet = p.get_snippet(mock_cliargs)

self.assertIn('COPY --from=glvnd /usr/local/lib/x86_64-linux-gnu /usr/local/lib/x86_64-linux-gnu', snippet)
self.assertIn('COPY --from=glvnd /usr/local/lib/i386-linux-gnu /usr/local/lib/i386-linux-gnu', snippet)
self.assertIn('ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu:/usr/local/lib/i386-linux-gnu', snippet)
self.assertIn('NVIDIA_VISIBLE_DEVICES', snippet)
self.assertIn('NVIDIA_DRIVER_CAPABILITIES', snippet)

mock_cliargs = {'base_image': 'ubuntu:bionic'}
snippet = p.get_snippet(mock_cliargs)
self.assertIn('RUN apt-get update && apt-get install -y --no-install-recommends', snippet)
self.assertIn(' libglvnd0 ', snippet)
self.assertIn(' libgles2 ', snippet)
self.assertIn('COPY --from=glvnd /usr/share/glvnd/egl_vendor.d/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json', snippet)

self.assertIn('NVIDIA_VISIBLE_DEVICES', snippet)
self.assertIn('NVIDIA_DRIVER_CAPABILITIES', snippet)


preamble = p.get_preamble(mock_cliargs)
self.assertIn('FROM nvidia/opengl:1.0-glvnd-devel-', preamble)

docker_args = p.get_docker_args(mock_cliargs)
self.assertIn(' -e DISPLAY -e TERM', docker_args)
self.assertIn(' -e QT_X11_NO_MITSHM=1', docker_args)
self.assertIn(' -e XAUTHORITY=', docker_args)
self.assertIn(' -v /tmp/.X11-unix:/tmp/.X11-unix ', docker_args)
self.assertIn(' -v /etc/localtime:/etc/localtime:ro ', docker_args)
self.assertIn(' --runtime=nvidia ', docker_args)
self.assertIn(' --security-opt seccomp=unconfined', docker_args)


def test_no_nvidia_glmark2(self):
Expand Down

0 comments on commit 6f8121f

Please sign in to comment.