diff options
author | Patrick Venture <venture@google.com> | 2019-06-19 16:01:06 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-06-19 18:38:53 -0700 |
commit | 1f09d4145f6b925cab1b2fe7420b31725704bca5 (patch) | |
tree | 16627b3148e163c1b40ea21f9b0a2b5cbf0f3eee /tools/updater.hpp | |
parent | 00c7c72daf2c586bd95603057566a3ecd60c4db1 (diff) | |
download | phosphor-ipmi-flash-1f09d4145f6b925cab1b2fe7420b31725704bca5.tar.gz phosphor-ipmi-flash-1f09d4145f6b925cab1b2fe7420b31725704bca5.zip |
tool: continue the unit-tests of the host tool
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I51349fc103af2a55f1b83830bf8e74407fc15b9e
Diffstat (limited to 'tools/updater.hpp')
-rw-r--r-- | tools/updater.hpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/tools/updater.hpp b/tools/updater.hpp index ac4b11a..670d981 100644 --- a/tools/updater.hpp +++ b/tools/updater.hpp @@ -8,16 +8,10 @@ namespace host_tool { -/** Object that actually handles the update itself. */ -class UpdateHandler +class UpdateHandlerInterface { public: - UpdateHandler(ipmiblob::BlobInterface* blob, DataInterface* handler) : - blob(blob), handler(handler) - { - } - - virtual ~UpdateHandler() = default; + virtual ~UpdateHandlerInterface() = default; /** * Check if the goal firmware is listed in the blob_list and that the @@ -26,16 +20,16 @@ class UpdateHandler * @param[in] goalFirmware - the firmware to check /flash/image * /flash/tarball, etc. */ - virtual bool checkAvailable(const std::string& goalFirmware); + virtual bool checkAvailable(const std::string& goalFirmware) = 0; /** * Send the file contents at path to the blob id, target. * * @param[in] target - the blob id * @param[in] path - the source file path - * @throw ToolException on failure. */ - virtual void sendFile(const std::string& target, const std::string& path); + virtual void sendFile(const std::string& target, + const std::string& path) = 0; /** * Trigger verification. @@ -43,9 +37,32 @@ class UpdateHandler * @param[in] target - the verification blob id (may support multiple in the * future. * @return true if verified, false if verification errors. + */ + virtual bool verifyFile(const std::string& target) = 0; +}; + +/** Object that actually handles the update itself. */ +class UpdateHandler : public UpdateHandlerInterface +{ + public: + UpdateHandler(ipmiblob::BlobInterface* blob, DataInterface* handler) : + blob(blob), handler(handler) + { + } + + ~UpdateHandler() = default; + + bool checkAvailable(const std::string& goalFirmware) override; + + /** + * @throw ToolException on failure. + */ + void sendFile(const std::string& target, const std::string& path) override; + + /** * @throw ToolException on failure (TODO: throw on timeout.) */ - virtual bool verifyFile(const std::string& target); + bool verifyFile(const std::string& target) override; private: ipmiblob::BlobInterface* blob; @@ -69,7 +86,7 @@ bool pollStatus(std::uint16_t session, ipmiblob::BlobInterface* blob); * @param[in] signaturePath - the path to the signature file. * @throws ToolException on failures. */ -void updaterMain(UpdateHandler* updater, const std::string& imagePath, +void updaterMain(UpdateHandlerInterface* updater, const std::string& imagePath, const std::string& signaturePath); } // namespace host_tool |