John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 1 | #include "estoraged_conf.hpp" |
| 2 | #include "verifyDriveGeometry.hpp" |
| 3 | |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Common/error.hpp> |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 5 | |
| 6 | #include <gmock/gmock-matchers.h> |
| 7 | #include <gmock/gmock.h> |
| 8 | #include <gtest/gtest.h> |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 9 | |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 10 | namespace estoraged_test |
| 11 | { |
| 12 | using estoraged::VerifyDriveGeometry; |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 13 | using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 14 | |
| 15 | TEST(VerifyGeometry, TooBigFail) |
| 16 | { |
| 17 | VerifyDriveGeometry maxVerify(""); |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 18 | EXPECT_THROW(maxVerify.geometryOkay(ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY, |
| 19 | ERASE_MAX_GEOMETRY + 1), |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 20 | InternalFailure); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | TEST(VerifyGeometry, TooSmallFail) |
| 24 | { |
| 25 | VerifyDriveGeometry minVerify(""); |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 26 | EXPECT_THROW(minVerify.geometryOkay(ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY, |
| 27 | ERASE_MIN_GEOMETRY - 1), |
John Wedig | 972c3fa | 2021-12-29 17:30:41 -0800 | [diff] [blame] | 28 | InternalFailure); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | TEST(VerifyGeometry, pass) |
| 32 | { |
| 33 | VerifyDriveGeometry passVerify(""); |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 34 | EXPECT_NO_THROW(passVerify.geometryOkay( |
| 35 | ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY, ERASE_MIN_GEOMETRY + 1)); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 36 | } |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 37 | |
| 38 | } // namespace estoraged_test |