@@ -19,6 +19,7 @@ package generate
19
19
import (
20
20
"bytes"
21
21
"path/filepath"
22
+ "strings"
22
23
"testing"
23
24
24
25
"github.com/NVIDIA/go-nvml/pkg/nvml"
@@ -66,7 +67,7 @@ func TestGenerateSpec(t *testing.T) {
66
67
cdiVersion: 0.5.0
67
68
containerEdits:
68
69
deviceNodes:
69
- - hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1 /dev/nvidiactl
70
+ - hostPath: {{ .driverRoot }} /dev/nvidiactl
70
71
path: /dev/nvidiactl
71
72
env:
72
73
- NVIDIA_VISIBLE_DEVICES=void
@@ -78,6 +79,13 @@ containerEdits:
78
79
- libcuda.so.1::/lib/x86_64-linux-gnu/libcuda.so
79
80
hookName: createContainer
80
81
path: /usr/bin/nvidia-cdi-hook
82
+ - args:
83
+ - nvidia-cdi-hook
84
+ - compat-libs
85
+ - --driver-version
86
+ - 999.88.77
87
+ hookName: createContainer
88
+ path: /usr/bin/nvidia-cdi-hook
81
89
- args:
82
90
- nvidia-cdi-hook
83
91
- update-ldcache
@@ -87,7 +95,7 @@ containerEdits:
87
95
path: /usr/bin/nvidia-cdi-hook
88
96
mounts:
89
97
- containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
90
- hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1 /lib/x86_64-linux-gnu/libcuda.so.999.88.77
98
+ hostPath: {{ .driverRoot }} /lib/x86_64-linux-gnu/libcuda.so.999.88.77
91
99
options:
92
100
- ro
93
101
- nosuid
@@ -96,12 +104,12 @@ containerEdits:
96
104
devices:
97
105
- containerEdits:
98
106
deviceNodes:
99
- - hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1 /dev/nvidia0
107
+ - hostPath: {{ .driverRoot }} /dev/nvidia0
100
108
path: /dev/nvidia0
101
109
name: "0"
102
110
- containerEdits:
103
111
deviceNodes:
104
- - hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1 /dev/nvidia0
112
+ - hostPath: {{ .driverRoot }} /dev/nvidia0
105
113
path: /dev/nvidia0
106
114
name: all
107
115
kind: example.com/device
@@ -144,7 +152,7 @@ kind: example.com/device
144
152
_ , err = spec .WriteTo (& buf )
145
153
require .NoError (t , err )
146
154
147
- require .Equal (t , tc .expectedSpec , buf .String ())
155
+ require .Equal (t , strings . ReplaceAll ( tc .expectedSpec , "{{ .driverRoot }}" , driverRoot ) , buf .String ())
148
156
})
149
157
}
150
158
}
0 commit comments