tools: split out the update handler

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I367ea961c98ec822d3200d101c4f5977d77e7402
diff --git a/tools/test/Makefile.am b/tools/test/Makefile.am
index 26de6c5..c05654b 100644
--- a/tools/test/Makefile.am
+++ b/tools/test/Makefile.am
@@ -18,7 +18,8 @@
 check_PROGRAMS = \
 	tools_bt_unittest \
 	tools_lpc_unittest \
-	tools_updater_unittest
+	tools_updater_unittest \
+	tools_helper_unittest
 
 TESTS = $(check_PROGRAMS)
 
@@ -30,3 +31,6 @@
 
 tools_updater_unittest_SOURCES = tools_updater_unittest.cpp
 tools_updater_unittest_LDADD = $(top_builddir)/tools/libupdater.la
+
+tools_helper_unittest_SOURCES = tools_helper_unittest.cpp
+tools_helper_unittest_LDADD = $(top_builddir)/tools/libupdater.la
diff --git a/tools/test/tools_helper_unittest.cpp b/tools/test/tools_helper_unittest.cpp
new file mode 100644
index 0000000..931c59f
--- /dev/null
+++ b/tools/test/tools_helper_unittest.cpp
@@ -0,0 +1,47 @@
+#include "helper.hpp"
+#include "status.hpp"
+
+#include <cstdint>
+#include <ipmiblob/test/blob_interface_mock.hpp>
+
+#include <gtest/gtest.h>
+
+namespace host_tool
+{
+using ::testing::Return;
+using ::testing::TypedEq;
+
+class UpdaterTest : public ::testing::Test
+{
+  protected:
+    ipmiblob::BlobInterfaceMock blobMock;
+    std::uint16_t session = 0xbeef;
+};
+
+TEST_F(UpdaterTest, PollStatusReturnsAfterSuccess)
+{
+    ipmiblob::StatResponse verificationResponse = {};
+    /* the other details of the response are ignored, and should be. */
+    verificationResponse.metadata.push_back(
+        static_cast<std::uint8_t>(ipmi_flash::ActionStatus::success));
+
+    EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
+        .WillOnce(Return(verificationResponse));
+
+    EXPECT_TRUE(pollStatus(session, &blobMock));
+}
+
+TEST_F(UpdaterTest, PollStatusReturnsAfterFailure)
+{
+    ipmiblob::StatResponse verificationResponse = {};
+    /* the other details of the response are ignored, and should be. */
+    verificationResponse.metadata.push_back(
+        static_cast<std::uint8_t>(ipmi_flash::ActionStatus::failed));
+
+    EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
+        .WillOnce(Return(verificationResponse));
+
+    EXPECT_FALSE(pollStatus(session, &blobMock));
+}
+
+} // namespace host_tool
diff --git a/tools/test/tools_updater_unittest.cpp b/tools/test/tools_updater_unittest.cpp
index 5b3cb5b..a2ba2df 100644
--- a/tools/test/tools_updater_unittest.cpp
+++ b/tools/test/tools_updater_unittest.cpp
@@ -96,32 +96,6 @@
     std::uint16_t session = 0xbeef;
 };
 
-TEST_F(UpdaterTest, PollStatusReturnsAfterSuccess)
-{
-    ipmiblob::StatResponse verificationResponse = {};
-    /* the other details of the response are ignored, and should be. */
-    verificationResponse.metadata.push_back(
-        static_cast<std::uint8_t>(ipmi_flash::ActionStatus::success));
-
-    EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
-        .WillOnce(Return(verificationResponse));
-
-    EXPECT_TRUE(pollStatus(session, &blobMock));
-}
-
-TEST_F(UpdaterTest, PollStatusReturnsAfterFailure)
-{
-    ipmiblob::StatResponse verificationResponse = {};
-    /* the other details of the response are ignored, and should be. */
-    verificationResponse.metadata.push_back(
-        static_cast<std::uint8_t>(ipmi_flash::ActionStatus::failed));
-
-    EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session)))
-        .WillOnce(Return(verificationResponse));
-
-    EXPECT_FALSE(pollStatus(session, &blobMock));
-}
-
 TEST_F(UpdaterTest, UpdateMainReturnsSuccessIfAllSuccess)
 {
     const std::string image = "image.bin";