|
17 | 17 | package config |
18 | 18 |
|
19 | 19 | import ( |
| 20 | + "bytes" |
20 | 21 | "io/ioutil" |
21 | 22 | "os" |
22 | 23 | "path/filepath" |
@@ -234,3 +235,47 @@ func TestGetConfig(t *testing.T) { |
234 | 235 | }) |
235 | 236 | } |
236 | 237 | } |
| 238 | + |
| 239 | +func TestConfigDefault(t *testing.T) { |
| 240 | + config, err := getDefault() |
| 241 | + require.NoError(t, err) |
| 242 | + |
| 243 | + buffer := new(bytes.Buffer) |
| 244 | + _, err = config.Save(buffer) |
| 245 | + require.NoError(t, err) |
| 246 | + |
| 247 | + var lines []string |
| 248 | + for _, l := range strings.Split(buffer.String(), "\n") { |
| 249 | + l = strings.TrimSpace(l) |
| 250 | + if strings.HasPrefix(l, "# ") { |
| 251 | + l = "#" + strings.TrimPrefix(l, "# ") |
| 252 | + } |
| 253 | + lines = append(lines, l) |
| 254 | + } |
| 255 | + |
| 256 | + // We take the lines from the config that was included in previous packages. |
| 257 | + expectedLines := []string{ |
| 258 | + "disable-require = false", |
| 259 | + "#swarm-resource = \"DOCKER_RESOURCE_GPU\"", |
| 260 | + "#accept-nvidia-visible-devices-envvar-when-unprivileged = true", |
| 261 | + "#accept-nvidia-visible-devices-as-volume-mounts = false", |
| 262 | + |
| 263 | + "#root = \"/run/nvidia/driver\"", |
| 264 | + "#path = \"/usr/bin/nvidia-container-cli\"", |
| 265 | + "environment = []", |
| 266 | + "#debug = \"/var/log/nvidia-container-toolkit.log\"", |
| 267 | + "#ldcache = \"/etc/ld.so.cache\"", |
| 268 | + "load-kmods = true", |
| 269 | + "#no-cgroups = false", |
| 270 | + "#user = \"root:video\"", |
| 271 | + |
| 272 | + "[nvidia-container-runtime]", |
| 273 | + "#debug = \"/var/log/nvidia-container-runtime.log\"", |
| 274 | + "log-level = \"info\"", |
| 275 | + "mode = \"auto\"", |
| 276 | + |
| 277 | + "mount-spec-path = \"/etc/nvidia-container-runtime/host-files-for-container.d\"", |
| 278 | + } |
| 279 | + |
| 280 | + require.Subset(t, lines, expectedLines) |
| 281 | +} |
0 commit comments