tools: trigger verification
Trigger verification via committing to the verify blob id.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ia3722ff144ba268cd554bac0fda06f0c426edd88
diff --git a/test/tools_updater_unittest.cpp b/test/tools_updater_unittest.cpp
index 27a3fc4..04720e0 100644
--- a/test/tools_updater_unittest.cpp
+++ b/test/tools_updater_unittest.cpp
@@ -10,6 +10,7 @@
namespace host_tool
{
+using ::testing::_;
using ::testing::Eq;
using ::testing::Return;
using ::testing::StrEq;
@@ -24,6 +25,7 @@
std::string signatureFile = "image.sig";
std::string expectedBlob = "/flash/image";
std::string expectedHash = "/flash/hash";
+ std::string expectedVerify = "/flash/verify";
std::vector<std::string> blobList = {expectedBlob};
ipmiblob::StatResponse statObj;
@@ -58,6 +60,12 @@
sendContents(StrEq(signatureFile.c_str()), Eq(session)))
.WillOnce(Return(true));
+ EXPECT_CALL(blobMock,
+ openBlob(StrEq(expectedVerify.c_str()), Eq(supported)))
+ .WillOnce(Return(session));
+
+ EXPECT_CALL(blobMock, commit(Eq(session), _)).WillOnce(Return());
+
updaterMain(&blobMock, &handlerMock, firmwareImage, signatureFile);
}
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 2465945..fd72136 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -33,9 +33,14 @@
{
/* TODO(venture): Add optional parameter to specify the flash type, default
* to legacy for now.
+ *
+ * TODO(venture): Move the strings from the FirmwareHandler object to a
+ * boring utils object so it will be more happly linked cleanly to both the
+ * BMC and host-side.
*/
std::string goalFirmware = "/flash/image";
std::string hashFilename = "/flash/hash";
+ std::string verifyFilename = "/flash/verify";
/* Get list of blob_ids, check for /flash/image, or /flash/tarball.
* TODO(venture) the mechanism doesn't care, but the caller of burn_my_bmc
@@ -129,8 +134,38 @@
blob->closeBlob(session);
- /* Trigger the verification. */
- /* Check the verification. */
+ /* Trigger the verification by opening the verify file. */
+ std::fprintf(stderr, "Opening the verification file\n");
+ try
+ {
+ session = blob->openBlob(
+ verifyFilename,
+ static_cast<std::uint16_t>(supported) |
+ static_cast<std::uint16_t>(blobs::OpenFlags::write));
+ }
+ catch (const ipmiblob::BlobException& b)
+ {
+ throw ToolException("blob exception received: " +
+ std::string(b.what()));
+ }
+
+ std::fprintf(
+ stderr,
+ "Committing to verification file to trigger verification service\n");
+ try
+ {
+ blob->commit(session, {});
+ }
+ catch (const ipmiblob::BlobException& b)
+ {
+ throw ToolException("blob exception received: " +
+ std::string(b.what()));
+ }
+
+ /* TODO: Check the verification via stat(session). */
+
+ /* DO NOT CLOSE the verification session until it's done. */
+ blob->closeBlob(session);
return;
}