bmc: enable configuration of all verification
Enable verification configuration beyond the result file check. This
patchset allows a developer to provide their own verification mechanisms
by implementing an interface and adding configuration to enable using
their custom version.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Iba5d4be75bb49d9c4ab84be8578f0306c15b5be9
diff --git a/verify.hpp b/verify.hpp
new file mode 100644
index 0000000..0f67a20
--- /dev/null
+++ b/verify.hpp
@@ -0,0 +1,92 @@
+#pragma once
+
+#include "config.h"
+
+#include "status.hpp"
+
+#include <memory>
+#include <string>
+
+#if HAVE_SDBUSPLUS
+#include <sdbusplus/bus.hpp>
+#else
+namespace sdbusplus
+{
+namespace bus
+{
+class bus
+{
+};
+} // namespace bus
+} // namespace sdbusplus
+#endif
+
+namespace blobs
+{
+
+class VerificationInterface
+{
+ public:
+ virtual ~VerificationInterface() = default;
+
+ /**
+ * Trigger verification service.
+ *
+ * @return true if successfully started, false otherwise.
+ */
+ virtual bool triggerVerification() = 0;
+
+ /** Abort the verification process. */
+ virtual void abortVerification() = 0;
+
+ /** Check the current state of the verification process. */
+ virtual VerifyCheckResponses checkVerificationState() = 0;
+};
+
+/**
+ * Representation of what is used for verification. Currently, this reduces the
+ * chance of error by using an object instead of two strings to control the
+ * verification step, however, it leaves room for a future possibility out
+ * something wholly configurable.
+ */
+class Verification : public VerificationInterface
+{
+ public:
+ /**
+ * Create a default Verification object that uses systemd to trigger the
+ * process.
+ *
+ * @param[in] bus - an sdbusplus handler for a bus to use.
+ * @param[in] path - the path to check for verification status.
+ * @param[in[ service - the systemd service to start to trigger
+ * verification.
+ */
+ static std::unique_ptr<VerificationInterface>
+ CreateDefaultVerification(sdbusplus::bus::bus&& bus,
+ const std::string& path,
+ const std::string& service);
+
+ Verification(sdbusplus::bus::bus&& bus, const std::string& path,
+ const std::string& service) :
+ bus(std::move(bus)),
+ checkPath(path), triggerService(service)
+ {
+ }
+
+ ~Verification() = default;
+ Verification(const Verification&) = delete;
+ Verification& operator=(const Verification&) = delete;
+ Verification(Verification&&) = default;
+ Verification& operator=(Verification&&) = default;
+
+ bool triggerVerification() override;
+ void abortVerification() override;
+ VerifyCheckResponses checkVerificationState() override;
+
+ private:
+ sdbusplus::bus::bus bus;
+ const std::string checkPath;
+ const std::string triggerService;
+};
+
+} // namespace blobs