blob: cf6cf502bf105326911d1a9478338debb037da04 [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::Return;
Patrick Venture8cdf9642020-09-30 09:41:51 -070024using ::testing::Throw;
Patrick Ventureb58f5612019-05-07 09:22:07 -070025using ::testing::TypedEq;
Patrick Ventureaa32a362018-12-13 10:52:33 -080026
Patrick Venture1f09d412019-06-19 16:01:06 -070027class UpdateHandlerTest : public ::testing::Test
Patrick Venture55646de2019-05-16 10:06:26 -070028{
Patrick Venture1f09d412019-06-19 16:01:06 -070029 protected:
30 const std::uint16_t session = 0xbeef;
31
Patrick Venture55646de2019-05-16 10:06:26 -070032 DataInterfaceMock handlerMock;
33 ipmiblob::BlobInterfaceMock blobMock;
Patrick Venture1f09d412019-06-19 16:01:06 -070034 UpdateHandler updater{&blobMock, &handlerMock};
35};
Patrick Venture55646de2019-05-16 10:06:26 -070036
Patrick Venture1f09d412019-06-19 16:01:06 -070037TEST_F(UpdateHandlerTest, CheckAvailableSuccess)
38{
Patrick Venture55646de2019-05-16 10:06:26 -070039 EXPECT_CALL(blobMock, getBlobList())
Patrick Venture7dad86f2019-05-17 08:52:20 -070040 .WillOnce(
Patrick Venture1d5a31c2019-05-20 11:38:22 -070041 Return(std::vector<std::string>({ipmi_flash::staticLayoutBlobId})));
Patrick Venture55646de2019-05-16 10:06:26 -070042
Patrick Venture1d5a31c2019-05-20 11:38:22 -070043 EXPECT_TRUE(updater.checkAvailable(ipmi_flash::staticLayoutBlobId));
Patrick Venture55646de2019-05-16 10:06:26 -070044}
45
Patrick Venture8cdf9642020-09-30 09:41:51 -070046TEST_F(UpdateHandlerTest, CheckAvailableFailure)
47{
48 EXPECT_CALL(blobMock, getBlobList())
49 .WillOnce(Return(std::vector<std::string>()));
50
51 EXPECT_FALSE(updater.checkAvailable(ipmi_flash::staticLayoutBlobId));
52}
53
Patrick Venture1f09d412019-06-19 16:01:06 -070054TEST_F(UpdateHandlerTest, SendFileSuccess)
Patrick Venture55646de2019-05-16 10:06:26 -070055{
56 /* Call sendFile to verify it does what we expect. */
Patrick Venture55646de2019-05-16 10:06:26 -070057 std::string firmwareImage = "image.bin";
58
59 std::uint16_t supported =
60 static_cast<std::uint16_t>(
Patrick Venture84778b82019-06-26 20:11:09 -070061 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
62 static_cast<std::uint16_t>(
63 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
Patrick Venture55646de2019-05-16 10:06:26 -070064
65 EXPECT_CALL(handlerMock, supportedType())
Patrick Venture84778b82019-06-26 20:11:09 -070066 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
Patrick Venture55646de2019-05-16 10:06:26 -070067
Patrick Venture1f09d412019-06-19 16:01:06 -070068 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
Patrick Venture55646de2019-05-16 10:06:26 -070069 .WillOnce(Return(session));
70
Patrick Venture1f09d412019-06-19 16:01:06 -070071 EXPECT_CALL(handlerMock, sendContents(firmwareImage, session))
Patrick Venture55646de2019-05-16 10:06:26 -070072 .WillOnce(Return(true));
73
74 EXPECT_CALL(blobMock, closeBlob(session)).Times(1);
75
Patrick Venture1d5a31c2019-05-20 11:38:22 -070076 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage);
Patrick Venture55646de2019-05-16 10:06:26 -070077}
78
Patrick Venture8cdf9642020-09-30 09:41:51 -070079TEST_F(UpdateHandlerTest, SendFileExceptsOnBlobOpening)
80{
81 std::string firmwareImage = "image.bin";
82
83 std::uint16_t supported =
84 static_cast<std::uint16_t>(
85 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
86 static_cast<std::uint16_t>(
87 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
88
89 EXPECT_CALL(handlerMock, supportedType())
90 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
91
92 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
93 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
94
95 EXPECT_THROW(
96 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage),
97 ToolException);
98}
99
100TEST_F(UpdateHandlerTest, SendFileHandlerFailureCausesException)
101{
102 std::string firmwareImage = "image.bin";
103
104 std::uint16_t supported =
105 static_cast<std::uint16_t>(
106 ipmi_flash::FirmwareFlags::UpdateFlags::lpc) |
107 static_cast<std::uint16_t>(
108 ipmi_flash::FirmwareFlags::UpdateFlags::openWrite);
109
110 EXPECT_CALL(handlerMock, supportedType())
111 .WillOnce(Return(ipmi_flash::FirmwareFlags::UpdateFlags::lpc));
112
113 EXPECT_CALL(blobMock, openBlob(ipmi_flash::staticLayoutBlobId, supported))
114 .WillOnce(Return(session));
115
116 EXPECT_CALL(handlerMock, sendContents(firmwareImage, session))
117 .WillOnce(Return(false));
118
119 EXPECT_CALL(blobMock, closeBlob(session)).Times(1);
120
121 EXPECT_THROW(
122 updater.sendFile(ipmi_flash::staticLayoutBlobId, firmwareImage),
123 ToolException);
124}
125
Patrick Venture1f09d412019-06-19 16:01:06 -0700126TEST_F(UpdateHandlerTest, VerifyFileHandleReturnsTrueOnSuccess)
Patrick Ventureaa32a362018-12-13 10:52:33 -0800127{
Patrick Venture1f09d412019-06-19 16:01:06 -0700128 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
Patrick Ventureaa32a362018-12-13 10:52:33 -0800129 .WillOnce(Return(session));
Patrick Venture55646de2019-05-16 10:06:26 -0700130 EXPECT_CALL(blobMock, commit(session, _)).WillOnce(Return());
Patrick Venture1f09d412019-06-19 16:01:06 -0700131 ipmiblob::StatResponse verificationResponse = {};
132 /* the other details of the response are ignored, and should be. */
133 verificationResponse.metadata.push_back(
134 static_cast<std::uint8_t>(ipmi_flash::ActionStatus::success));
Patrick Venture7dcca5d2019-05-15 12:32:33 -0700135
Patrick Venture1f09d412019-06-19 16:01:06 -0700136 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
137 .WillOnce(Return(verificationResponse));
138 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
139
Brandon Kim6749ba12019-09-19 13:31:37 -0700140 EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId, false));
Patrick Venture1f09d412019-06-19 16:01:06 -0700141}
142
Patrick Venture8cdf9642020-09-30 09:41:51 -0700143TEST_F(UpdateHandlerTest, VerifyFileHandleSkipsPollingIfIgnoreStatus)
144{
145 /* if ignoreStatus, it'll skip polling for a verification result. */
146 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
147 .WillOnce(Return(session));
148 EXPECT_CALL(blobMock, commit(session, _)).WillOnce(Return());
149
150 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
151
152 EXPECT_TRUE(updater.verifyFile(ipmi_flash::verifyBlobId, true));
153}
154
155TEST_F(UpdateHandlerTest, VerifyFileConvertsOpenBlobExceptionToToolException)
156{
157 /* On open, it can except and this is converted to a ToolException. */
158 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
159 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
160 EXPECT_THROW(updater.verifyFile(ipmi_flash::verifyBlobId, false),
161 ToolException);
162}
163
164TEST_F(UpdateHandlerTest, VerifyFileCommitExceptionForwards)
165{
166 /* On commit, it can except. */
167 EXPECT_CALL(blobMock, openBlob(ipmi_flash::verifyBlobId, _))
168 .WillOnce(Return(session));
169 EXPECT_CALL(blobMock, commit(session, _))
170 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
171 EXPECT_THROW(updater.verifyFile(ipmi_flash::verifyBlobId, false),
172 ToolException);
173}
174
Jie Yang328f5202021-03-16 00:52:07 -0700175TEST_F(UpdateHandlerTest, ReadVerisonReturnExpected)
176{
177 /* It can return as expected, when polling and readBytes succeeds. */
178 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
179 .WillOnce(Return(session));
180 ipmiblob::StatResponse readVersionResponse = {};
181 readVersionResponse.blob_state =
182 blobs::StateFlags::open_read | blobs::StateFlags::committed;
183 readVersionResponse.size = 10;
184 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
185 .WillOnce(Return(readVersionResponse));
186 std::vector<uint8_t> resp = {0x2d, 0xfe};
187 EXPECT_CALL(blobMock, readBytes(session, 0, _)).WillOnce(Return(resp));
188
189 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
190 EXPECT_EQ(resp, updater.readVersion(ipmi_flash::biosVersionBlobId));
191}
192
193TEST_F(UpdateHandlerTest, ReadVersionExceptionWhenPollingSucceedsReadBytesFails)
194{
195 /* On readBytes, it can except. */
196 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
197 .WillOnce(Return(session));
198 ipmiblob::StatResponse readVersionResponse = {};
199 readVersionResponse.blob_state =
200 blobs::StateFlags::open_read | blobs::StateFlags::committed;
201 readVersionResponse.size = 10;
202 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
203 .WillOnce(Return(readVersionResponse));
204 EXPECT_CALL(blobMock, readBytes(session, 0, _))
205 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
206 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
207 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
208 ToolException);
209}
210
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700211TEST_F(UpdateHandlerTest, ReadVersionReturnsErrorIfPollingFails)
Jie Yang328f5202021-03-16 00:52:07 -0700212{
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700213 /* It can throw an error, when polling fails. */
Jie Yang328f5202021-03-16 00:52:07 -0700214 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
215 .WillOnce(Return(session));
216 ipmiblob::StatResponse readVersionResponse = {};
217 readVersionResponse.blob_state = blobs::StateFlags::commit_error;
218 EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
219 .WillOnce(Return(readVersionResponse));
220 EXPECT_CALL(blobMock, closeBlob(session)).WillOnce(Return());
William A. Kennington IIIf88bcf32021-10-14 02:15:10 -0700221 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
222 ToolException);
Jie Yang328f5202021-03-16 00:52:07 -0700223}
224
225TEST_F(UpdateHandlerTest, ReadVersionCovertsOpenBlobExceptionToToolException)
226{
227 /* On open, it can except and this is converted to a ToolException. */
228 EXPECT_CALL(blobMock, openBlob(ipmi_flash::biosVersionBlobId, _))
229 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
230 EXPECT_THROW(updater.readVersion(ipmi_flash::biosVersionBlobId),
231 ToolException);
232}
233
Patrick Venture8cdf9642020-09-30 09:41:51 -0700234TEST_F(UpdateHandlerTest, CleanArtifactsSkipsCleanupIfUnableToOpen)
235{
236 /* It only tries to commit if it's able to open the blob. However, if
237 * committing fails, this error is ignored.
238 */
239 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
240 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
241 EXPECT_CALL(blobMock, commit(_, _)).Times(0);
242 EXPECT_CALL(blobMock, closeBlob(_)).Times(0);
243
244 updater.cleanArtifacts();
245}
246
247TEST_F(UpdateHandlerTest, CleanArtifactsIfOpenDoesClose)
248{
249 /* The closeBlob call is called even if commit excepts. */
250 std::uint16_t session = 0xa5eb;
251 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
252 .WillOnce(Return(session));
253 EXPECT_CALL(blobMock, commit(session, _))
254 .WillOnce(Throw(ipmiblob::BlobException("asdf")));
255 EXPECT_CALL(blobMock, closeBlob(session));
256
257 updater.cleanArtifacts();
258}
259
260TEST_F(UpdateHandlerTest, CleanArtifactsSuccessPath)
261{
262 std::uint16_t session = 0xa5eb;
263 EXPECT_CALL(blobMock, openBlob(ipmi_flash::cleanupBlobId, _))
264 .WillOnce(Return(session));
265 EXPECT_CALL(blobMock, commit(session, _));
266 EXPECT_CALL(blobMock, closeBlob(session));
267
268 updater.cleanArtifacts();
269}
270
Patrick Venture1f09d412019-06-19 16:01:06 -0700271class UpdaterTest : public ::testing::Test
272{
273 protected:
Patrick Venture8cdf9642020-09-30 09:41:51 -0700274 static constexpr char image[] = "image.bin";
275 static constexpr char signature[] = "signature.bin";
276 static constexpr char layout[] = "static";
277 static constexpr char path[] = "/flash/static";
278
Patrick Venture1f09d412019-06-19 16:01:06 -0700279 ipmiblob::BlobInterfaceMock blobMock;
280 std::uint16_t session = 0xbeef;
Brandon Kim6749ba12019-09-19 13:31:37 -0700281 bool defaultIgnore = false;
Patrick Venture1f09d412019-06-19 16:01:06 -0700282};
283
Patrick Venture1f09d412019-06-19 16:01:06 -0700284TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess)
285{
Patrick Venture1f09d412019-06-19 16:01:06 -0700286 UpdateHandlerMock handler;
287
Patrick Venture8cdf9642020-09-30 09:41:51 -0700288 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
289 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
290 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
291 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700292 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
Patrick Venture1f09d412019-06-19 16:01:06 -0700293 .WillOnce(Return(true));
Brandon Kim6749ba12019-09-19 13:31:37 -0700294 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
Patrick Venture1f09d412019-06-19 16:01:06 -0700295 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700296 EXPECT_CALL(blobMock, getBlobList())
297 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture1f09d412019-06-19 16:01:06 -0700298
Willy Tu203ad802021-09-09 20:06:36 -0700299 updaterMain(&handler, &blobMock, image, signature, layout, defaultIgnore);
300}
301
302TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccessWithDeleteActiveBlob)
303{
304 UpdateHandlerMock handler;
305
306 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
307 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
308 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
309 .WillOnce(Return());
310 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
311 .WillOnce(Return(true));
312 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
313 .WillOnce(Return(true));
314 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
315 EXPECT_CALL(blobMock, deleteBlob(ipmi_flash::activeImageBlobId))
Patrick Venture28624212021-11-09 09:04:03 -0800316 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700317 EXPECT_CALL(blobMock, getBlobList())
318 .WillOnce(Return(std::vector<std::string>(
319 {ipmi_flash::staticLayoutBlobId, ipmi_flash::activeImageBlobId})));
320
321 updaterMain(&handler, &blobMock, image, signature, layout, defaultIgnore);
Brandon Kim6749ba12019-09-19 13:31:37 -0700322}
323
324TEST_F(UpdaterTest, UpdateMainReturnsSuccessWithIgnoreUpdate)
325{
Brandon Kim6749ba12019-09-19 13:31:37 -0700326 UpdateHandlerMock handler;
327 bool updateIgnore = true;
328
Patrick Venture8cdf9642020-09-30 09:41:51 -0700329 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
330 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
331 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
332 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700333 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
334 .WillOnce(Return(true));
335 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, updateIgnore))
336 .WillOnce(Return(true));
Willy Tu203ad802021-09-09 20:06:36 -0700337 EXPECT_CALL(blobMock, getBlobList())
338 .WillOnce(Return(std::vector<std::string>({})));
Brandon Kim6749ba12019-09-19 13:31:37 -0700339
Willy Tu203ad802021-09-09 20:06:36 -0700340 updaterMain(&handler, &blobMock, image, signature, layout, updateIgnore);
Patrick Venture1f09d412019-06-19 16:01:06 -0700341}
Patrick Venture9b534f02018-12-13 16:10:02 -0800342
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700343TEST_F(UpdaterTest, UpdateMainCleansUpOnFailure)
344{
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700345 UpdateHandlerMock handler;
346
Patrick Venture8cdf9642020-09-30 09:41:51 -0700347 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
348 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
349 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
350 .WillOnce(Return());
Brandon Kim6749ba12019-09-19 13:31:37 -0700351 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700352 .WillOnce(Return(false));
353 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
Willy Tu203ad802021-09-09 20:06:36 -0700354 EXPECT_CALL(blobMock, getBlobList())
355 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700356
Willy Tu203ad802021-09-09 20:06:36 -0700357 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
358 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700359 ToolException);
360}
361
362TEST_F(UpdaterTest, UpdateMainExceptsOnUpdateBlobFailure)
363{
364 UpdateHandlerMock handler;
365
366 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(true));
367 EXPECT_CALL(handler, sendFile(path, image)).WillOnce(Return());
368 EXPECT_CALL(handler, sendFile(ipmi_flash::hashBlobId, signature))
369 .WillOnce(Return());
370 EXPECT_CALL(handler, verifyFile(ipmi_flash::verifyBlobId, defaultIgnore))
371 .WillOnce(Return(true));
372 EXPECT_CALL(handler, verifyFile(ipmi_flash::updateBlobId, defaultIgnore))
373 .WillOnce(Return(false));
374 EXPECT_CALL(handler, cleanArtifacts()).WillOnce(Return());
Willy Tu203ad802021-09-09 20:06:36 -0700375 EXPECT_CALL(blobMock, getBlobList())
376 .WillOnce(Return(std::vector<std::string>({})));
Patrick Venture8cdf9642020-09-30 09:41:51 -0700377
Willy Tu203ad802021-09-09 20:06:36 -0700378 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
379 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700380 ToolException);
381}
382
383TEST_F(UpdaterTest, UpdateMainExceptsIfAvailableNotFound)
384{
385 UpdateHandlerMock handler;
386
387 EXPECT_CALL(handler, checkAvailable(path)).WillOnce(Return(false));
388
Willy Tu203ad802021-09-09 20:06:36 -0700389 EXPECT_THROW(updaterMain(&handler, &blobMock, image, signature, layout,
390 defaultIgnore),
Patrick Venture8cdf9642020-09-30 09:41:51 -0700391 ToolException);
Patrick Venture5f2fcc42019-06-20 07:21:05 -0700392}
393
Patrick Venture9b534f02018-12-13 16:10:02 -0800394} // namespace host_tool