blob: 51a284898015e96fa81e436eaefddace2d3606b8 [file] [log] [blame]
Patrick Ventureaa32a362018-12-13 10:52:33 -08001#include "data_interface_mock.hpp"
Patrick Venture84778b82019-06-26 20:11:09 -07002#include "flags.hpp"
Patrick Venture1f09d412019-06-19 16:01:06 -07003#include "status.hpp"
Patrick Venture5f2fcc42019-06-20 07:21:05 -07004#include "tool_errors.hpp"
Patrick Ventureaa32a362018-12-13 10:52:33 -08005#include "updater.hpp"
Patrick Venture55646de2019-05-16 10:06:26 -07006#include "updater_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07007#include "util.hpp"
Patrick Ventureaa32a362018-12-13 10:52:33 -08008
Jie Yang328f5202021-03-16 00:52:07 -07009#include <blobs-ipmid/blobs.hpp>
Patrick Venture8cdf9642020-09-30 09:41:51 -070010#include <ipmiblob/blob_errors.hpp>
Patrick Venture664c5bc2019-03-07 08:09:45 -080011#include <ipmiblob/test/blob_interface_mock.hpp>
Patrick Venture9b37b092020-05-28 20:58:57 -070012
Patrick Ventureaa32a362018-12-13 10:52:33 -080013#include <string>
Patrick Venture8cdf9642020-09-30 09:41:51 -070014#include <vector>
Patrick Ventureaa32a362018-12-13 10:52:33 -080015
Patrick Venture8cdf9642020-09-30 09:41:51 -070016#include <gmock/gmock.h>
Patrick Ventureaa32a362018-12-13 10:52:33 -080017#include <gtest/gtest.h>
18
Patrick Venture9b534f02018-12-13 16:10:02 -080019namespace host_tool
20{
21
Patrick Venture7dcca5d2019-05-15 12:32:33 -070022using ::testing::_;
Patrick Ventureaa32a362018-12-13 10:52:33 -080023using ::testing::Eq;
Jie Yang328f5202021-03-16 00:52:07 -070024using ::testing::IsEmpty;
Patrick Ventureaa32a362018-12-13 10:52:33 -080025using ::testing::Return;
Patrick Venture8cdf9642020-09-30 09:41:51 -070026using ::testing::Throw;
Patrick Ventureb58f5612019-05-07 09:22:07 -070027using ::testing::TypedEq;
Patrick Ventureaa32a362018-12-13 10:52:33 -080028
Patrick Venture1f09d412019-06-19 16:01:06 -070029class UpdateHandlerTest : public ::testing::Test
Patrick Venture55646de2019-05-16 10:06:26 -070030{
Patrick Venture1f09d412019-06-19 16:01:06 -070031 protected:
32 const std::uint16_t session = 0xbeef;
33
Patrick Venture55646de2019-05-16 10:06:26 -070034 DataInterfaceMock handlerMock;
35 ipmiblob::BlobInterfaceMock blobMock;
Patrick Venture1f09d412019-06-19 16:01:06 -070036 UpdateHandler updater{&blobMock, &handlerMock};
37};
Patrick Venture55646de2019-05-16 10:06:26 -070038
Patrick Venture1f09d412019-06-19 16:01:06 -070039TEST_F(UpdateHandlerTest, CheckAvailableSuccess)
40{
Patrick Venture55646de2019-05-16 10:06:26 -070041 EXPECT_CALL(blobMock, getBlobList())
Patrick Venture7dad86f2019-05-17 08:52:20 -070042 .WillOnce(
Patrick Venture1d5a31c2019-05-20 11:38:22 -070043 Return(std::vector<std::string>({ipmi_flash::staticLayoutBlobId})));
Patrick Venture55646de2019-05-16 10:06:26 -070044
Patrick Venture1d5a31c2019-05-20 11:38:22 -070045 EXPECT_TRUE(updater.checkAvailable(ipmi_flash::staticLayoutBlobId));
Patrick Venture55646de2019-05-16 10:06:26 -070046}
47
Patrick Venture8cdf9642020-09-30 09:41:51 -070048TEST_F(UpdateHandlerTest, CheckAvailableFailure)
49{
50 EXPECT_CALL(blobMock, getBlobList())
51 .WillOnce(Return(std::vector<std::string>()));
52
53 EXPECT_FALSE(updater.checkAvailable(ipmi_flash::staticLayoutBlobId));
54}
55
Patrick Venture1f09d412019-06-19 16:01:06 -070056TEST_F(UpdateHandlerTest, SendFileSuccess)
Patrick Venture55646de2019-05-16 10:06:26 -070057{
58 /* Call sendFile to verify it does what we expect. */
Patrick Venture55646de2019-05-16 10:06:26 -070059 std::string firmwareImage = "image.bin";
60
61 std::uint16_t supported =
62 static_cast<std::uint16_t>(
Patrick Venture84778b82019-06-26 20:11:09 -070063 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
64 static_cast<std::uint16_t>(
65 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
Patrick Venture55646de2019-05-16 10:06:26 -070066
67 EXPECT_CALL(handlerMock, supportedType())
Patrick Venture84778b82019-06-26 20:11:09 -070068 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
Patrick Venture55646de2019-05-16 10:06:26 -070069
Patrick Venture1f09d412019-06-19 16:01:06 -070070 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
Patrick Venture55646de2019-05-16 10:06:26 -070071 .WillOnce(Return(session));
72
Patrick Venture1f09d412019-06-19 16:01:06 -070073 EXPECT_CALL(handlerMock, sendContents(firmwareImage, session))
Patrick Venture55646de2019-05-16 10:06:26 -070074 .WillOnce(Return(true));
75
76 EXPECT_CALL(blobMock, closeBlob(session)).Times(1);
77
Patrick Venture1d5a31c2019-05-20 11:38:22 -070078 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage);
Patrick Venture55646de2019-05-16 10:06:26 -070079}
80
Patrick Venture8cdf9642020-09-30 09:41:51 -070081TEST_F(UpdateHandlerTest, SendFileExceptsOnBlobOpening)
82{
83 std::string firmwareImage = "image.bin";
84
85 std::uint16_t supported =
86 static_cast<std::uint16_t>(
87 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
88 static_cast<std::uint16_t>(
89 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
90
91 EXPECT_CALL(handlerMock, supportedType())
92 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
93
94 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
95 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
96
97 EXPECT_THROW(
98 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage),
99 ToolException);
100}
101
102TEST_F(UpdateHandlerTest, SendFileHandlerFailureCausesException)
103{
104 std::string firmwareImage = "image.bin";
105
106 std::uint16_t supported =
107 static_cast<std::uint16_t>(
108 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
109 static_cast<std::uint16_t>(
110 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
111
112 EXPECT_CALL(handlerMock, supportedType())
113 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
114
115 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
116 .WillOnce(Return(session));
117
118 EXPECT_CALL(handlerMock, sendContents(firmwareImage, session))
119 .WillOnce(Return(false));
120
121 EXPECT_CALL(blobMock, closeBlob(session)).Times(1);
122
123 EXPECT_THROW(
124 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage),
125 ToolException);
126}
127
Patrick Venture1f09d412019-06-19 16:01:06 -0700128TEST_F(UpdateHandlerTest, VerifyFileHandleReturnsTrueOnSuccess)
Patrick Ventureaa32a362018-12-13 10:52:33 -0800129{
Patrick Venture1f09d412019-06-19 16:01:06 -0700130 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
Patrick Ventureaa32a362018-12-13 10:52:33 -0800131 .WillOnce(Return(session));
Patrick Venture55646de2019-05-16 10:06:26 -0700132 EXPECT_CALL(blobMock, commit(session, _)).WillOnce(Return());
Patrick Venture1f09d412019-06-19 16:01:06 -0700133 ipmiblob::StatResponse verificationResponse = {};
134 /* the other details of the response are ignored, and should be. */
135 verificationResponse.metadata.push_back(
136 static_cast<std::uint8_t>(ipmi_flash::ActionStatus::success));
Patrick Venture7dcca5d2019-05-15 12:32:33 -0700137
Patrick Venture1f09d412019-06-19 16:01:06 -0700138 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
139 .WillOnce(Return(verificationResponse));
140 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
141
Brandon Kim6749ba12019-09-19 13:31:37 -0700142 EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId, false));
Patrick Venture1f09d412019-06-19 16:01:06 -0700143}
144
Patrick Venture8cdf9642020-09-30 09:41:51 -0700145TEST_F(UpdateHandlerTest, VerifyFileHandleSkipsPollingIfIgnoreStatus)
146{
147 /* if ignoreStatus, it'll skip polling for a verification result. */
148 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
149 .WillOnce(Return(session));
150 EXPECT_CALL(blobMock, commit(session, _)).WillOnce(Return());
151
152 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
153
154 EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId, true));
155}
156
157TEST_F(UpdateHandlerTest, VerifyFileConvertsOpenBlobExceptionToToolException)
158{
159 /* On open, it can except and this is converted to a ToolException. */
160 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
161 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
162 EXPECT_THROW(updater.verifyFile(ipmi_flash::verifyBlobId, false),
163 ToolException);
164}
165
166TEST_F(UpdateHandlerTest, VerifyFileCommitExceptionForwards)
167{
168 /* On commit, it can except. */
169 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
170 .WillOnce(Return(session));
171 EXPECT_CALL(blobMock, commit(session, _))
172 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
173 EXPECT_THROW(updater.verifyFile(ipmi_flash::verifyBlobId, false),
174 ToolException);
175}
176
Jie Yang328f5202021-03-16 00:52:07 -0700177TEST_F(UpdateHandlerTest, ReadVerisonReturnExpected)
178{
179 /* It can return as expected, when polling and readBytes succeeds. */
180 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
181 .WillOnce(Return(session));
182 ipmiblob::StatResponse readVersionResponse = {};
183 readVersionResponse.blob_state =
184 blobs::StateFlags::open_read | blobs::StateFlags::committed;
185 readVersionResponse.size = 10;
186 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
187 .WillOnce(Return(readVersionResponse));
188 std::vector<uint8_t> resp = {0x2d, 0xfe};
189 EXPECT_CALL(blobMock, readBytes(session, 0, _)).WillOnce(Return(resp));
190
191 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
192 EXPECT_EQ(resp, updater.readVersion(ipmi_flash::biosVersionBlobId));
193}
194
195TEST_F(UpdateHandlerTest, ReadVersionExceptionWhenPollingSucceedsReadBytesFails)
196{
197 /* On readBytes, it can except. */
198 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
199 .WillOnce(Return(session));
200 ipmiblob::StatResponse readVersionResponse = {};
201 readVersionResponse.blob_state =
202 blobs::StateFlags::open_read | blobs::StateFlags::committed;
203 readVersionResponse.size = 10;
204 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
205 .WillOnce(Return(readVersionResponse));
206 EXPECT_CALL(blobMock, readBytes(session, 0, _))
207 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
208 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
209 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
210 ToolException);
211}
212
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700213TEST_F(UpdateHandlerTest, ReadVersionReturnsErrorIfPollingFails)
Jie Yang328f5202021-03-16 00:52:07 -0700214{
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700215 /* It can throw an error, when polling fails. */
Jie Yang328f5202021-03-16 00:52:07 -0700216 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
217 .WillOnce(Return(session));
218 ipmiblob::StatResponse readVersionResponse = {};
219 readVersionResponse.blob_state = blobs::StateFlags::commit_error;
220 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
221 .WillOnce(Return(readVersionResponse));
222 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700223 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
224 ToolException);
Jie Yang328f5202021-03-16 00:52:07 -0700225}
226
227TEST_F(UpdateHandlerTest, ReadVersionCovertsOpenBlobExceptionToToolException)
228{
229 /* On open, it can except and this is converted to a ToolException. */
230 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
231 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
232 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
233 ToolException);
234}
235
Patrick Venture8cdf9642020-09-30 09:41:51 -0700236TEST_F(UpdateHandlerTest, CleanArtifactsSkipsCleanupIfUnableToOpen)
237{
238 /* It only tries to commit if it's able to open the blob. However, if
239 * committing fails, this error is ignored.
240 */
241 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
242 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
243 EXPECT_CALL(blobMock, commit(_, _)).Times(0);
244 EXPECT_CALL(blobMock, closeBlob(_)).Times(0);
245
246 updater.cleanArtifacts();
247}
248
249TEST_F(UpdateHandlerTest, CleanArtifactsIfOpenDoesClose)
250{
251 /* The closeBlob call is called even if commit excepts. */
252 std::uint16_t session = 0xa5eb;
253 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
254 .WillOnce(Return(session));
255 EXPECT_CALL(blobMock, commit(session, _))
256 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
257 EXPECT_CALL(blobMock, closeBlob(session));
258
259 updater.cleanArtifacts();
260}
261
262TEST_F(UpdateHandlerTest, CleanArtifactsSuccessPath)
263{
264 std::uint16_t session = 0xa5eb;
265 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
266 .WillOnce(Return(session));
267 EXPECT_CALL(blobMock, commit(session, _));
268 EXPECT_CALL(blobMock, closeBlob(session));
269
270 updater.cleanArtifacts();
271}
272
Patrick Venture1f09d412019-06-19 16:01:06 -0700273class UpdaterTest : public ::testing::Test
274{
275 protected:
Patrick Venture8cdf9642020-09-30 09:41:51 -0700276 static constexpr char image[] = "image.bin";
277 static constexpr char signature[] = "signature.bin";
278 static constexpr char layout[] = "static";
279 static constexpr char path[] = "/flash/static";
280
Patrick Venture1f09d412019-06-19 16:01:06 -0700281 ipmiblob::BlobInterfaceMock blobMock;
282 std::uint16_t session = 0xbeef;
Brandon Kim6749ba12019-09-19 13:31:37 -0700283 bool defaultIgnore = false;
Patrick Venture1f09d412019-06-19 16:01:06 -0700284};
285
Patrick Venture1f09d412019-06-19 16:01:06 -0700286TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess)
287{
Patrick Venture1f09d412019-06-19 16:01:06 -0700288 UpdateHandlerMock handler;
289
Patrick Venture8cdf9642020-09-30 09:41:51 -0700290 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
291 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
292 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
293 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700294 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
Patrick Venture1f09d412019-06-19 16:01:06 -0700295 .WillOnce(Return(true));
Brandon Kim6749ba12019-09-19 13:31:37 -0700296 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
Patrick Venture1f09d412019-06-19 16:01:06 -0700297 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700298 EXPECT_CALL(blobMock, getBlobList())
299 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture1f09d412019-06-19 16:01:06 -0700300
Willy Tu203ad802021-09-09 20:06:36 -0700301 updaterMain(&handler, &blobMock, image, signature, layout, defaultIgnore);
302}
303
304TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccessWithDeleteActiveBlob)
305{
306 UpdateHandlerMock handler;
307
308 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
309 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
310 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
311 .WillOnce(Return());
312 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
313 .WillOnce(Return(true));
314 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
315 .WillOnce(Return(true));
316 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
317 EXPECT_CALL(blobMock, deleteBlob(ipmi_flash::activeImageBlobId))
Patrick Venture28624212021-11-09 09:04:03 -0800318 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700319 EXPECT_CALL(blobMock, getBlobList())
320 .WillOnce(Return(std::vector<std::string>(
321 {ipmi_flash::staticLayoutBlobId, ipmi_flash::activeImageBlobId})));
322
323 updaterMain(&handler, &blobMock, image, signature, layout, defaultIgnore);
Brandon Kim6749ba12019-09-19 13:31:37 -0700324}
325
326TEST_F(UpdaterTest, UpdateMainReturnsSuccessWithIgnoreUpdate)
327{
Brandon Kim6749ba12019-09-19 13:31:37 -0700328 UpdateHandlerMock handler;
329 bool updateIgnore = true;
330
Patrick Venture8cdf9642020-09-30 09:41:51 -0700331 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
332 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
333 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
334 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700335 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
336 .WillOnce(Return(true));
337 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, updateIgnore))
338 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700339 EXPECT_CALL(blobMock, getBlobList())
340 .WillOnce(Return(std::vector<std::string>({})));
Brandon Kim6749ba12019-09-19 13:31:37 -0700341
Willy Tu203ad802021-09-09 20:06:36 -0700342 updaterMain(&handler, &blobMock, image, signature, layout, updateIgnore);
Patrick Venture1f09d412019-06-19 16:01:06 -0700343}
Patrick Venture9b534f02018-12-13 16:10:02 -0800344
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700345TEST_F(UpdaterTest, UpdateMainCleansUpOnFailure)
346{
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700347 UpdateHandlerMock handler;
348
Patrick Venture8cdf9642020-09-30 09:41:51 -0700349 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
350 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
351 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
352 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700353 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700354 .WillOnce(Return(false));
355 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
Willy Tu203ad802021-09-09 20:06:36 -0700356 EXPECT_CALL(blobMock, getBlobList())
357 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700358
Willy Tu203ad802021-09-09 20:06:36 -0700359 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
360 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700361 ToolException);
362}
363
364TEST_F(UpdaterTest, UpdateMainExceptsOnUpdateBlobFailure)
365{
366 UpdateHandlerMock handler;
367
368 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
369 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
370 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
371 .WillOnce(Return());
372 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
373 .WillOnce(Return(true));
374 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
375 .WillOnce(Return(false));
376 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
Willy Tu203ad802021-09-09 20:06:36 -0700377 EXPECT_CALL(blobMock, getBlobList())
378 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture8cdf9642020-09-30 09:41:51 -0700379
Willy Tu203ad802021-09-09 20:06:36 -0700380 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
381 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700382 ToolException);
383}
384
385TEST_F(UpdaterTest, UpdateMainExceptsIfAvailableNotFound)
386{
387 UpdateHandlerMock handler;
388
389 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(false));
390
Willy Tu203ad802021-09-09 20:06:36 -0700391 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
392 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700393 ToolException);
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700394}
395
Patrick Venture9b534f02018-12-13 16:10:02 -0800396} // namespace host_tool