Skip to content

Commit

Permalink
Merge pull request ceph#38247 from dillaman/wip-librbd-test-rename
Browse files Browse the repository at this point in the history
test/librbd: rename tests to match proper namespaces

Reviewed-by: Mykola Golub <[email protected]>
  • Loading branch information
trociny committed Nov 24, 2020
2 parents 30a3261 + 07d2ded commit acf3b72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/test/librbd/crypto/openssl/test_DataCryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const unsigned char TEST_IV[16] = {2};
const unsigned char TEST_IV_2[16] = {3};
const unsigned char TEST_DATA[4096] = {4};

struct TestDataCryptor : public TestFixture {
struct TestCryptoOpensslDataCryptor : public TestFixture {
DataCryptor *cryptor;

void SetUp() override {
Expand All @@ -30,28 +30,28 @@ struct TestDataCryptor : public TestFixture {
}
};

TEST_F(TestDataCryptor, InvalidCipherName) {
TEST_F(TestCryptoOpensslDataCryptor, InvalidCipherName) {
EXPECT_EQ(-EINVAL, cryptor->init(nullptr, TEST_KEY, sizeof(TEST_KEY)));
EXPECT_EQ(-EINVAL, cryptor->init("", TEST_KEY, sizeof(TEST_KEY)));
EXPECT_EQ(-EINVAL, cryptor->init("Invalid", TEST_KEY, sizeof(TEST_KEY)));
}

TEST_F(TestDataCryptor, InvalidKey) {
TEST_F(TestCryptoOpensslDataCryptor, InvalidKey) {
EXPECT_EQ(-EINVAL, cryptor->init(TEST_CIPHER_NAME, nullptr, 0));
EXPECT_EQ(-EINVAL, cryptor->init(TEST_CIPHER_NAME, nullptr,
sizeof(TEST_KEY)));
EXPECT_EQ(-EINVAL, cryptor->init(TEST_CIPHER_NAME, TEST_KEY, 1));
}

TEST_F(TestDataCryptor, GetContextInvalidMode) {
TEST_F(TestCryptoOpensslDataCryptor, GetContextInvalidMode) {
EXPECT_EQ(nullptr, cryptor->get_context(static_cast<CipherMode>(-1)));
}

TEST_F(TestDataCryptor, ReturnNullContext) {
TEST_F(TestCryptoOpensslDataCryptor, ReturnNullContext) {
cryptor->return_context(nullptr, static_cast<CipherMode>(-1));
}

TEST_F(TestDataCryptor, ReturnContextInvalidMode) {
TEST_F(TestCryptoOpensslDataCryptor, ReturnContextInvalidMode) {
auto ctx = cryptor->get_context(CipherMode::CIPHER_MODE_ENC);
ASSERT_NE(ctx, nullptr);
cryptor->return_context(ctx, CipherMode::CIPHER_MODE_DEC);
Expand All @@ -60,7 +60,7 @@ TEST_F(TestDataCryptor, ReturnContextInvalidMode) {
cryptor->return_context(ctx, static_cast<CipherMode>(-1));
}

TEST_F(TestDataCryptor, EncryptDecrypt) {
TEST_F(TestCryptoOpensslDataCryptor, EncryptDecrypt) {
auto ctx = cryptor->get_context(CipherMode::CIPHER_MODE_ENC);
ASSERT_NE(ctx, nullptr);
cryptor->init_context(ctx, TEST_IV, sizeof(TEST_IV));
Expand All @@ -78,7 +78,7 @@ TEST_F(TestDataCryptor, EncryptDecrypt) {
cryptor->return_context(ctx, CipherMode::CIPHER_MODE_DEC);
}

TEST_F(TestDataCryptor, ReuseContext) {
TEST_F(TestCryptoOpensslDataCryptor, ReuseContext) {
auto ctx = cryptor->get_context(CipherMode::CIPHER_MODE_ENC);
ASSERT_NE(ctx, nullptr);

Expand All @@ -105,7 +105,7 @@ TEST_F(TestDataCryptor, ReuseContext) {
cryptor->return_context(ctx2, CipherMode::CIPHER_MODE_ENC);
}

TEST_F(TestDataCryptor, InvalidIVLength) {
TEST_F(TestCryptoOpensslDataCryptor, InvalidIVLength) {
auto ctx = cryptor->get_context(CipherMode::CIPHER_MODE_ENC);
ASSERT_NE(ctx, nullptr);

Expand Down
14 changes: 7 additions & 7 deletions src/test/librbd/crypto/test_mock_BlockCrypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ MATCHER_P(CompareArrayToString, s, "") {
return (memcmp(arg, s.c_str(), s.length()) == 0);
}

struct TestMockBlockCrypto : public TestFixture {
struct TestMockCryptoBlockCrypto : public TestFixture {
MockDataCryptor cryptor;
ceph::ref_t<BlockCrypto<MockCryptoContext>> bc;
int cryptor_block_size = 2;
Expand Down Expand Up @@ -73,7 +73,7 @@ struct TestMockBlockCrypto : public TestFixture {
}
};

TEST_F(TestMockBlockCrypto, Encrypt) {
TEST_F(TestMockCryptoBlockCrypto, Encrypt) {
uint32_t image_offset = 0x1234 * block_size;

ceph::bufferlist data1;
Expand Down Expand Up @@ -104,35 +104,35 @@ TEST_F(TestMockBlockCrypto, Encrypt) {
ASSERT_TRUE(data.is_aligned(block_size));
}

TEST_F(TestMockBlockCrypto, UnalignedImageOffset) {
TEST_F(TestMockCryptoBlockCrypto, UnalignedImageOffset) {
ceph::bufferlist data;
data.append("1234");
ASSERT_EQ(-EINVAL, bc->encrypt(&data, 2));
}

TEST_F(TestMockBlockCrypto, UnalignedDataLength) {
TEST_F(TestMockCryptoBlockCrypto, UnalignedDataLength) {
ceph::bufferlist data;
data.append("123");
ASSERT_EQ(-EINVAL, bc->encrypt(&data, 0));
}

TEST_F(TestMockBlockCrypto, GetContextError) {
TEST_F(TestMockCryptoBlockCrypto, GetContextError) {
ceph::bufferlist data;
data.append("1234");
EXPECT_CALL(cryptor, get_context(CipherMode::CIPHER_MODE_ENC)).WillOnce(
Return(nullptr));
ASSERT_EQ(-EIO, bc->encrypt(&data, 0));
}

TEST_F(TestMockBlockCrypto, InitContextError) {
TEST_F(TestMockCryptoBlockCrypto, InitContextError) {
ceph::bufferlist data;
data.append("1234");
expect_get_context(CipherMode::CIPHER_MODE_ENC);
EXPECT_CALL(cryptor, init_context(_, _, _)).WillOnce(Return(-123));
ASSERT_EQ(-123, bc->encrypt(&data, 0));
}

TEST_F(TestMockBlockCrypto, UpdateContextError) {
TEST_F(TestMockCryptoBlockCrypto, UpdateContextError) {
ceph::bufferlist data;
data.append("1234");
expect_get_context(CipherMode::CIPHER_MODE_ENC);
Expand Down
4 changes: 2 additions & 2 deletions src/test/librbd/crypto/test_mock_CryptoContextPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using ::testing::Return;
namespace librbd {
namespace crypto {

struct TestMockCryptoContextPool : public ::testing::Test {
struct TestMockCryptoCryptoContextPool : public ::testing::Test {
MockDataCryptor cryptor;

void expect_get_context(CipherMode mode) {
Expand All @@ -28,7 +28,7 @@ struct TestMockCryptoContextPool : public ::testing::Test {
}
};

TEST_F(TestMockCryptoContextPool, Test) {
TEST_F(TestMockCryptoCryptoContextPool, Test) {
CryptoContextPool<MockCryptoContext> pool(&cryptor, 1);

expect_get_context(CipherMode::CIPHER_MODE_ENC);
Expand Down

0 comments on commit acf3b72

Please sign in to comment.