@@ -38,11 +38,22 @@ func TestLDCacheUpdateHook(t *testing.T) {
38
38
mounts []Mount
39
39
mountError error
40
40
expectedError error
41
- expectedArgs [] string
41
+ expectedHooks [] Hook
42
42
}{
43
43
{
44
- description : "empty mounts" ,
45
- expectedArgs : []string {"nvidia-cdi-hook" , "update-ldcache" },
44
+ description : "empty mounts" ,
45
+ expectedHooks : []Hook {
46
+ {
47
+ Lifecycle : "createContainer" ,
48
+ Path : testNvidiaCDIHookPath ,
49
+ Args : []string {"nvidia-cdi-hook" , "create-soname-symlinks" },
50
+ },
51
+ {
52
+ Lifecycle : "createContainer" ,
53
+ Path : testNvidiaCDIHookPath ,
54
+ Args : []string {"nvidia-cdi-hook" , "update-ldcache" },
55
+ },
56
+ },
46
57
},
47
58
{
48
59
description : "mount error" ,
@@ -65,7 +76,18 @@ func TestLDCacheUpdateHook(t *testing.T) {
65
76
Path : "/usr/local/lib/libbar.so" ,
66
77
},
67
78
},
68
- expectedArgs : []string {"nvidia-cdi-hook" , "update-ldcache" , "--folder" , "/usr/local/lib" , "--folder" , "/usr/local/libother" },
79
+ expectedHooks : []Hook {
80
+ {
81
+ Lifecycle : "createContainer" ,
82
+ Path : testNvidiaCDIHookPath ,
83
+ Args : []string {"nvidia-cdi-hook" , "create-soname-symlinks" , "--folder" , "/usr/local/lib" , "--folder" , "/usr/local/libother" },
84
+ },
85
+ {
86
+ Lifecycle : "createContainer" ,
87
+ Path : testNvidiaCDIHookPath ,
88
+ Args : []string {"nvidia-cdi-hook" , "update-ldcache" , "--folder" , "/usr/local/lib" , "--folder" , "/usr/local/libother" },
89
+ },
90
+ },
69
91
},
70
92
{
71
93
description : "host paths are ignored" ,
@@ -75,12 +97,34 @@ func TestLDCacheUpdateHook(t *testing.T) {
75
97
Path : "/usr/local/lib/libfoo.so" ,
76
98
},
77
99
},
78
- expectedArgs : []string {"nvidia-cdi-hook" , "update-ldcache" , "--folder" , "/usr/local/lib" },
100
+ expectedHooks : []Hook {
101
+ {
102
+ Lifecycle : "createContainer" ,
103
+ Path : testNvidiaCDIHookPath ,
104
+ Args : []string {"nvidia-cdi-hook" , "create-soname-symlinks" , "--folder" , "/usr/local/lib" },
105
+ },
106
+ {
107
+ Lifecycle : "createContainer" ,
108
+ Path : testNvidiaCDIHookPath ,
109
+ Args : []string {"nvidia-cdi-hook" , "update-ldcache" , "--folder" , "/usr/local/lib" },
110
+ },
111
+ },
79
112
},
80
113
{
81
114
description : "explicit ldconfig path is passed" ,
82
115
ldconfigPath : testLdconfigPath ,
83
- expectedArgs : []string {"nvidia-cdi-hook" , "update-ldcache" , "--ldconfig-path" , testLdconfigPath },
116
+ expectedHooks : []Hook {
117
+ {
118
+ Lifecycle : "createContainer" ,
119
+ Path : testNvidiaCDIHookPath ,
120
+ Args : []string {"nvidia-cdi-hook" , "create-soname-symlinks" , "--ldconfig-path" , testLdconfigPath },
121
+ },
122
+ {
123
+ Lifecycle : "createContainer" ,
124
+ Path : testNvidiaCDIHookPath ,
125
+ Args : []string {"nvidia-cdi-hook" , "update-ldcache" , "--ldconfig-path" , testLdconfigPath },
126
+ },
127
+ },
84
128
},
85
129
}
86
130
@@ -91,12 +135,6 @@ func TestLDCacheUpdateHook(t *testing.T) {
91
135
return tc .mounts , tc .mountError
92
136
},
93
137
}
94
- expectedHook := Hook {
95
- Path : testNvidiaCDIHookPath ,
96
- Args : tc .expectedArgs ,
97
- Lifecycle : "createContainer" ,
98
- }
99
-
100
138
d , err := NewLDCacheUpdateHook (logger , mountMock , testNvidiaCDIHookPath , tc .ldconfigPath )
101
139
require .NoError (t , err )
102
140
@@ -110,9 +148,7 @@ func TestLDCacheUpdateHook(t *testing.T) {
110
148
}
111
149
112
150
require .NoError (t , err )
113
- require .Len (t , hooks , 1 )
114
-
115
- require .EqualValues (t , hooks [0 ], expectedHook )
151
+ require .EqualValues (t , tc .expectedHooks , hooks )
116
152
117
153
devices , err := d .Devices ()
118
154
require .NoError (t , err )
0 commit comments