Add Erase verifyGeometry
This confirms specified amount of the drive is accessible. The min and
max expected drive size are set as a build configuration, and compared
against the drive size (found by using the linux ioctl). Also adds
testing build files, testing options, and verifyGeometry test.
Tested: Ran eStoraged on a machine with an eMMC, using the following
$ ./eStoraged -b /dev/mmcblk0 &
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 \
/xyz/openbmc_project/storage/mmcblk0 \
xyz.openbmc_project.eStoraged Erase ays 1 1 \
xyz.openbmc_project.eStoraged.EraseMethod.VerifyGeometry
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: Ie47f8666996a6085a115d1b86f2643bc278638c5
diff --git a/src/test/erase/verifyGeometry_test.cpp b/src/test/erase/verifyGeometry_test.cpp
new file mode 100644
index 0000000..1731e75
--- /dev/null
+++ b/src/test/erase/verifyGeometry_test.cpp
@@ -0,0 +1,27 @@
+#include "estoraged_conf.hpp"
+#include "verifyDriveGeometry.hpp"
+
+#include <xyz/openbmc_project/eStoraged/error.hpp>
+
+#include <gmock/gmock-matchers.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+using sdbusplus::xyz::openbmc_project::eStoraged::Error::EraseError;
+
+TEST(VerifyGeometry, TooBigFail)
+{
+ VerifyDriveGeometry maxVerify("");
+ EXPECT_THROW(maxVerify.geometryOkay(ERASE_MAX_GEOMETRY + 1), EraseError);
+}
+
+TEST(VerifyGeometry, TooSmallFail)
+{
+ VerifyDriveGeometry minVerify("");
+ EXPECT_THROW(minVerify.geometryOkay(ERASE_MIN_GEOMETRY - 1), EraseError);
+}
+
+TEST(VerifyGeometry, pass)
+{
+ VerifyDriveGeometry passVerify("");
+ EXPECT_NO_THROW(passVerify.geometryOkay(ERASE_MIN_GEOMETRY + 1));
+}