@@ -103,15 +103,28 @@ def mkdump(base, size, x64 = false)
103
103
let ( :file_list ) do
104
104
double ( "Mixlib::Shellout" ,
105
105
error! : false ,
106
+ error? : false ,
106
107
stdout : <<~EOH
107
108
/opt/chefdk/shouldnt/matter
108
109
EOH
109
110
)
110
111
end
111
112
113
+ let ( :file_list_multiple ) do
114
+ double ( "Mixlib::Shellout" ,
115
+ error! : false ,
116
+ error? : false ,
117
+ stdout : <<~EOH
118
+ /opt/chefdk/first
119
+ /opt/chefdk/second
120
+ EOH
121
+ )
122
+ end
123
+
112
124
let ( :empty_list ) do
113
125
double ( "Mixlib::Shellout" ,
114
126
error! : false ,
127
+ error? : false ,
115
128
stdout : <<~EOH
116
129
EOH
117
130
)
@@ -130,6 +143,7 @@ def mkdump(base, size, x64 = false)
130
143
let ( :bad_list ) do
131
144
double ( "Mixlib::Shellout" ,
132
145
error! : false ,
146
+ error? : false ,
133
147
stdout : <<~EOH
134
148
/somewhere/other/than/install/dir
135
149
EOH
@@ -139,6 +153,7 @@ def mkdump(base, size, x64 = false)
139
153
let ( :bad_healthcheck ) do
140
154
double ( "Mixlib::Shellout" ,
141
155
error! : false ,
156
+ error? : false ,
142
157
stdout : <<~EOH
143
158
/bin/ls:
144
159
linux-vdso.so.1 => (0x00007fff583ff000)
@@ -161,6 +176,7 @@ def mkdump(base, size, x64 = false)
161
176
let ( :good_healthcheck ) do
162
177
double ( "Mixlib::Shellout" ,
163
178
error! : false ,
179
+ error? : false ,
164
180
stdout : <<~EOH
165
181
/bin/echo:
166
182
linux-vdso.so.1 => (0x00007fff8a6ee000)
@@ -174,6 +190,17 @@ def mkdump(base, size, x64 = false)
174
190
)
175
191
end
176
192
193
+ let ( :bad_exitstatus_healthcheck ) do
194
+ double ( "Mixlib::Shellout" ,
195
+ error! : -> { raise Mixlib ::ShellOut ::ShellCommandFailed } ,
196
+ error? : true ,
197
+ exitstatus : 135 ,
198
+ stdout : <<~EOH
199
+ /bin/echo:
200
+ EOH
201
+ )
202
+ end
203
+
177
204
it "raises an exception when there are external dependencies" do
178
205
allow ( subject ) . to receive ( :shellout )
179
206
. with ( "find /opt/chefdk/ -type f | xargs file | grep \" ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'" )
@@ -198,6 +225,33 @@ def mkdump(base, size, x64 = false)
198
225
expect { subject . run! } . to_not raise_error
199
226
end
200
227
228
+ it "does checks lld for each file if the initial bulk ldd command fails" do
229
+ allow ( subject ) . to receive ( :shellout )
230
+ . with ( "find /opt/chefdk/ -type f | xargs file | grep \" ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'" )
231
+ . and_return ( file_list_multiple )
232
+
233
+ # Bulk ldd command fails
234
+ allow ( subject ) . to receive ( :shellout )
235
+ . with ( "xargs ldd" , { input : "/opt/chefdk/first\n /opt/chefdk/second\n " } )
236
+ . and_return ( bad_exitstatus_healthcheck )
237
+
238
+ # First file ldd fails
239
+ allow ( subject ) . to receive ( :shellout )
240
+ . with ( "xargs ldd" , { input : "/opt/chefdk/first\n " } )
241
+ . and_return ( bad_exitstatus_healthcheck )
242
+
243
+ # Second file lld succeeds
244
+ allow ( subject ) . to receive ( :shellout )
245
+ . with ( "xargs ldd" , { input : "/opt/chefdk/second\n " } )
246
+ . and_return ( good_healthcheck )
247
+
248
+ output = capture_logging do
249
+ expect { subject . run! } . to_not raise_error
250
+ end
251
+ expect ( output ) . to match ( /Failed running xargs ldd with exit status 135 when resolving individually/ )
252
+ expect ( output ) . to match ( %r{Failed running xargs ldd with exit status 135 against: /opt/chefdk/first} )
253
+ end
254
+
201
255
it "will not perform dll base relocation checks" do
202
256
expect ( subject . relocation_checkable? ) . to be false
203
257
end
0 commit comments