patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -17,14 +17,13 @@ using namespace oceanbase::common;
using namespace oceanbase::rpc;
using namespace oceanbase::obmysql;
class ObFakeMySQLPacket : public ObMySQLPacket {
class ObFakeMySQLPacket : public ObMySQLPacket
{
public:
ObFakeMySQLPacket() : content_len_(0)
{}
ObFakeMySQLPacket() : content_len_(0) {}
int64_t content_len_;
protected:
virtual int serialize(char* start, const int64_t len, int64_t& pos) const
virtual int serialize(char *start, const int64_t len, int64_t &pos) const
{
int ret = OB_SUCCESS;
if ((NULL == start) || (content_len_ < 0)) {
@ -41,18 +40,23 @@ protected:
}
};
class TestMySQLPacket : public ::testing::Test {
class TestMySQLPacket : public ::testing::Test
{
public:
TestMySQLPacket()
{}
{
}
virtual void SetUp()
{}
{
}
virtual void TearDown()
{}
{
}
};
TEST_F(TestMySQLPacket, common)
{
ObFakeMySQLPacket fake_pkt;
@ -62,14 +66,14 @@ TEST_F(TestMySQLPacket, common)
int64_t pos = 0;
int ret = OB_SUCCESS;
int64_t len = 100;
char* buf = new char[len];
char *buf = new char[len];
ret = fake_pkt.encode(buf, len, pos, pkt_count);
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(1, pkt_count);
delete[] buf;
delete []buf;
buf = NULL;
len = 16 * 1024 * 1024 - 1 + 4;
len = 16 * 1024 *1024 - 1 + 4;
buf = new char[len];
fake_pkt.content_len_ = 16 * 1024 * 1024 - 1;
pkt_count = 0;
@ -78,10 +82,10 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SIZE_OVERFLOW, ret);
EXPECT_EQ(0, pkt_count);
EXPECT_EQ(0, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = 16 * 1024 * 1024 - 1 + 4 + 4;
len = 16 * 1024 *1024 - 1 + 4 + 4;
buf = new char[len];
fake_pkt.content_len_ = 16 * 1024 * 1024 - 1;
pkt_count = 0;
@ -90,10 +94,10 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(2, pkt_count);
EXPECT_EQ(len, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = 16 * 1024 * 1024 - 1 + 4 + 4;
len = 16 * 1024 *1024 - 1 + 4 + 4;
buf = new char[len];
fake_pkt.content_len_ = 16 * 1024 * 1024 - 1;
pkt_count = 0;
@ -102,10 +106,10 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(2, pkt_count);
EXPECT_EQ(len, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = 16 * 1024 * 1024 - 2 + 4;
len = 16 * 1024 *1024 - 2 + 4;
buf = new char[len];
fake_pkt.content_len_ = 16 * 1024 * 1024 - 2;
pkt_count = 0;
@ -114,10 +118,10 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(1, pkt_count);
EXPECT_EQ(len, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = 16 * 1024 * 1024 - 1 + 1 + 4 + 4;
len = 16 * 1024 *1024 - 1 + 1 + 4 + 4;
buf = new char[len];
fake_pkt.content_len_ = 16 * 1024 * 1024 - 1 + 1;
pkt_count = 0;
@ -126,7 +130,7 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(2, pkt_count);
EXPECT_EQ(len, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = (16 * 1024 * 1024 - 1 + 4) * 5 + 4;
@ -138,7 +142,7 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_SUCCESS, ret);
EXPECT_EQ(6, pkt_count);
EXPECT_EQ(len, pos);
delete[] buf;
delete []buf;
buf = NULL;
len = (16 * 1024 * 1024 - 1 + 4);
@ -150,11 +154,12 @@ TEST_F(TestMySQLPacket, common)
EXPECT_EQ(OB_BUF_NOT_ENOUGH, ret);
EXPECT_EQ(0, pkt_count);
EXPECT_EQ(0, pos);
delete[] buf;
delete []buf;
buf = NULL;
}
int main(int argc, char* argv[])
int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();