blob: 57feebd90c360c3e1f035a06e32f6a89baff0721 [file] [log] [blame]
John Edward Broadbente6ffe702021-10-14 14:03:11 -07001#include "estoraged_conf.hpp"
2#include "verifyDriveGeometry.hpp"
3
John Wedig972c3fa2021-12-29 17:30:41 -08004#include <xyz/openbmc_project/Common/error.hpp>
John Edward Broadbente6ffe702021-10-14 14:03:11 -07005
6#include <gmock/gmock-matchers.h>
7#include <gmock/gmock.h>
8#include <gtest/gtest.h>
John Wedig972c3fa2021-12-29 17:30:41 -08009
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080010namespace estoraged_test
11{
12using estoraged::VerifyDriveGeometry;
John Wedig972c3fa2021-12-29 17:30:41 -080013using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
John Edward Broadbente6ffe702021-10-14 14:03:11 -070014
15TEST(VerifyGeometry, TooBigFail)
16{
17 VerifyDriveGeometry maxVerify("");
Tom Tung043af592023-11-24 13:37:05 +080018 EXPECT_THROW(maxVerify.geometryOkay(ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY,
19 ERASE_MAX_GEOMETRY + 1),
John Wedig972c3fa2021-12-29 17:30:41 -080020 InternalFailure);
John Edward Broadbente6ffe702021-10-14 14:03:11 -070021}
22
23TEST(VerifyGeometry, TooSmallFail)
24{
25 VerifyDriveGeometry minVerify("");
Tom Tung043af592023-11-24 13:37:05 +080026 EXPECT_THROW(minVerify.geometryOkay(ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY,
27 ERASE_MIN_GEOMETRY - 1),
John Wedig972c3fa2021-12-29 17:30:41 -080028 InternalFailure);
John Edward Broadbente6ffe702021-10-14 14:03:11 -070029}
30
31TEST(VerifyGeometry, pass)
32{
33 VerifyDriveGeometry passVerify("");
Tom Tung043af592023-11-24 13:37:05 +080034 EXPECT_NO_THROW(passVerify.geometryOkay(
35 ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY, ERASE_MIN_GEOMETRY + 1));
John Edward Broadbente6ffe702021-10-14 14:03:11 -070036}
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080037
38} // namespace estoraged_test