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

@ -13,6 +13,7 @@
#include <gtest/gtest.h>
#include "common/ob_segmented_buffer.h"
#include "lib/allocator/ob_mod_define.h"
#include "lib/oblog/ob_log.h"
#include "lib/ob_define.h"
using namespace oceanbase::common;
@ -21,7 +22,8 @@ using namespace oceanbase::lib;
TEST(TestObSegmentedBuffer, base)
{
const int block_size = 100;
ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_MEM_META, ObCtxIds::DEFAULT_CTX_ID);
ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_MEM_META,
ObCtxIds::DEFAULT_CTX_ID);
ObSegmentedBufffer sb(block_size, attr);
char buf[block_size * 10];
int ret = OB_SUCCESS;
@ -30,7 +32,7 @@ TEST(TestObSegmentedBuffer, base)
ASSERT_EQ(OB_SUCCESS, ret);
}
ObSegmentedBuffferIterator sbi(sb);
char* cur_buf = nullptr;
char *cur_buf = nullptr;
int64_t len = 0;
int64_t pos = 0;
while ((cur_buf = sbi.next(len)) != nullptr) {
@ -40,15 +42,15 @@ TEST(TestObSegmentedBuffer, base)
// test dump to file
ASSERT_EQ(OB_INVALID_ARGUMENT, sb.dump_to_file(nullptr));
const static char* file_name = "tmp_file";
const static char *file_name = "tmp_file";
ASSERT_EQ(OB_SUCCESS, sb.dump_to_file(file_name));
FILE* file = fopen(file_name, "rb");
FILE * file = fopen (file_name, "rb" );
ASSERT_NE(file, nullptr);
fseek(file, 0, SEEK_END);
int64_t size = ftell(file);
rewind(file);
char* buffer = (char*)malloc(size);
char *buffer = (char*) malloc (size);
ASSERT_NE(buffer, nullptr);
ObSegmentedBufffer new_sb(block_size, attr);
int64_t real_size = fread(buffer, 1, size, file);
@ -58,11 +60,11 @@ TEST(TestObSegmentedBuffer, base)
{
ObSegmentedBuffferIterator sbi(sb);
ObSegmentedBuffferIterator sbi2(new_sb);
char* ptr = 0;
char *ptr = 0;
int64_t len = 0;
while ((ptr = sbi.next(len)) != nullptr) {
int64_t len2 = 0;
char* ptr2 = sbi2.next(len2);
char *ptr2 = sbi2.next(len2);
ASSERT_EQ(len2, len);
ASSERT_EQ(0, MEMCMP(ptr, ptr2, len));
}
@ -73,9 +75,9 @@ TEST(TestObSegmentedBuffer, base)
system("rm -rf tmp_file");
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
testing::InitGoogleTest(&argc,argv);
OB_LOGGER.set_log_level("INFO");
return RUN_ALL_TESTS();
}