[CP] fix leak of MALLOC_TIME_MONITOR log when ob_log alloc
This commit is contained in:
1
deps/oblib/unittest/common/CMakeLists.txt
vendored
1
deps/oblib/unittest/common/CMakeLists.txt
vendored
@ -1,6 +1,7 @@
|
||||
#oblib_addtest(test_memfrag_recycle_allocator.cpp)
|
||||
oblib_addtest(test_cell_reader.cpp)
|
||||
oblib_addtest(test_cell_writer.cpp)
|
||||
oblib_addtest(test_common_utility.cpp)
|
||||
oblib_addtest(test_delay_free_allocator.cpp)
|
||||
#oblib_addtest(test_ext_store_range.cpp)
|
||||
#oblib_addtest(test_multi_version_range.cpp)
|
||||
|
||||
50
deps/oblib/unittest/common/test_common_utility.cpp
vendored
Normal file
50
deps/oblib/unittest/common/test_common_utility.cpp
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#define private public
|
||||
#include "common/ob_common_utility.h"
|
||||
using namespace oceanbase::common;
|
||||
TEST(TestBasicTimeGuard, tl_time_guard)
|
||||
{
|
||||
EXPECT_TRUE(NULL == ObBasicTimeGuard::get_tl_time_guard());
|
||||
BASIC_TIME_GUARD(tg, "ObLog");
|
||||
EXPECT_TRUE(&tg == ObBasicTimeGuard::get_tl_time_guard());
|
||||
{
|
||||
BASIC_TIME_GUARD(tg1, "ObMalloc");
|
||||
EXPECT_TRUE(&tg1 == ObBasicTimeGuard::get_tl_time_guard());
|
||||
}
|
||||
EXPECT_TRUE(&tg == ObBasicTimeGuard::get_tl_time_guard());
|
||||
}
|
||||
|
||||
TEST(TestBasicTimeGuard, click_infos)
|
||||
{
|
||||
BASIC_TIME_GUARD(tg, "ObMalloc");
|
||||
int index = 8;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
if (index == i) {
|
||||
usleep(1);
|
||||
} else {
|
||||
usleep(100);
|
||||
}
|
||||
BASIC_TIME_GUARD_CLICK("alloc_chunk");
|
||||
}
|
||||
EXPECT_EQ(index, tg.click_infos_[index].seq_);
|
||||
usleep(50);
|
||||
BASIC_TIME_GUARD_CLICK("target");
|
||||
EXPECT_EQ(16, tg.click_infos_[index].seq_);
|
||||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user