patch 4.0
This commit is contained in:
242
deps/oblib/unittest/lib/utility/test_utility.cpp
vendored
242
deps/oblib/unittest/lib/utility/test_utility.cpp
vendored
@ -18,9 +18,10 @@
|
||||
using namespace oceanbase::common;
|
||||
using namespace std;
|
||||
|
||||
|
||||
TEST(utility, load_file_to_string)
|
||||
{
|
||||
const char* path = NULL;
|
||||
const char *path = NULL;
|
||||
CharArena alloc;
|
||||
ObString str;
|
||||
|
||||
@ -34,7 +35,9 @@ TEST(utility, get_ethernet_speed)
|
||||
int64_t speed = 0;
|
||||
ASSERT_NE(OB_SUCCESS, get_ethernet_speed(NULL, speed));
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, get_ethernet_speed("bond0", speed));
|
||||
if (OB_FILE_NOT_EXIST == get_ethernet_speed("bond0", speed)) {
|
||||
ASSERT_EQ(OB_SUCCESS, get_ethernet_speed("eth0", speed));
|
||||
}
|
||||
ASSERT_GE(speed, 1 << 20);
|
||||
_OB_LOG(INFO, "speed %ld", speed);
|
||||
}
|
||||
@ -48,13 +51,13 @@ TEST(utility, wild_compare)
|
||||
char str[NUM];
|
||||
char str_ne[NUM];
|
||||
char str_wild_one[NUM];
|
||||
// char str_ne[NUM];
|
||||
//char str_ne[NUM];
|
||||
snprintf(str, NUM, "0123456789");
|
||||
snprintf(str_ne, NUM, "0213456789");
|
||||
snprintf(str_wild_one, NUM, "01234567_9");
|
||||
|
||||
// arguments with 'char *' type
|
||||
// str: "012345678", str_ne: "021345678", str_wild_one: "01234567_"
|
||||
//arguments with 'char *' type
|
||||
//str: "012345678", str_ne: "021345678", str_wild_one: "01234567_"
|
||||
ASSERT_EQ(0, wild_compare(str, str_wild_one, STR_IS_NOT_PATTERN));
|
||||
ASSERT_NE(0, wild_compare(str_ne, str_wild_one, STR_IS_NOT_PATTERN));
|
||||
|
||||
@ -64,8 +67,8 @@ TEST(utility, wild_compare)
|
||||
ObString ob_str(NUM, str);
|
||||
ObString ob_str_wild(NUM, str_wild_one);
|
||||
ObString ob_str_ne(NUM, str_ne);
|
||||
// arguments with 'ObString' type
|
||||
// ob_str: "0123456789", ob_str_ne: "0213456789" ob_str_wild: "01234567_9"
|
||||
//arguments with 'ObString' type
|
||||
//ob_str: "0123456789", ob_str_ne: "0213456789" ob_str_wild: "01234567_9"
|
||||
ASSERT_EQ(0, wild_compare(ob_str, ob_str_wild, STR_IS_NOT_PATTERN));
|
||||
ASSERT_NE(0, wild_compare(ob_str_ne, ob_str_wild, STR_IS_NOT_PATTERN));
|
||||
|
||||
@ -75,16 +78,16 @@ TEST(utility, wild_compare)
|
||||
snprintf(str_wild_many, MANY_STR_NUM, "012%%89");
|
||||
str[NUM - 1] = '\0';
|
||||
str_ne[NUM - 1] = '\0';
|
||||
// arguments with 'char *' type
|
||||
// str: "012345678", str_ne: "021345678" str_wild_many: "012%8"
|
||||
//arguments with 'char *' type
|
||||
//str: "012345678", str_ne: "021345678" str_wild_many: "012%8"
|
||||
ASSERT_EQ(0, wild_compare(str, str_wild_many, STR_IS_NOT_PATTERN));
|
||||
ASSERT_NE(0, wild_compare(str_ne, str_wild_many, STR_IS_NOT_PATTERN));
|
||||
|
||||
str[NUM - 1] = '9';
|
||||
str_ne[NUM - 1] = '9';
|
||||
str_wild_many[MANY_STR_NUM - 1] = '9';
|
||||
// arguments with 'ObString' type
|
||||
// ob_str: "0123456789", ob_str_ne:"0213456789" ob_str_wild: "012%89"
|
||||
//arguments with 'ObString' type
|
||||
//ob_str: "0123456789", ob_str_ne:"0213456789" ob_str_wild: "012%89"
|
||||
ob_str.assign_ptr(str, NUM);
|
||||
ob_str_wild.assign_ptr(str_wild_many, MANY_STR_NUM);
|
||||
ob_str_ne.assign_ptr(str_ne, NUM);
|
||||
@ -95,17 +98,17 @@ TEST(utility, wild_compare)
|
||||
snprintf(str, NUM, "01234567%%");
|
||||
snprintf(str_wild_many, MANY_STR_NUM, "0123%%");
|
||||
snprintf(str_ne, NUM, "012%%34567");
|
||||
// arguments with 'char *' type
|
||||
// str: "01234567%", str_ne: "012%34567", str_wild_many: "0123%"
|
||||
//arguments with 'char *' type
|
||||
//str: "01234567%", str_ne: "012%34567", str_wild_many: "0123%"
|
||||
ASSERT_EQ(0, wild_compare(str, str_wild_many, STR_IS_PATTERN));
|
||||
ASSERT_NE(0, wild_compare(str_ne, str_wild_many, STR_IS_PATTERN));
|
||||
str[NUM - 1] = '9';
|
||||
str_wild_many[MANY_STR_NUM - 1] = '9';
|
||||
str_wild_many[MANY_STR_NUM -1] = '9';
|
||||
ob_str.assign_ptr(str, NUM);
|
||||
ob_str_wild.assign_ptr(str_wild_many, MANY_STR_NUM);
|
||||
ob_str_ne.assign_ptr(str_ne, NUM);
|
||||
// arguments with 'ObString' type
|
||||
// ob_str: "01234567%9", ob_str_ne: "012%345679", ob_str_wild: "0123%9"
|
||||
//arguments with 'ObString' type
|
||||
//ob_str: "01234567%9", ob_str_ne: "012%345679", ob_str_wild: "0123%9"
|
||||
ASSERT_EQ(0, wild_compare(ob_str, ob_str_wild, STR_IS_PATTERN));
|
||||
ASSERT_NE(0, wild_compare(ob_str_ne, ob_str_wild, STR_IS_PATTERN));
|
||||
|
||||
@ -210,7 +213,7 @@ TEST(utility, ltoa10)
|
||||
|
||||
TEST(utility, long_to_str10)
|
||||
{
|
||||
// correct
|
||||
//correct
|
||||
char sp_buff[35];
|
||||
char str10[OB_LTOA10_CHAR_LEN];
|
||||
int64_t check_value = INT64_MIN;
|
||||
@ -304,15 +307,15 @@ void test_max_speed(const int64_t rate, const int64_t total_size, const int64_t
|
||||
ASSERT_NE(0, rate);
|
||||
ObBandwidthThrottle throttle;
|
||||
int64_t cur_buf_size = 0;
|
||||
// int64_t avaliable_ts = 0;
|
||||
if (total_size * 1000 * 1000 > INT64_MAX) {
|
||||
//int64_t avaliable_ts = 0;
|
||||
if (total_size * 1000 * 1000 > INT64_MAX){
|
||||
COMMON_LOG(ERROR, "total size is too large", K(total_size));
|
||||
FAIL();
|
||||
}
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.init(rate));
|
||||
|
||||
int64_t start_time = ObTimeUtility::current_time();
|
||||
// int64_t sleep_time = 0;
|
||||
//int64_t sleep_time = 0;
|
||||
int64_t expect_time = 0;
|
||||
int64_t count = 0;
|
||||
int64_t cost_time = 0;
|
||||
@ -330,50 +333,32 @@ void test_max_speed(const int64_t rate, const int64_t total_size, const int64_t
|
||||
cost_time = ObTimeUtility::current_time() - start_time;
|
||||
expect_time = 1000 * 1000 * total_size / rate;
|
||||
if (cost_time > 0) {
|
||||
speed = total_size * 1000 * 1000 / cost_time;
|
||||
speed = total_size * 1000 * 1000/ cost_time;
|
||||
}
|
||||
int64_t diff = (speed - rate) * 100 / rate;
|
||||
COMMON_LOG(INFO,
|
||||
"finish check",
|
||||
K(cost_time),
|
||||
K(expect_time),
|
||||
K(total_size),
|
||||
K(rate),
|
||||
K(buf_size),
|
||||
K(count),
|
||||
K(speed),
|
||||
K(diff));
|
||||
COMMON_LOG(INFO, "finish check", K(cost_time), K(expect_time), K(total_size), K(rate), K(buf_size), K(count), K(speed), K(diff));
|
||||
if (diff > 0 || diff < -20) {
|
||||
COMMON_LOG(WARN,
|
||||
"check time",
|
||||
K(cost_time),
|
||||
K(expect_time),
|
||||
K(total_size),
|
||||
K(rate),
|
||||
K(buf_size),
|
||||
K(count),
|
||||
K(speed),
|
||||
K(diff));
|
||||
COMMON_LOG(WARN, "check time", K(cost_time), K(expect_time), K(total_size), K(rate), K(buf_size), K(count), K(speed), K(diff));
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(utility, bandwidth_throttle)
|
||||
TEST(utility, DISABLED_bandwidth_throttle)
|
||||
{
|
||||
ObBandwidthThrottle throttle;
|
||||
ASSERT_EQ(OB_NOT_INIT, throttle.set_rate(1024 * 1024)); // 1m/s
|
||||
ASSERT_EQ(OB_NOT_INIT, throttle.set_rate(1024*1024));//1m/s
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.init(0));
|
||||
throttle.destroy();
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.init(1024 * 1024)); // 1m/s
|
||||
ASSERT_EQ(OB_INIT_TWICE, throttle.init(1024 * 1024)); // 1m/s
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.init(1024*1024));//1m/s
|
||||
ASSERT_EQ(OB_INIT_TWICE, throttle.init(1024*1024));//1m/s
|
||||
ASSERT_EQ(OB_INVALID_ARGUMENT, throttle.set_rate(-1));
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.set_rate(0));
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.set_rate(1024 * 1024)); // 1m/s
|
||||
ASSERT_EQ(OB_SUCCESS, throttle.set_rate(1024*1024));//1m/s
|
||||
|
||||
test_max_speed(100 * 1024 * 1024, 60 * 1024 * 1024, 2 * 1024 * 1024);
|
||||
test_max_speed(1 * 1024, 1 * 1024, 32);
|
||||
test_max_speed(512 * 1024 * 1024 * 1024LL, 1024 * 1024 * 1024 * 1024LL, 600 * 1024 * 1024);
|
||||
test_max_speed(100 * 1024 * 1024, 60 * 1024 * 1024, -1);
|
||||
test_max_speed(100*1024*1024, 60*1024*1024, 2*1024*1024);
|
||||
test_max_speed(1*1024, 1*1024, 32);
|
||||
test_max_speed(512*1024*1024*1024LL, 1024*1024*1024*1024LL, 600*1024*1024);
|
||||
test_max_speed(100*1024*1024, 60*1024*1024, -1);
|
||||
}
|
||||
|
||||
TEST(utility, ob_localtime)
|
||||
@ -386,17 +371,17 @@ TEST(utility, ob_localtime)
|
||||
struct timeval tv;
|
||||
(void)gettimeofday(&tv, NULL);
|
||||
|
||||
// check next five year, need 180s
|
||||
//check next five year, need 180s
|
||||
const int64_t min_time = static_cast<int64_t>(tv.tv_sec);
|
||||
const int64_t max_time = min_time + 5 * 365 * 24 * 60 * 60;
|
||||
const int64_t max_time = min_time + 64 * 24 * 60 * 60;
|
||||
for (int64_t i = min_time; i < max_time; i += 1) {
|
||||
::localtime_r((const time_t*)&i, &std_tm);
|
||||
ob_localtime((const time_t*)&i, &ob_tm);
|
||||
::localtime_r((const time_t *)&i, &std_tm);
|
||||
ob_localtime((const time_t *)&i, &ob_tm);
|
||||
|
||||
// _COMMON_LOG(WARN, "check time, std_tm=%d %d-%d %d:%d:%d, ob_tm=%d %d-%d %d:%d:%d, value=%ld",
|
||||
// std_tm.tm_year, std_tm.tm_mon, std_tm.tm_mday, std_tm.tm_hour, std_tm.tm_min, std_tm.tm_sec,
|
||||
// ob_tm.tm_year, ob_tm.tm_mon, ob_tm.tm_mday, ob_tm.tm_hour, ob_tm.tm_min, ob_tm.tm_sec,
|
||||
// i);
|
||||
// _COMMON_LOG(WARN, "check time, std_tm=%d %d-%d %d:%d:%d, ob_tm=%d %d-%d %d:%d:%d, value=%ld",
|
||||
// std_tm.tm_year, std_tm.tm_mon, std_tm.tm_mday, std_tm.tm_hour, std_tm.tm_min, std_tm.tm_sec,
|
||||
// ob_tm.tm_year, ob_tm.tm_mon, ob_tm.tm_mday, ob_tm.tm_hour, ob_tm.tm_min, ob_tm.tm_sec,
|
||||
// i);
|
||||
|
||||
EXPECT_EQ(std_tm.tm_sec, ob_tm.tm_sec);
|
||||
EXPECT_EQ(std_tm.tm_min, ob_tm.tm_min);
|
||||
@ -416,50 +401,38 @@ TEST(utility, ob_localtime)
|
||||
}
|
||||
|
||||
int64_t special_value[18] = {
|
||||
825523199, // 1996.02.28 23.59.59
|
||||
825523200, // 1996.02.29 00.00.00
|
||||
825609599, // 1996.02.29 23.59.59
|
||||
825609600, // 1996.03.01 00.00.00
|
||||
825523199,//1996.02.28 23.59.59
|
||||
825523200,//1996.02.29 00.00.00
|
||||
825609599,//1996.02.29 23.59.59
|
||||
825609600,//1996.03.01 00.00.00
|
||||
|
||||
951753599, // 2000.02.28 23.59.59
|
||||
951753600, // 2000.02.29 00.00.00
|
||||
951839999, // 2000.02.29 23.59.59
|
||||
951840000, // 2000.03.01 00.00.00
|
||||
951753599,//2000.02.28 23.59.59
|
||||
951753600,//2000.02.29 00.00.00
|
||||
951839999,//2000.02.29 23.59.59
|
||||
951840000,//2000.03.01 00.00.00
|
||||
|
||||
4107513599, // 2100.02.28 23:59:59
|
||||
4107513600, // 2100.03.01 00:00:00
|
||||
920217599, // 1999.02.28 23.59.59
|
||||
920217600, // 1999.03.01 00.00.00
|
||||
4107513599,//2100.02.28 23:59:59
|
||||
4107513600,//2100.03.01 00:00:00
|
||||
920217599,//1999.02.28 23.59.59
|
||||
920217600,//1999.03.01 00.00.00
|
||||
|
||||
946655999, // 1999.12.31 23.59.59
|
||||
946656000, // 2000.01.01 0:0:0
|
||||
946655999,//1999.12.31 23.59.59
|
||||
946656000,//2000.01.01 0:0:0
|
||||
|
||||
0, // 1970.01.01 08:00:00
|
||||
-1, // 1970.01.01 07:59:59
|
||||
-2203920344, // 1900.02.28 23.59.59
|
||||
-2203920343 // 1900.03.01 00.00.00
|
||||
0,//1970.01.01 08:00:00
|
||||
-1,//1970.01.01 07:59:59
|
||||
-2203920344,//1900.02.28 23.59.59
|
||||
-2203920343//1900.03.01 00.00.00
|
||||
};
|
||||
|
||||
for (int64_t i = 0; i < 14; ++i) {
|
||||
::localtime_r((const time_t*)(special_value + i), &std_tm);
|
||||
ob_localtime((const time_t*)(special_value + i), &ob_tm);
|
||||
::localtime_r((const time_t *)(special_value + i), &std_tm);
|
||||
ob_localtime((const time_t *)(special_value + i), &ob_tm);
|
||||
|
||||
_COMMON_LOG(WARN,
|
||||
"check time, std_tm=%d %d-%d %d:%d:%d, ob_tm=%d %d-%d %d:%d:%d, value=%ld, __time=%ld",
|
||||
std_tm.tm_year,
|
||||
std_tm.tm_mon,
|
||||
std_tm.tm_mday,
|
||||
std_tm.tm_hour,
|
||||
std_tm.tm_min,
|
||||
std_tm.tm_sec,
|
||||
ob_tm.tm_year,
|
||||
ob_tm.tm_mon,
|
||||
ob_tm.tm_mday,
|
||||
ob_tm.tm_hour,
|
||||
ob_tm.tm_min,
|
||||
ob_tm.tm_sec,
|
||||
special_value[i],
|
||||
__timezone / 60);
|
||||
_COMMON_LOG(WARN, "check time, std_tm=%d %d-%d %d:%d:%d, ob_tm=%d %d-%d %d:%d:%d, value=%ld, __time=%ld",
|
||||
std_tm.tm_year, std_tm.tm_mon, std_tm.tm_mday, std_tm.tm_hour, std_tm.tm_min, std_tm.tm_sec,
|
||||
ob_tm.tm_year, ob_tm.tm_mon, ob_tm.tm_mday, ob_tm.tm_hour, ob_tm.tm_min, ob_tm.tm_sec,
|
||||
special_value[i], __timezone / 60);
|
||||
|
||||
EXPECT_EQ(std_tm.tm_sec, ob_tm.tm_sec);
|
||||
EXPECT_EQ(std_tm.tm_min, ob_tm.tm_min);
|
||||
@ -486,7 +459,7 @@ TEST(utility, ob_localtime)
|
||||
ob_tm.tm_year = 0;
|
||||
|
||||
for (int64_t i = 14; i < 18; ++i) {
|
||||
ob_localtime((const time_t*)(special_value + i), &ob_tm);
|
||||
ob_localtime((const time_t *)(special_value + i), &ob_tm);
|
||||
|
||||
EXPECT_EQ(0, ob_tm.tm_sec);
|
||||
EXPECT_EQ(0, ob_tm.tm_min);
|
||||
@ -507,59 +480,51 @@ TEST(utility, ob_localtime_performance)
|
||||
|
||||
gettimeofday(&time_begin, NULL);
|
||||
for (int64_t i = 1; i < MAX_COUNT; i += 1) {
|
||||
::localtime_r((const time_t*)&i, &ob_tm);
|
||||
::localtime_r((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
gettimeofday(&time_end, NULL);
|
||||
OB_LOG(INFO,
|
||||
"performance average(ns)",
|
||||
"localtime_r",
|
||||
(WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"cost_sec",
|
||||
time_end.tv_sec - time_begin.tv_sec,
|
||||
"cost_us",
|
||||
time_end.tv_usec - time_begin.tv_usec);
|
||||
OB_LOG(INFO, "performance average(ns)",
|
||||
"localtime_r", (WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"cost_sec", time_end.tv_sec - time_begin.tv_sec,
|
||||
"cost_us", time_end.tv_usec - time_begin.tv_usec);
|
||||
|
||||
|
||||
gettimeofday(&time_begin, NULL);
|
||||
for (int64_t i = 1; i < MAX_COUNT; i += 1) {
|
||||
ob_localtime((const time_t*)&i, &ob_tm);
|
||||
ob_localtime((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
gettimeofday(&time_end, NULL);
|
||||
OB_LOG(INFO,
|
||||
"performance average(ns)",
|
||||
"ob_localtime",
|
||||
(WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"cost_sec",
|
||||
time_end.tv_sec - time_begin.tv_sec,
|
||||
"cost_us",
|
||||
time_end.tv_usec - time_begin.tv_usec);
|
||||
OB_LOG(INFO, "performance average(ns)",
|
||||
"ob_localtime", (WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"cost_sec", time_end.tv_sec - time_begin.tv_sec,
|
||||
"cost_us", time_end.tv_usec - time_begin.tv_usec);
|
||||
}
|
||||
|
||||
struct TestCheckStruct {
|
||||
TestCheckStruct() : is_ob_localtime_(false), stop_(false)
|
||||
{}
|
||||
struct TestCheckStruct {
|
||||
TestCheckStruct() : is_ob_localtime_(false), stop_(false) {}
|
||||
bool is_ob_localtime_;
|
||||
volatile bool stop_;
|
||||
};
|
||||
|
||||
void* ob_localtime_pthread_op_func(void* arg)
|
||||
{
|
||||
TestCheckStruct* tmp = static_cast<TestCheckStruct*>(arg);
|
||||
TestCheckStruct *tmp = static_cast<TestCheckStruct *>(arg);
|
||||
struct tm ob_tm;
|
||||
// OB_LOG(INFO, "thread begin");
|
||||
// OB_LOG(INFO, "thread begin");
|
||||
if (tmp->is_ob_localtime_) {
|
||||
for (int64_t i = 0; !tmp->stop_; i += 1) {
|
||||
ob_localtime((const time_t*)&i, &ob_tm);
|
||||
ob_localtime((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
} else {
|
||||
for (int64_t i = 0; !tmp->stop_; i += 1) {
|
||||
::localtime_r((const time_t*)&i, &ob_tm);
|
||||
::localtime_r((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
}
|
||||
// OB_LOG(INFO, "thread end");
|
||||
// OB_LOG(INFO, "thread end");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TEST(utility, multi_thread_sys)
|
||||
TEST(utility, DISABLED_multi_thread_sys)
|
||||
{
|
||||
const int64_t max_thread_count[] = {10, 100};
|
||||
for (int64_t j = 0; j < 2; ++j) {
|
||||
@ -584,15 +549,12 @@ TEST(utility, multi_thread_sys)
|
||||
|
||||
gettimeofday(&time_begin, NULL);
|
||||
for (int64_t i = 1; i < MAX_COUNT; i += 1) {
|
||||
::localtime_r((const time_t*)&i, &ob_tm);
|
||||
::localtime_r((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
gettimeofday(&time_end, NULL);
|
||||
OB_LOG(INFO,
|
||||
"performance average(ns)",
|
||||
"localtime_r",
|
||||
(WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"thread_count",
|
||||
max_thread_count[j]);
|
||||
OB_LOG(INFO, "performance average(ns)",
|
||||
"localtime_r", (WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"thread_count", max_thread_count[j]);
|
||||
|
||||
tmp.stop_ = true;
|
||||
for (int64_t i = 0; i < max_thread_count[j]; ++i) {
|
||||
@ -626,15 +588,12 @@ TEST(utility, multi_thread_ob)
|
||||
|
||||
gettimeofday(&time_begin, NULL);
|
||||
for (int64_t i = 1; i < MAX_COUNT; i += 1) {
|
||||
ob_localtime((const time_t*)&i, &ob_tm);
|
||||
ob_localtime((const time_t *)&i, &ob_tm);
|
||||
}
|
||||
gettimeofday(&time_end, NULL);
|
||||
OB_LOG(INFO,
|
||||
"performance average(ns)",
|
||||
"ob_localtime",
|
||||
(WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"thread_count",
|
||||
max_thread_count[j]);
|
||||
OB_LOG(INFO, "performance average(ns)",
|
||||
"ob_localtime", (WEIGHT * (time_end.tv_sec - time_begin.tv_sec) + time_end.tv_usec - time_begin.tv_usec) / (MAX_COUNT / 1000),
|
||||
"thread_count", max_thread_count[j]);
|
||||
|
||||
tmp.stop_ = true;
|
||||
for (int64_t i = 0; i < max_thread_count[j]; ++i) {
|
||||
@ -646,7 +605,7 @@ TEST(utility, multi_thread_ob)
|
||||
TEST(utility, ob_atoll_overflow)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char* digital_num = "99999999999999999999999999";
|
||||
const char *digital_num = "99999999999999999999999999";
|
||||
int64_t val = 0;
|
||||
ret = ob_atoll(digital_num, val);
|
||||
ASSERT_EQ(OB_SIZE_OVERFLOW, ret);
|
||||
@ -656,16 +615,17 @@ TEST(utility, ob_atoll_overflow)
|
||||
TEST(utility, ob_strtoull_overflow)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char* digital_num = "99999999999999999999999999";
|
||||
char* endptr = NULL;
|
||||
const char *digital_num = "99999999999999999999999999";
|
||||
char *endptr = NULL;
|
||||
uint64_t val = 0;
|
||||
ret = ob_strtoull(digital_num, endptr, val);
|
||||
ASSERT_EQ(OB_SIZE_OVERFLOW, ret);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
Reference in New Issue
Block a user