@@ -40,10 +40,11 @@ func TestApp(t *testing.T) {
4040 hostRoot := filepath .Join (moduleRoot , "testdata" , "lookup" , "rootfs-1" )
4141
4242 testCases := []struct {
43- description string
44- args []string
45- expectedToolkitConfig string
46- expectedRuntimeConfig string
43+ description string
44+ args []string
45+ expectedToolkitConfig string
46+ expectedRuntimeConfig string
47+ expectedDropInRuntimeConfig string
4748 }{
4849 {
4950 description : "no args" ,
@@ -285,7 +286,10 @@ swarm-resource = ""
285286[nvidia-ctk]
286287 path = "{{ .toolkitRoot }}/toolkit/nvidia-ctk"
287288` ,
288- expectedRuntimeConfig : `version = 2
289+ expectedRuntimeConfig : `imports = ["{{ .testRoot }}/config.d/*.toml"]
290+ version = 2
291+ ` ,
292+ expectedDropInRuntimeConfig : `version = 2
289293
290294[plugins]
291295
@@ -371,7 +375,10 @@ swarm-resource = ""
371375[nvidia-ctk]
372376 path = "{{ .toolkitRoot }}/toolkit/nvidia-ctk"
373377` ,
374- expectedRuntimeConfig : `version = 2
378+ expectedRuntimeConfig : `imports = ["{{ .testRoot }}/config.d/*.toml"]
379+ version = 2
380+ ` ,
381+ expectedDropInRuntimeConfig : `version = 2
375382
376383[plugins]
377384
@@ -418,6 +425,7 @@ swarm-resource = ""
418425
419426 cdiOutputDir := filepath .Join (testRoot , "/var/run/cdi" )
420427 runtimeConfigFile := filepath .Join (testRoot , "config.file" )
428+ runtimeDropInConfigFile := filepath .Join (testRoot , "config.d/config.toml" )
421429
422430 toolkitRoot := filepath .Join (testRoot , "toolkit-test" )
423431 toolkitConfigFile := filepath .Join (toolkitRoot , "toolkit/.config/nvidia-container-runtime/config.toml" )
@@ -430,6 +438,7 @@ swarm-resource = ""
430438 "--no-daemon" ,
431439 "--cdi-output-dir=" + cdiOutputDir ,
432440 "--config=" + runtimeConfigFile ,
441+ "--drop-in-config=" + runtimeDropInConfigFile ,
433442 "--create-device-nodes=none" ,
434443 "--driver-root-ctr-path=" + hostRoot ,
435444 "--pid-file=" + filepath .Join (testRoot , "toolkit.pid" ),
@@ -446,10 +455,24 @@ swarm-resource = ""
446455 require .NoError (t , err )
447456 require .EqualValues (t , strings .ReplaceAll (tc .expectedToolkitConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (toolkitConfigFileContents ))
448457
449- require .FileExists (t , runtimeConfigFile )
450- runtimeConfigFileContents , err := os .ReadFile (runtimeConfigFile )
451- require .NoError (t , err )
452- require .EqualValues (t , strings .ReplaceAll (tc .expectedRuntimeConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeConfigFileContents ))
458+ if len (tc .expectedRuntimeConfig ) > 0 {
459+ require .FileExists (t , runtimeConfigFile )
460+ runtimeConfigFileContents , err := os .ReadFile (runtimeConfigFile )
461+ require .NoError (t , err )
462+ expected := strings .ReplaceAll (tc .expectedRuntimeConfig , "{{ .testRoot }}" , testRoot )
463+ require .Equal (t , strings .ReplaceAll (expected , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeConfigFileContents ))
464+ } else {
465+ require .NoFileExists (t , runtimeConfigFile )
466+ }
467+
468+ if len (tc .expectedDropInRuntimeConfig ) > 0 {
469+ require .FileExists (t , runtimeDropInConfigFile )
470+ runtimeDropInConfigFileContents , err := os .ReadFile (runtimeDropInConfigFile )
471+ require .NoError (t , err )
472+ require .Equal (t , strings .ReplaceAll (tc .expectedDropInRuntimeConfig , "{{ .toolkitRoot }}" , toolkitRoot ), string (runtimeDropInConfigFileContents ))
473+ } else {
474+ require .NoFileExists (t , runtimeDropInConfigFile )
475+ }
453476 })
454477 }
455478
0 commit comments