mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-23 07:50:24 +00:00
!1228 fix:replace map with array
Merge pull request !1228 from yue/master
This commit is contained in:
commit
6a29e12149
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2021-2024 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
|
||||
@ -61,7 +61,8 @@ private:
|
||||
static pthread_once_t TLSKeyOnce_;
|
||||
std::atomic<bool> exitFlag_ = false;
|
||||
std::atomic<uint32_t> usingFlag_ = INVOKER_IDLE_MAGIC;
|
||||
std::unordered_map<int, IRemoteInvoker *> invokers_;
|
||||
static constexpr uint32_t INVOKER_MAX_COUNT = 2;
|
||||
IRemoteInvoker *invokers_[INVOKER_MAX_COUNT] = {nullptr, nullptr};
|
||||
};
|
||||
#ifdef CONFIG_IPC_SINGLE
|
||||
} // namespace IPC_SINGLE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2021-2024 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
|
||||
@ -52,9 +52,13 @@ extern "C" __attribute__((destructor)) void DeleteTlsKey()
|
||||
void IPCThreadSkeleton::TlsDestructor(void *args)
|
||||
{
|
||||
auto *current = static_cast<IPCThreadSkeleton *>(args);
|
||||
auto it = current->invokers_.find(IRemoteObject::IF_PROT_BINDER);
|
||||
if (it != current->invokers_.end()) {
|
||||
BinderInvoker *invoker = reinterpret_cast<BinderInvoker *>(it->second);
|
||||
if (current == nullptr) {
|
||||
ZLOGE(LOG_LABEL, "current is nullptr");
|
||||
return;
|
||||
}
|
||||
uint32_t itemIndex = static_cast<uint32_t>(IRemoteObject::IF_PROT_BINDER);
|
||||
if (itemIndex < IPCThreadSkeleton::INVOKER_MAX_COUNT && current->invokers_[itemIndex] != nullptr) {
|
||||
BinderInvoker *invoker = reinterpret_cast<BinderInvoker *>(current->invokers_[itemIndex]);
|
||||
invoker->FlushCommands(nullptr);
|
||||
invoker->ExitCurrentThread();
|
||||
}
|
||||
@ -102,14 +106,19 @@ IPCThreadSkeleton::~IPCThreadSkeleton()
|
||||
return;
|
||||
}
|
||||
ZLOGD(LOG_LABEL, "%{public}u", ProcessSkeleton::ConvertAddr(this));
|
||||
for (auto it = invokers_.begin(); it != invokers_.end();) {
|
||||
delete it->second;
|
||||
it = invokers_.erase(it);
|
||||
for (auto &invoker : invokers_) {
|
||||
delete invoker;
|
||||
invoker = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
IRemoteInvoker *IPCThreadSkeleton::GetRemoteInvoker(int proto)
|
||||
{
|
||||
if (proto < 0 || static_cast<uint32_t>(proto) >= IPCThreadSkeleton::INVOKER_MAX_COUNT) {
|
||||
ZLOGE(LOG_LABEL, "invalid proto:%{public}d", proto);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
if (current == nullptr) {
|
||||
return nullptr;
|
||||
@ -122,9 +131,9 @@ IRemoteInvoker *IPCThreadSkeleton::GetRemoteInvoker(int proto)
|
||||
}
|
||||
current->usingFlag_ = INVOKER_USE_MAGIC;
|
||||
IRemoteInvoker *invoker = nullptr;
|
||||
auto it = current->invokers_.find(proto);
|
||||
if (it != current->invokers_.end()) {
|
||||
invoker = it->second;
|
||||
auto it = current->invokers_[proto];
|
||||
if (it != nullptr) {
|
||||
invoker = it;
|
||||
} else {
|
||||
InvokerFactory &factory = InvokerFactory::Get();
|
||||
invoker = factory.newInstance(proto);
|
||||
@ -137,7 +146,7 @@ IRemoteInvoker *IPCThreadSkeleton::GetRemoteInvoker(int proto)
|
||||
}
|
||||
|
||||
// non-thread safe, add lock to protect it.
|
||||
current->invokers_.insert(std::make_pair(proto, invoker));
|
||||
current->invokers_[proto] = invoker;
|
||||
}
|
||||
|
||||
current->usingFlag_ = INVOKER_IDLE_MAGIC;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
@ -154,7 +155,7 @@ HWTEST_F(DBinderCallbackStubTest, ProcessProtoTest001, TestSize.Level1)
|
||||
|
||||
int32_t ret = fakeStub->ProcessProto(code, data, reply, option);
|
||||
EXPECT_EQ(ret, BINDER_CALLBACK_AUTHCOMM_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -230,7 +231,7 @@ HWTEST_F(DBinderCallbackStubTest, ProcessProtoTest002, TestSize.Level1)
|
||||
|
||||
int32_t ret = fakeStub->ProcessProto(code, data, reply, option);
|
||||
EXPECT_EQ(ret, DBINDER_SERVICE_PROCESS_PROTO_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -268,6 +269,6 @@ HWTEST_F(DBinderCallbackStubTest, ProcessProtoTest003, TestSize.Level1)
|
||||
|
||||
int32_t ret = fakeStub->ProcessProto(code, data, reply, option);
|
||||
EXPECT_EQ(ret, DBINDER_SERVICE_PROCESS_PROTO_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2021-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include "ipc_debug.h"
|
||||
#include "ipc_skeleton.h"
|
||||
@ -297,13 +298,14 @@ HWTEST_F(IPCDbinderDataBusInvokerTest, NewSessionOfBinderProxy003, TestSize.Leve
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_[IRemoteObject::IF_PROT_DEFAULT] = nullptr;
|
||||
|
||||
IRemoteInvoker *invoker = IPCThreadSkeleton::GetRemoteInvoker(IRemoteObject::IF_PROT_DEFAULT);
|
||||
ASSERT_TRUE(invoker == nullptr);
|
||||
ASSERT_NE(invoker, nullptr);
|
||||
|
||||
DBinderDatabusInvoker testInvoker;
|
||||
std::shared_ptr<DBinderSessionObject> ret = testInvoker.NewSessionOfBinderProxy(handle, remoteSession);
|
||||
EXPECT_TRUE (ret == nullptr);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1090,7 +1092,7 @@ HWTEST_F(IPCDbinderDataBusInvokerTest, GetSelfFirstCallerTokenIDTest001, TestSiz
|
||||
|
||||
auto ret = testInvoker.GetSelfFirstCallerTokenID();
|
||||
EXPECT_EQ(ret, 111);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1108,7 +1110,7 @@ HWTEST_F(IPCDbinderDataBusInvokerTest, GetSelfFirstCallerTokenIDTest002, TestSiz
|
||||
|
||||
auto ret = testInvoker.GetSelfFirstCallerTokenID();
|
||||
EXPECT_EQ(ret, 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstring>
|
||||
@ -105,7 +107,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_JoinWorkThread_001, TestSize.Level1)
|
||||
.WillRepeatedly(testing::Return(IRemoteInvoker::ACTIVE_INVOKER));
|
||||
OH_IPCSkeleton_JoinWorkThread();
|
||||
ASSERT_TRUE(IPCThreadSkeleton::GetCurrent() != nullptr);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -120,7 +122,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_StopWorkThread_001, TestSize.Level1)
|
||||
|
||||
OH_IPCSkeleton_StopWorkThread();
|
||||
ASSERT_TRUE(IPCThreadSkeleton::GetCurrent() != nullptr);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -140,7 +142,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_GetCallingTokenId_001, TestSize.Level
|
||||
|
||||
EXPECT_EQ(result, tokenId);
|
||||
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -182,7 +184,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_IsLocalCalling_001, TestSize.Level1)
|
||||
.WillRepeatedly(testing::Return(false));
|
||||
|
||||
EXPECT_EQ(OH_IPCSkeleton_IsLocalCalling(), false);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -203,7 +205,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_SetCallingIdentity_001, TestSize.Leve
|
||||
|
||||
auto ret = OH_IPCSkeleton_SetCallingIdentity(testStr.c_str());
|
||||
EXPECT_EQ(ret, OH_IPC_SUCCESS);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -234,7 +236,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_ResetCallingIdentity_001, TestSize.Le
|
||||
if (identity != nullptr) {
|
||||
delete identity;
|
||||
}
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -250,7 +252,7 @@ HWTEST_F(IpcCApiSkeletonUnitTest, Skeleton_IsHandlingTransaction_001, TestSize.L
|
||||
.WillRepeatedly(testing::Return(IRemoteInvoker::ACTIVE_INVOKER));
|
||||
|
||||
EXPECT_EQ(OH_IPCSkeleton_IsHandlingTransaction(), true);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2021-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
@ -329,7 +330,7 @@ HWTEST_F(IPCNativeUnitTest, OnRemoteRequestTest002, TestSize.Level1)
|
||||
|
||||
auto ret = testStub->OnRemoteRequest(code, data, reply, option);
|
||||
EXPECT_EQ(ret, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
@ -53,7 +54,7 @@ void IPCObjectProxyTest::SetUp()
|
||||
void IPCObjectProxyTest::TearDown()
|
||||
{
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +113,7 @@ HWTEST_F(IPCObjectProxyTest, SendRequestInnerTest001, TestSize.Level1)
|
||||
|
||||
auto ret = object.SendRequestInner(isLocal, code, data, reply, option);
|
||||
ASSERT_TRUE(ret == ERR_DEAD_OBJECT);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -244,7 +245,7 @@ HWTEST_F(IPCObjectProxyTest, GetInterfaceDescriptorTest005, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetInterfaceDescriptor();
|
||||
ASSERT_TRUE(ret.size() == 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -272,7 +273,7 @@ HWTEST_F(IPCObjectProxyTest, GetInterfaceDescriptorTest006, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetInterfaceDescriptor();
|
||||
ASSERT_TRUE(ret.size() == 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -362,7 +363,7 @@ HWTEST_F(IPCObjectProxyTest, GetGrantedSessionNameTest003, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetSessionNameForPidUid(1, 1);
|
||||
ASSERT_TRUE(ret.size() == 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -390,7 +391,7 @@ HWTEST_F(IPCObjectProxyTest, GetSessionNameForPidUidTest004, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetSessionNameForPidUid(1, 1);
|
||||
ASSERT_TRUE(ret.size() == 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -418,7 +419,7 @@ HWTEST_F(IPCObjectProxyTest, GetSessionNameForPidUidTest005, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetSessionNameForPidUid(1, 1);
|
||||
ASSERT_TRUE(ret.size() == 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -439,7 +440,7 @@ HWTEST_F(IPCObjectProxyTest, OnFirstStrongRefTest005, TestSize.Level1)
|
||||
|
||||
object.OnFirstStrongRef(nullptr);
|
||||
ASSERT_TRUE(object.handle_ == 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -796,7 +797,7 @@ HWTEST_F(IPCObjectProxyTest, GetProtoInfoTest003, TestSize.Level1)
|
||||
|
||||
auto ret = object.GetProtoInfo();
|
||||
ASSERT_TRUE(ret != IRemoteObject::IF_PROT_DATABUS);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -931,7 +932,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest001, TestSize.Level1)
|
||||
auto ret = object->UpdateDatabusClientSession(1, reply);
|
||||
|
||||
ASSERT_TRUE(ret == false);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -947,7 +948,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest002, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -981,7 +982,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest003, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -1015,7 +1016,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest004, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 0;
|
||||
@ -1048,7 +1049,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest005, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -1089,7 +1090,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest006, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -1131,7 +1132,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest007, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -1172,7 +1173,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest008, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 0;
|
||||
@ -1209,7 +1210,7 @@ HWTEST_F(IPCObjectProxyTest, UpdateDatabusClientSessionTest009, TestSize.Level1)
|
||||
object->proto_ = IRemoteObject::IF_PROT_DEFAULT;
|
||||
|
||||
IPCThreadSkeleton *current = IPCThreadSkeleton::GetCurrent();
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
|
||||
MessageParcel reply;
|
||||
uint64_t stubIndex = 1;
|
||||
@ -1342,7 +1343,7 @@ HWTEST_F(IPCObjectProxyTest, RemoveSessionNameTest001, TestSize.Level1)
|
||||
int result = object.RemoveSessionName(sessionName);
|
||||
ASSERT_EQ(result, ERR_NONE);
|
||||
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1366,6 +1367,6 @@ HWTEST_F(IPCObjectProxyTest, RemoveSessionNameTest002, TestSize.Level1)
|
||||
int result = object.RemoveSessionName(sessionName);
|
||||
ASSERT_EQ(result, ERR_DEAD_OBJECT);
|
||||
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <pthread.h>
|
||||
@ -322,7 +323,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest006, TestSize.Level1)
|
||||
current->invokers_[IRemoteObject::IF_PROT_BINDER] = invoker;
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -347,7 +348,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest007, TestSize.Level1)
|
||||
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -395,7 +396,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest009, TestSize.Level1)
|
||||
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, ERR_NONE);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
delete dbinderInvoker;
|
||||
}
|
||||
@ -441,7 +442,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest011, TestSize.Level1)
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, ERR_NONE);
|
||||
delete invoker;
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,7 +519,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest015, TestSize.Level1)
|
||||
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -564,7 +565,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest016, TestSize.Level1)
|
||||
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_NE(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -592,7 +593,7 @@ HWTEST_F(IPCObjectStubTest, SendRequestTest017, TestSize.Level1)
|
||||
|
||||
int result = testStub->SendRequest(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
#endif
|
||||
@ -1050,7 +1051,7 @@ HWTEST_F(IPCObjectStubTest, GetGrantedSessionNameTest001, TestSize.Level1)
|
||||
|
||||
int result = testStub->GetGrantedSessionName(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1090,7 +1091,7 @@ HWTEST_F(IPCObjectStubTest, GetSessionNameForPidUidTest001, TestSize.Level1)
|
||||
|
||||
int result = testStub->GetSessionNameForPidUid(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1130,7 +1131,7 @@ HWTEST_F(IPCObjectStubTest, GetSessionNameForPidUidTest002, TestSize.Level1)
|
||||
|
||||
int result = testStub->GetSessionNameForPidUid(code, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_INVALID_DATA_ERR);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1172,7 +1173,7 @@ HWTEST_F(IPCObjectStubTest, GetCallingTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto ret = testStub->GetCallingTokenID();
|
||||
EXPECT_EQ(ret, 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -1199,6 +1200,6 @@ HWTEST_F(IPCObjectStubTest, GetCallingFullTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto ret = testStub->GetCallingFullTokenID();
|
||||
EXPECT_EQ(ret, 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022-2024 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
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
@ -80,7 +81,7 @@ HWTEST_F(IPCSkeletonTest, JoinWorkThreadTest001, TestSize.Level1)
|
||||
skeleton.JoinWorkThread();
|
||||
ASSERT_TRUE(IPCThreadSkeleton::GetCurrent() != nullptr);
|
||||
delete invoker;
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +102,7 @@ HWTEST_F(IPCSkeletonTest, StopWorkThreadTest001, TestSize.Level1)
|
||||
|
||||
skeleton.StopWorkThread();
|
||||
ASSERT_TRUE(IPCThreadSkeleton::GetCurrent() != nullptr);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -126,7 +127,7 @@ HWTEST_F(IPCSkeletonTest, GetCallingSidTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetCallingSid();
|
||||
EXPECT_EQ(result, "");
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -151,7 +152,7 @@ HWTEST_F(IPCSkeletonTest, GetCallingTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetCallingTokenID();
|
||||
EXPECT_EQ(result, 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -179,7 +180,7 @@ HWTEST_F(IPCSkeletonTest, GetCallingFullTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetCallingFullTokenID();
|
||||
EXPECT_EQ(result, 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -199,7 +200,7 @@ HWTEST_F(IPCSkeletonTest, GetFirstTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetFirstTokenID();
|
||||
EXPECT_EQ(result, 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +219,7 @@ HWTEST_F(IPCSkeletonTest, GetFirstFullTokenIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetFirstFullTokenID();
|
||||
EXPECT_EQ(result, 0);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,7 +246,7 @@ HWTEST_F(IPCSkeletonTest, GetFirstFullTokenIDTest002, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetFirstFullTokenID();
|
||||
EXPECT_EQ(result, 1);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -276,7 +277,7 @@ HWTEST_F(IPCSkeletonTest, GetFirstFullTokenIDTest003, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetFirstFullTokenID();
|
||||
EXPECT_EQ(result, 111);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -302,7 +303,7 @@ HWTEST_F(IPCSkeletonTest, GetLocalDeviceIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetLocalDeviceID();
|
||||
EXPECT_STREQ(result.c_str(), testID.c_str());
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -328,7 +329,7 @@ HWTEST_F(IPCSkeletonTest, GetCallingDeviceIDTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.GetCallingDeviceID();
|
||||
EXPECT_STREQ(result.c_str(), testDeviceID.c_str());
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -353,7 +354,7 @@ HWTEST_F(IPCSkeletonTest, IsLocalCallingTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.IsLocalCalling();
|
||||
ASSERT_TRUE(!result);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -382,7 +383,7 @@ HWTEST_F(IPCSkeletonTest, FlushCommandsTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.FlushCommands(object);
|
||||
EXPECT_EQ(result, 111);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
delete object;
|
||||
}
|
||||
@ -409,7 +410,7 @@ HWTEST_F(IPCSkeletonTest, ResetCallingIdentityTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.ResetCallingIdentity();
|
||||
EXPECT_STREQ(result.c_str(), testStr.c_str());
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -433,7 +434,7 @@ HWTEST_F(IPCSkeletonTest, ResetCallingIdentityTest002, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.ResetCallingIdentity();
|
||||
EXPECT_STREQ(result.c_str(), testStr.c_str());
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -459,7 +460,7 @@ HWTEST_F(IPCSkeletonTest, SetCallingIdentityTest001, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.SetCallingIdentity(testStr);
|
||||
ASSERT_TRUE(!result);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
||||
@ -483,6 +484,6 @@ HWTEST_F(IPCSkeletonTest, SetCallingIdentityTest002, TestSize.Level1)
|
||||
|
||||
auto result = skeleton.SetCallingIdentity(testStr);
|
||||
ASSERT_TRUE(result);
|
||||
current->invokers_.clear();
|
||||
std::fill(current->invokers_, current->invokers_ + IPCThreadSkeleton::INVOKER_MAX_COUNT, nullptr);
|
||||
delete invoker;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user