提交 0feee11c 编写于 作者: Y YOUR_NAME

Description:add dlclose test

Feature or Bugfix:Feature
Binary Source: No
Signed-off-by: NYOUR_NAME <heyingjiao@huawei.com>
上级 138ec9ff
......@@ -39,6 +39,7 @@ ohos_shared_library("ipc_core") {
"$IPC_CORE_ROOT/src/core/source/databus_session_callback.cpp",
"$IPC_CORE_ROOT/src/core/source/dbinder_callback_stub.cpp",
"$IPC_CORE_ROOT/src/core/source/dbinder_session_object.cpp",
"$IPC_CORE_ROOT/src/core/source/ipc_core_so_init.cpp",
"$IPC_CORE_ROOT/src/core/source/ipc_file_descriptor.cpp",
"$IPC_CORE_ROOT/src/core/source/ipc_object_proxy.cpp",
"$IPC_CORE_ROOT/src/core/source/ipc_object_stub.cpp",
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string>
#include <dlfcn.h>
#include "log_tags.h"
#include "ipc_debug.h"
namespace OHOS {
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_RPC, "ipc_core_so_init" };
extern "C" __attribute__((constructor)) void init(void) {
std::string path = std::string("libclang_rt.ubsan_standalone.so");
void *handle = dlopen(path.c_str(), RTLD_NOW);
if (handle == nullptr) {
ZLOGE(LOG_LABEL, "ipc_core.so init fail");
}
}
} // namespace OHOS
\ No newline at end of file
......@@ -370,6 +370,20 @@ if (product_name == "rk3568" && target_cpu == "arm64") {
}
}
ohos_unittest("IPCSoDlcloseTest") {
module_out_path = MODULE_OUTPUT_PATH
sources = [ "ipc_so_dlclose_unittest.cpp" ]
deps = [
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
resource_config_file =
"//foundation/communication/ipc/test/resource/ipc/ohos_test.xml"
}
###############################################################################
group("unittest") {
testonly = true
......@@ -380,6 +394,7 @@ group("unittest") {
":IPCHiTraceUnitTest",
":IPCMockUnitTest",
":IPCNativeUnitTest",
":IPCSoDlcloseTest",
":InvokerFactoryTest",
":RPCFeatureUnitTest",
]
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include <unistd.h>
#include <dlfcn.h>
using namespace testing::ext;
class IpcSoDlcloseTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void IpcSoDlcloseTest::SetUpTestCase()
{
}
void IpcSoDlcloseTest::TearDownTestCase()
{
}
void IpcSoDlcloseTest::SetUp()
{
}
void IpcSoDlcloseTest::TearDown()
{
}
/**
* @tc.name: SingleSoDlcloseTest001
* @tc.desc: test if ipc_core.so ipc_single.so dlclose normal
* @tc.type: FUNC
*/
HWTEST_F(IpcSoDlcloseTest, SingleSoDlcloseTest001, TestSize.Level1)
{
std::string path = std::string("libipc_single.z.so");
for (int i = 0; i < 100; i++) {
void *handle = dlopen(path.c_str(), RTLD_NOW);
if (handle != nullptr) {
dlclose(handle);
handle = nullptr;
}
}
}
/**
* @tc.name: CoreSoDlcloseTest001
* @tc.desc: test if ipc_core.so ipc_single.so dlclose normal
* @tc.type: FUNC
*/
HWTEST_F(IpcSoDlcloseTest, CoreSoDlcloseTest001, TestSize.Level1)
{
std::string path = std::string("libipc_core.z.so");
for (int i = 0; i < 100; i++) {
void *handle = dlopen(path.c_str(), RTLD_NOW);
if (handle != nullptr) {
dlclose(handle);
handle = nullptr;
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册