Check in a clang-tidy
This should've been done when we first created the repo, but better late
than never.
Signed-off-by: Ed Tanous <edtanous@google.com>
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I68da1d13167ec94f9d008dea307c9f23a991d42c
diff --git a/src/test/erase/crypto_test.cpp b/src/test/erase/crypto_test.cpp
index 917b23b..9eefa9d 100644
--- a/src/test/erase/crypto_test.cpp
+++ b/src/test/erase/crypto_test.cpp
@@ -20,25 +20,23 @@
{
using estoraged::CryptErase;
-using estoraged::Cryptsetup;
-using estoraged::CryptsetupInterface;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound;
-using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume;
using ::testing::_;
using ::testing::Return;
using ::testing::StrEq;
-class cryptoEraseTest : public testing::Test
+const std::string testFileName = "testFile";
+
+class CryptoEraseTest : public testing::Test
{
public:
- static constexpr char testFileName[] = "testfile";
std::ofstream testFile;
void SetUp() override
{
/* Create an empty file that we'll pretend is a 'storage device'. */
- testFile.open(testFileName,
+ testFile.open(testFileName.c_str(),
std::ios::out | std::ios::binary | std::ios::trunc);
testFile.close();
if (testFile.fail())
@@ -49,7 +47,7 @@
}
};
-TEST_F(cryptoEraseTest, EraseCryptPass)
+TEST_F(CryptoEraseTest, EraseCryptPass)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -66,11 +64,11 @@
EXPECT_CALL(*mockCryptIface, cryptKeyslotDestroy(_, 0)).Times(1);
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
-TEST_F(cryptoEraseTest, EraseCrypMaxSlotFails)
+TEST_F(CryptoEraseTest, EraseCrypMaxSlotFails)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -82,11 +80,11 @@
.WillOnce(Return(-1));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
-TEST_F(cryptoEraseTest, EraseCrypMaxSlotZero)
+TEST_F(CryptoEraseTest, EraseCrypMaxSlotZero)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -98,11 +96,11 @@
.WillOnce(Return(0));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
-TEST_F(cryptoEraseTest, EraseCrypOnlyInvalid)
+TEST_F(CryptoEraseTest, EraseCrypOnlyInvalid)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -117,11 +115,11 @@
.WillRepeatedly(Return(CRYPT_SLOT_INVALID));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
-TEST_F(cryptoEraseTest, EraseCrypDestoryFails)
+TEST_F(CryptoEraseTest, EraseCrypDestoryFails)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -139,7 +137,7 @@
.WillOnce(Return(-1));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), InternalFailure);
}
diff --git a/src/test/erase/pattern_test.cpp b/src/test/erase/pattern_test.cpp
index 98eb374..e0192a0 100644
--- a/src/test/erase/pattern_test.cpp
+++ b/src/test/erase/pattern_test.cpp
@@ -63,7 +63,8 @@
int dummyValue = 88;
testFile.open(testFileName, std::ios::binary | std::ios::out);
- testFile.write((const char*)&dummyValue, sizeof(dummyValue));
+ testFile.write((reinterpret_cast<const char*>(&dummyValue)),
+ sizeof(dummyValue));
testFile.close();
EXPECT_NO_THROW(pass.writePattern(size - sizeof(dummyValue)));
diff --git a/src/test/erase/zero_test.cpp b/src/test/erase/zero_test.cpp
index 70a62e2..846059d 100644
--- a/src/test/erase/zero_test.cpp
+++ b/src/test/erase/zero_test.cpp
@@ -17,7 +17,6 @@
using estoraged::Zero;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-using stdplus::fd::ManagedFd;
namespace estoraged_test
{
@@ -61,9 +60,10 @@
std::ofstream testFile;
// open the file and write none zero to it
- int dummyValue = 0x88776655;
+ uint32_t dummyValue = 0x88776655;
testFile.open(testFileName, std::ios::binary | std::ios::out);
- testFile.write((const char*)&dummyValue, sizeof(dummyValue));
+ testFile.write((reinterpret_cast<const char*>(&dummyValue)),
+ sizeof(dummyValue));
testFile.close();
uint64_t size = 4096;
Zero pass(testFileName);
@@ -88,7 +88,7 @@
uint64_t size = 4096;
Zero pass(testFileName);
- int dummyValue = 88;
+ uint32_t dummyValue = 88;
EXPECT_NO_THROW(pass.writeZero(size - sizeof(dummyValue)));
// open the file and write none zero to it