From b614af88e819b065d31af5028ecd2ceefb98dcf1 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Tue, 5 Aug 2025 10:24:26 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanlin15 --- .../core/framework/source/message_parcel.cpp | 6 ++--- .../small/client/client_business_impl.c | 26 +++++++++---------- test/example/small/client/client_callback.c | 6 +++-- test/example/small/client/client_main.c | 2 -- .../small/server/server_business_impl.c | 21 ++++++++------- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/ipc/native/src/core/framework/source/message_parcel.cpp b/ipc/native/src/core/framework/source/message_parcel.cpp index 8fdc9788..df0a93fc 100644 --- a/ipc/native/src/core/framework/source/message_parcel.cpp +++ b/ipc/native/src/core/framework/source/message_parcel.cpp @@ -463,14 +463,14 @@ const void *MessageParcel::ReadRawData(size_t size) /* if rawDataFd_ == 0 means rawData is received from remote */ if (rawData_ != nullptr && writeRawDataFd_ == 0) { /* should read fd for move readCursor of parcel */ - if (ReadFileDescriptor()) { - // do nothing - } + int fd = ReadFileDescriptor(); if (rawDataSize_ != size) { ZLOGE(LOG_LABEL, "rawData is received from remote, the rawDataSize:%{public}zu not equal size:%{public}zu", rawDataSize_, size); + ::close(fd); return nullptr; } + ::close(fd); return rawData_.get(); } int fd = ReadFileDescriptor(); diff --git a/test/example/small/client/client_business_impl.c b/test/example/small/client/client_business_impl.c index 434e7f98..0bf0be08 100644 --- a/test/example/small/client/client_business_impl.c +++ b/test/example/small/client/client_business_impl.c @@ -113,7 +113,7 @@ static int32_t StartTimerForFdEvent() static void SetClientIdentity(unsigned int handle, uintptr_t token, uintptr_t cookie) { - g_clientIdentify.handle = handle; + g_clientIdentify.handle = static_casthandle; g_clientIdentify.token = token; g_clientIdentify.cookie = cookie; return; @@ -192,7 +192,7 @@ void InitLocalIdentity() .cookie = (uintptr_t)&objectStub }; // save to local - SetClientIdentity(clientIdentity.handle, clientIdentity.token, clientIdentity.cookie); + SetClientIdentity(static_castclientIdentity.handle, clientIdentity.token, clientIdentity.cookie); return; } @@ -415,7 +415,7 @@ void SendInt8Vector() IpcIo io; IpcIo *ioPtr = &io; int8_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (int8_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, Int8Vector, CLIENT_VECTOR_LEN); @@ -434,7 +434,7 @@ void SendInt16Vector() IpcIo io; IpcIo *ioPtr = &io; int16_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (int16_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, Int16Vector, CLIENT_VECTOR_LEN); @@ -453,7 +453,7 @@ void SendInt32Vector() IpcIo io; IpcIo *ioPtr = &io; int32_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (int32_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, Int32Vector, CLIENT_VECTOR_LEN); @@ -472,7 +472,7 @@ void SendInt64Vector() IpcIo io; IpcIo *ioPtr = &io; int64_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (int64_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, Int64Vector, CLIENT_VECTOR_LEN); @@ -491,7 +491,7 @@ void SendUint8Vector() IpcIo io; IpcIo *ioPtr = &io; uint8_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (uint8_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, UInt8Vector, CLIENT_VECTOR_LEN); @@ -510,7 +510,7 @@ void SendUint16Vector() IpcIo io; IpcIo *ioPtr = &io; uint16_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (uint16_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, UInt16Vector, CLIENT_VECTOR_LEN); @@ -529,7 +529,7 @@ void SendUint32Vector() IpcIo io; IpcIo *ioPtr = &io; uint32_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (uint32_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, UInt32Vector, CLIENT_VECTOR_LEN); @@ -548,7 +548,7 @@ void SendUint64Vector() IpcIo io; IpcIo *ioPtr = &io; uint64_t sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (uint64_t i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = CLIENT_TEST_NUMBER + i; } InitSendPtr(ioPtr, sendData, UInt64Vector, CLIENT_VECTOR_LEN); @@ -567,7 +567,7 @@ void SendFloatVector() IpcIo io; IpcIo *ioPtr = &io; float sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (float i = 0.0f; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = PI + i; } InitSendPtr(ioPtr, sendData, FloatVector, CLIENT_VECTOR_LEN); @@ -586,7 +586,7 @@ void SendDoubleVector() IpcIo io; IpcIo *ioPtr = &io; double sendData[CLIENT_VECTOR_LEN]; - for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { + for (double i = 0.0d; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = PI + i; } InitSendPtr(ioPtr, sendData, DoubleVector, CLIENT_VECTOR_LEN); @@ -643,7 +643,7 @@ void SendFileDescriptor() DeinitPipe(); } else { buffer[readLen] = '\0'; - RPC_LOG_INFO("[ipc_test_client] SendFileDescriptor receive size=%d data=%s", readLen, buffer); + RPC_LOG_INFO("[ipc_test_client] SendFileDescriptor receive size=%zu data=%s", readLen, buffer); DeinitPipe(); } RPC_LOG_INFO("[ipc_test_client] ------ SendFileDescriptor end ------"); diff --git a/test/example/small/client/client_callback.c b/test/example/small/client/client_callback.c index 38da67ac..3372eac6 100644 --- a/test/example/small/client/client_callback.c +++ b/test/example/small/client/client_callback.c @@ -137,6 +137,7 @@ static void OnInt16VectorRecv(IpcIo *reply) } RPC_LOG_INFO("[ipc_test_client] OnInt16VectorRecv called, size=%zu, start=%" PRId16 ", end=%" PRId16 "", size, dataVector[0], dataVector[size - 1]); + free(dataVector); return; } @@ -286,8 +287,9 @@ static void OnRawDataRecv(IpcIo *reply) static void OnBufferRecv(IpcIo *reply) { SvcIdentity *recvData = NULL; - recvData = ReadBuffer(reply, sizeof(SvcIdentity)); - if (recvData == NULL) { + const uint8_t *retPtr = NULL; + retPtr = ReadBuffer(reply, sizeof(SvcIdentity)); + if (retPtr == NULL) { RPC_LOG_ERROR("[ipc_test_client] OnBufferRecv error, recvData is null"); return; } diff --git a/test/example/small/client/client_main.c b/test/example/small/client/client_main.c index e3124d0e..6a251ab7 100644 --- a/test/example/small/client/client_main.c +++ b/test/example/small/client/client_main.c @@ -29,8 +29,6 @@ #define WAIT_SERVER_READY_INTERVAL_COUNT 50 #define EXIT_TIMEOUT 60 // 60s -static IClientProxy *g_serverProxy = NULL; - static void ServerDeadCallback(void *arg) { RPC_LOG_INFO("====== server dead ServerDeadCallback called ======"); diff --git a/test/example/small/server/server_business_impl.c b/test/example/small/server/server_business_impl.c index f51f5358..a9029e8f 100644 --- a/test/example/small/server/server_business_impl.c +++ b/test/example/small/server/server_business_impl.c @@ -336,7 +336,7 @@ static int32_t OnInt8VectorReceived(IpcIo *req, IpcIo *reply) // reply to client int8_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (int8_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteInt8Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -363,13 +363,14 @@ static int32_t OnInt16VectorReceived(IpcIo *req, IpcIo *reply) // reply to client int16_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (int16_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteInt16Vector(reply, replyData, SERVER_VECTOR_LEN); RPC_LOG_INFO("[ipc_test_server] OnInt16VectorReceived called, size=%zu, start=%" PRId16 ", end=%" PRId16 "", size, data[0], data[size - 1]); + free(data); return ERR_NONE; } @@ -390,7 +391,7 @@ static int32_t OnInt32VectorReceived(IpcIo *req, IpcIo *reply) // reply to client int32_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (int32_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteInt32Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -417,7 +418,7 @@ static int32_t OnInt64VectorReceived(IpcIo *req, IpcIo *reply) // reply to client int64_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (int64_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteInt64Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -444,7 +445,7 @@ static int32_t OnUint8VectorReceived(IpcIo *req, IpcIo *reply) // reply to client uint8_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (uint8_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteUInt8Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -471,7 +472,7 @@ static int32_t OnUint16VectorReceived(IpcIo *req, IpcIo *reply) // reply to client uint16_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (uint16_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteUInt16Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -498,7 +499,7 @@ static int32_t OnUint32VectorReceived(IpcIo *req, IpcIo *reply) // reply to client uint32_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (uint32_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteUInt32Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -525,7 +526,7 @@ static int32_t OnUint64VectorReceived(IpcIo *req, IpcIo *reply) // reply to client uint64_t replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (uint64_t i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = SERVER_TEST_NUMBER + i; } WriteUInt64Vector(reply, replyData, SERVER_VECTOR_LEN); @@ -552,7 +553,7 @@ static int32_t OnFloatVectorReceived(IpcIo *req, IpcIo *reply) // reply to client float replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (float i = 0.0f; i < SERVER_VECTOR_LEN; i++) { replyData[i] = HALF_PI + i; } WriteFloatVector(reply, replyData, SERVER_VECTOR_LEN); @@ -579,7 +580,7 @@ static int32_t OnDoubleVectorReceived(IpcIo *req, IpcIo *reply) // reply to client double replyData[SERVER_VECTOR_LEN]; - for (int i = 0; i < SERVER_VECTOR_LEN; i++) { + for (double i = 0.0d; i < SERVER_VECTOR_LEN; i++) { replyData[i] = HALF_PI + i; } WriteDoubleVector(reply, replyData, SERVER_VECTOR_LEN); -- Gitee From 093491bab216c45f0ff7de5b40919e05321f8e10 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Tue, 5 Aug 2025 11:12:52 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanlin15 --- ipc/native/src/core/framework/source/message_parcel.cpp | 5 +---- test/example/small/client/client_business_impl.c | 2 +- test/example/small/client/client_callback.c | 4 ++-- test/example/small/server/server_business_impl.c | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ipc/native/src/core/framework/source/message_parcel.cpp b/ipc/native/src/core/framework/source/message_parcel.cpp index df0a93fc..a0c6fc22 100644 --- a/ipc/native/src/core/framework/source/message_parcel.cpp +++ b/ipc/native/src/core/framework/source/message_parcel.cpp @@ -462,15 +462,12 @@ const void *MessageParcel::ReadRawData(size_t size) /* if rawDataFd_ == 0 means rawData is received from remote */ if (rawData_ != nullptr && writeRawDataFd_ == 0) { - /* should read fd for move readCursor of parcel */ - int fd = ReadFileDescriptor(); + /* should read fd for move readCursor of parcel */ if (rawDataSize_ != size) { ZLOGE(LOG_LABEL, "rawData is received from remote, the rawDataSize:%{public}zu not equal size:%{public}zu", rawDataSize_, size); - ::close(fd); return nullptr; } - ::close(fd); return rawData_.get(); } int fd = ReadFileDescriptor(); diff --git a/test/example/small/client/client_business_impl.c b/test/example/small/client/client_business_impl.c index 0bf0be08..b91f261c 100644 --- a/test/example/small/client/client_business_impl.c +++ b/test/example/small/client/client_business_impl.c @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include #include #include #include diff --git a/test/example/small/client/client_callback.c b/test/example/small/client/client_callback.c index 3372eac6..d9a30f5a 100644 --- a/test/example/small/client/client_callback.c +++ b/test/example/small/client/client_callback.c @@ -286,8 +286,8 @@ static void OnRawDataRecv(IpcIo *reply) static void OnBufferRecv(IpcIo *reply) { - SvcIdentity *recvData = NULL; - const uint8_t *retPtr = NULL; + SvcIdentity *recvData = nullptr; + const uint8_t *retPtr = nullptr; retPtr = ReadBuffer(reply, sizeof(SvcIdentity)); if (retPtr == NULL) { RPC_LOG_ERROR("[ipc_test_client] OnBufferRecv error, recvData is null"); diff --git a/test/example/small/server/server_business_impl.c b/test/example/small/server/server_business_impl.c index a9029e8f..1dc0fe0f 100644 --- a/test/example/small/server/server_business_impl.c +++ b/test/example/small/server/server_business_impl.c @@ -553,7 +553,7 @@ static int32_t OnFloatVectorReceived(IpcIo *req, IpcIo *reply) // reply to client float replyData[SERVER_VECTOR_LEN]; - for (float i = 0.0f; i < SERVER_VECTOR_LEN; i++) { + for (int i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = HALF_PI + i; } WriteFloatVector(reply, replyData, SERVER_VECTOR_LEN); @@ -580,7 +580,7 @@ static int32_t OnDoubleVectorReceived(IpcIo *req, IpcIo *reply) // reply to client double replyData[SERVER_VECTOR_LEN]; - for (double i = 0.0d; i < SERVER_VECTOR_LEN; i++) { + for (int i = 0; i < SERVER_VECTOR_LEN; i++) { replyData[i] = HALF_PI + i; } WriteDoubleVector(reply, replyData, SERVER_VECTOR_LEN); -- Gitee From 9a04fbff847043f4b50173a652400534e87d5f5d Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Thu, 7 Aug 2025 10:11:17 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanlin15 --- test/example/small/client/client_business_impl.c | 11 +++++------ test/example/small/client/client_callback.c | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test/example/small/client/client_business_impl.c b/test/example/small/client/client_business_impl.c index b91f261c..5664f8b8 100644 --- a/test/example/small/client/client_business_impl.c +++ b/test/example/small/client/client_business_impl.c @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include #include #include @@ -113,7 +112,7 @@ static int32_t StartTimerForFdEvent() static void SetClientIdentity(unsigned int handle, uintptr_t token, uintptr_t cookie) { - g_clientIdentify.handle = static_casthandle; + g_clientIdentify.handle = (int32_t)handle; g_clientIdentify.token = token; g_clientIdentify.cookie = cookie; return; @@ -192,7 +191,7 @@ void InitLocalIdentity() .cookie = (uintptr_t)&objectStub }; // save to local - SetClientIdentity(static_castclientIdentity.handle, clientIdentity.token, clientIdentity.cookie); + SetClientIdentity((unsigned int)clientIdentity.handle, clientIdentity.token, clientIdentity.cookie); return; } @@ -567,7 +566,7 @@ void SendFloatVector() IpcIo io; IpcIo *ioPtr = &io; float sendData[CLIENT_VECTOR_LEN]; - for (float i = 0.0f; i < CLIENT_VECTOR_LEN; i++) { + for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = PI + i; } InitSendPtr(ioPtr, sendData, FloatVector, CLIENT_VECTOR_LEN); @@ -586,7 +585,7 @@ void SendDoubleVector() IpcIo io; IpcIo *ioPtr = &io; double sendData[CLIENT_VECTOR_LEN]; - for (double i = 0.0d; i < CLIENT_VECTOR_LEN; i++) { + for (int i = 0; i < CLIENT_VECTOR_LEN; i++) { sendData[i] = PI + i; } InitSendPtr(ioPtr, sendData, DoubleVector, CLIENT_VECTOR_LEN); @@ -643,7 +642,7 @@ void SendFileDescriptor() DeinitPipe(); } else { buffer[readLen] = '\0'; - RPC_LOG_INFO("[ipc_test_client] SendFileDescriptor receive size=%zu data=%s", readLen, buffer); + RPC_LOG_INFO("[ipc_test_client] SendFileDescriptor receive size=%zd data=%s", readLen, buffer); DeinitPipe(); } RPC_LOG_INFO("[ipc_test_client] ------ SendFileDescriptor end ------"); diff --git a/test/example/small/client/client_callback.c b/test/example/small/client/client_callback.c index d9a30f5a..5c593b6a 100644 --- a/test/example/small/client/client_callback.c +++ b/test/example/small/client/client_callback.c @@ -286,11 +286,10 @@ static void OnRawDataRecv(IpcIo *reply) static void OnBufferRecv(IpcIo *reply) { - SvcIdentity *recvData = nullptr; - const uint8_t *retPtr = nullptr; + const uint8_t *retPtr = NULL; retPtr = ReadBuffer(reply, sizeof(SvcIdentity)); if (retPtr == NULL) { - RPC_LOG_ERROR("[ipc_test_client] OnBufferRecv error, recvData is null"); + RPC_LOG_ERROR("[ipc_test_client] OnBufferRecv error, retPtr is null"); return; } RPC_LOG_ERROR("[ipc_test_client] OnBufferRecv success"); -- Gitee From a2375e9c3bc9baaf305b63731d928c861c9bbfc2 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Thu, 7 Aug 2025 10:58:53 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanlin15 --- test/example/small/client/client_business_impl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/example/small/client/client_business_impl.c b/test/example/small/client/client_business_impl.c index 5664f8b8..439f5dad 100644 --- a/test/example/small/client/client_business_impl.c +++ b/test/example/small/client/client_business_impl.c @@ -110,9 +110,9 @@ static int32_t StartTimerForFdEvent() return ERR_NONE; } -static void SetClientIdentity(unsigned int handle, uintptr_t token, uintptr_t cookie) +static void SetClientIdentity(int32_t handle, uintptr_t token, uintptr_t cookie) { - g_clientIdentify.handle = (int32_t)handle; + g_clientIdentify.handle = handle; g_clientIdentify.token = token; g_clientIdentify.cookie = cookie; return; @@ -191,7 +191,7 @@ void InitLocalIdentity() .cookie = (uintptr_t)&objectStub }; // save to local - SetClientIdentity((unsigned int)clientIdentity.handle, clientIdentity.token, clientIdentity.cookie); + SetClientIdentity(clientIdentity.handle, clientIdentity.token, clientIdentity.cookie); return; } -- Gitee From cb84f152e80cb56896a4f5686f4ef7c3df43eb90 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Thu, 21 Aug 2025 19:24:51 +0800 Subject: [PATCH 5/9] test ut Signed-off-by: hanlin15 --- .../dbinder_service/src/dbinder_service.cpp | 77 ++++++++++++++++++- .../src/socket/dbinder_remote_listener.cpp | 5 ++ .../unittest/dbinder_service_unittest.cpp | 10 ++- .../unittest/mock_dbinder_remote_listener.h | 5 +- .../source/databus_socket_listener.cpp | 6 +- .../source/dbinder_databus_invoker.cpp | 10 ++- .../dbinder/source/dbinder_softbus_client.cpp | 5 +- .../framework/source/ipc_process_skeleton.cpp | 30 ++++++-- .../core/invoker/source/binder_invoker.cpp | 18 ++++- .../databus_socket_listener_unittest.cpp | 10 +++ .../ipc_binder_databus_invoker_unittest.cpp | 5 +- .../common/ipc_process_skeleton_unittest.cpp | 8 +- .../src/dbinder_service_unittest.cpp | 6 +- 13 files changed, 173 insertions(+), 22 deletions(-) diff --git a/dbinder/dbinder_service/src/dbinder_service.cpp b/dbinder/dbinder_service/src/dbinder_service.cpp index 3104b9ca..3b19b841 100644 --- a/dbinder/dbinder_service/src/dbinder_service.cpp +++ b/dbinder/dbinder_service/src/dbinder_service.cpp @@ -14,7 +14,7 @@ */ #include "dbinder_service.h" - +#include #include #include #include "securec.h" @@ -69,6 +69,7 @@ DBinderService::~DBinderService() // LCOV_EXCL_START std::string DBinderService::GetLocalDeviceID() { + std::cout<<"$$$$$LONG$$$$$DBinderService-GetLocalDeviceID called"<(); if (remoteListener_ == nullptr) { + std::cout<<"$$$$$LONG$$$$$DBinderService-StartRemoteListener failed to create remote listener"<StartListener() != true) { + std::cout<<"$$$$$LONG$$$$$DBinderService-StartRemoteListener StartListener fialed"< &stub, cons std::vector> DBinderService::FindDBinderStub(const std::u16string &service, const std::string &device) { + std::cout<<"$$$$$LONG$$$$$DBinderService-FindDBinderStub called"<> result; std::lock_guard lockGuard(handleEntryMutex_); for (auto it = DBinderStubRegisted_.begin(); it != DBinderStubRegisted_.end(); ++it) { @@ -473,20 +482,24 @@ std::shared_ptr DBinderService::CreateMessage(const spt bool DBinderService::SendEntryToRemote(const sptr stub, uint32_t seqNumber, uint32_t pid, uint32_t uid) { + std::cout<<"$$$$$LONG$$$$$DBinderService-SendEntryToRemote called"<GetDeviceID(); const std::string localDevID = GetLocalDeviceID(); if (CheckDeviceIDsInvalid(deviceID, localDevID)) { DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_ERR_INVALID_DATA, __FUNCTION__); + std::cout<<"$$$$$LONG$$$$$DBinderService-SendEntryToRemote device is invalid"< stub, uint (message->stub & BINDER_MASK), message->deviceIdInfo.tokenId); std::shared_ptr remoteListener = GetRemoteListener(); if (remoteListener == nullptr) { + std::cout<<"$$$$$LONG$$$$$DBinderService-SendEntryToRemote remoteListener is nullptr"<binderObject, message->seqNumber); DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_GET_REMOTE_LISTENER_FAIL, __FUNCTION__); return false; } bool result = remoteListener->SendDataToRemote(deviceID, message.get()); + std::cout<<"$$$$$LONG$$$$$DBinderService-SendEntryToRemote 511"<binderObject, message->seqNumber); DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_SEND_DATA_TO_REMOTE_FAIL, __FUNCTION__); return false; } + std::cout<<"$$$$$LONG$$$$$DBinderService-SendEntryToRemote 518"< stub, uint32_t seqNumber, uint32_t pid, uint32_t uid, std::shared_ptr &threadLockInfo) { + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinderWhenRequest called"<(std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); stub->SetNegoStatusAndTime(NegotiationStatus::NEGO_DOING, time); threadLockInfo = std::make_shared(); if (!AttachThreadLockInfo(seqNumber, stub->GetDeviceID(), threadLockInfo)) { + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinderWhenRequest called 524"<SetNegoStatusAndTime(NegotiationStatus::NEGO_INIT, 0); DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_ATTACH_THREADLOCK_FAIL, __FUNCTION__); return MAKE_THREADLOCK_FAILED; } + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinderWhenRequest called 529"<SetNegoStatusAndTime(NegotiationStatus::NEGO_INIT, 0); DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_SEND_ENTRY_TO_REMOTE_FAIL, __FUNCTION__); @@ -537,6 +557,7 @@ int32_t DBinderService::InvokerRemoteDBinderWhenRequest(const sptr stub, uint32_t seqNumber, uint32_t pid, uint32_t uid, std::shared_ptr &threadLockInfo) { + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinderWhenWaitRsp called"< stub, uint32_t seqNumber, uint32_t pid, uint32_t uid, bool isNew) { + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinder called"< stub std::shared_ptr threadLockInfo = nullptr; NegotiationStatus negoStatus; uint64_t negoTime; + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinder called 582"<GetNegoStatusAndTime(negoStatus, negoTime); if (isNew || negoStatus == NegotiationStatus::NEGO_INIT) { result = InvokerRemoteDBinderWhenRequest(stub, seqNumber, pid, uid, threadLockInfo); @@ -588,7 +613,7 @@ int32_t DBinderService::InvokerRemoteDBinder(const sptr stub return result; } } - + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinder called 596"< lock(threadLockInfo->mutex); if (threadLockInfo->condition.wait_for(lock, std::chrono::seconds(WAIT_FOR_REPLY_MAX_SEC), @@ -601,6 +626,7 @@ int32_t DBinderService::InvokerRemoteDBinder(const sptr stub threadLockInfo->ready = false; return WAIT_REPLY_TIMEOUT; } + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinder called 609"<(stub.GetRefPtr())); if (session == nullptr) { @@ -612,6 +638,7 @@ int32_t DBinderService::InvokerRemoteDBinder(const sptr stub auto time = static_cast(std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); stub->SetNegoStatusAndTime(NegotiationStatus::NEGO_FINISHED, time); + std::cout<<"$$$$$LONG$$$$$DBinderService-InvokerRemoteDBinder called 621"<= FIRST_SYS_ABILITY_ID && systemAbilityId <= LAST_SYS_ABILITY_ID; } +// LCOV_EXCL_START uint16_t DBinderService::AllocFreeSocketPort() { /* alloc port by system */ return 0; } +// LCOV_EXCL_STOP bool DBinderService::IsSameLoadSaItem(const std::string& srcNetworkId, int32_t systemAbilityId, std::shared_ptr loadSaItem) { + std::cout<<"$$$$$LONG$$$$$DBinderService-IsSameLoadSaItem called"<(loadSaItem->binderObject)<<"load item systemAbilityId is"<deviceIdInfo.fromDeviceId<(loadSaItem->binderObject) == systemAbilityId && loadSaItem->deviceIdInfo.fromDeviceId == srcNetworkId) { DBINDER_LOGI(LOG_LABEL, "match succeed"); @@ -659,22 +691,27 @@ std::shared_ptr DBinderService::PopLoadSaItem(const std::strin void DBinderService::LoadSystemAbilityComplete(const std::string& srcNetworkId, int32_t systemAbilityId, const sptr& remoteObject) { + std::cout<<"$$$$$LONG$$$$$DBinderService-LoadSystemAbilityComplete called"< replyMessage = PopLoadSaItem(srcNetworkId, systemAbilityId); if (replyMessage == nullptr) { + std::cout<<"$$$$$LONG$$$$$DBinderService-LoadSystemAbilityComplete 698"<binderObject; IPCObjectProxy *saProxy = reinterpret_cast(remoteObject.GetRefPtr()); if (QueryProxyObject(binderObject) == nullptr) { /* When the stub object dies, you need to delete the corresponding busName information */ sptr death(new DbinderSaDeathRecipient(binderObject)); if (!saProxy->AddDeathRecipient(death)) { + std::cout<<"$$$$$LONG$$$$$DBinderService-LoadSystemAbilityComplete 713"<deviceIdInfo.fromDeviceId; if (replyMessage->transType != IRemoteObject::DATABUS_TYPE) { + std::cout<<"$$$$$LONG$$$$$DBinderService-LoadSystemAbilityComplete 728"<deviceIdInfo.tokenId is random value uint32_t tokenId = (replyMessage->head.version < RPC_TOKENID_SUPPORT_VERSION) ? 0 : replyMessage->deviceIdInfo.tokenId; uint32_t result = OnRemoteInvokerDataBusMessage(saProxy, replyMessage, deviceId, replyMessage->pid, replyMessage->uid, tokenId); if (result != 0) { + std::cout<<"$$$$$LONG$$$$$DBinderService-LoadSystemAbilityComplete 740"< replyMessage) { + std::cout<<"$$$$$LONG$$$$$DBinderService-SendReplyMessageToRemote called"< remoteListener = GetRemoteListener(); if (remoteListener == nullptr) { DBINDER_LOGE(LOG_LABEL, "remoteListener is null"); @@ -718,6 +762,7 @@ void DBinderService::SendReplyMessageToRemote(uint32_t dBinderCode, uint32_t rea if (dBinderCode == MESSAGE_AS_REMOTE_ERROR) { replyMessage->transType = reason; // reuse transType send back error code } + std::cout<<"$$$$$LONG$$$$$DBinderService-SendReplyMessageToRemote called 756"<SendDataReply(replyMessage->deviceIdInfo.fromDeviceId, replyMessage.get())) { DBINDER_LOGE(LOG_LABEL, "fail to send data to client"); DfxReportFailEvent(DbinderErrorCode::RPC_DRIVER, RADAR_SEND_DATA_REPLAY_FAIL, __FUNCTION__); @@ -885,12 +930,15 @@ uint32_t DBinderService::OnRemoteInvokerDataBusMessage(IPCObjectProxy *proxy, std::shared_ptr replyMessage, std::string &remoteDeviceId, int pid, int uid, uint32_t tokenId) { + std::cout<<"$$$$$LONG$$$$$DBinderService-OnRemoteInvokerDataBusMessage called"<GetHandle()); DfxReportFailHandleEvent(DbinderErrorCode::RPC_DRIVER, proxy->GetHandle(), RADAR_WRITE_PARCEL_FAIL, __FUNCTION__); + std::cout<<"$$$$$LONG$$$$$DBinderService-OnRemoteInvokerDataBusMessage write parcel fail"<GetHandle(), RADAR_INVOKE_STUB_THREAD_FAIL, __FUNCTION__); + std::cout<<"$$$$$LONG$$$$$DBinderService-OnRemoteInvokerDataBusMessage invoke fail"<GetHandle(), RADAR_SESSION_NAME_INVALID, __FUNCTION__); + std::cout<<"$$$$$LONG$$$$$DBinderService-OnRemoteInvokerDataBusMessage sessionName invalid 971"<GetHandle(), RADAR_ERR_MEMCPY_DATA, __FUNCTION__); + std::cout<<"$$$$$LONG$$$$$DBinderService-OnRemoteInvokerDataBusMessage sessionName invalid 976"< DBinderService::QueryThreadLockInfo(uint32_t seqNumber) { + std::cout<<"$$$$$LONG$$$$$DBinderService-QueryThreadLockInfo called seqNumber is"< lock(threadLockMutex_); auto it = threadLockInfo_.find(seqNumber); if (it != threadLockInfo_.end()) { + std::cout<<"$$$$$LONG$$$$$DBinderService-QueryThreadLockInfo called seqNumber find"<second; } + std::cout<<"$$$$$LONG$$$$$DBinderService-QueryThreadLockInfo seqNumber not find"< object, binder_uintptr_t binderObject) { + std::cout<<"$$$$$LONG$$$$$DBinderService-AttachProxyObject called"< lock(proxyMutex_); auto result = proxyObject_.insert(std::pair>(binderObject, object)); return result.second; @@ -1306,6 +1363,7 @@ bool DBinderService::DetachCallbackProxy(sptr object) bool DBinderService::AttachCallbackProxy(sptr object, DBinderServiceStub *dbStub) { + std::cout<<"$$$$$LONG$$$$$DBinderService-AttachCallbackProxy called"< lockGuard(callbackProxyMutex_); auto result = noticeProxy_.insert(std::pair, DBinderServiceStub *>(object, dbStub)); @@ -1314,12 +1372,14 @@ bool DBinderService::AttachCallbackProxy(sptr object, DBinderServ bool DBinderService::NoticeCallbackProxy(const std::u16string &serviceName, const std::string &deviceID) { + std::cout<<"$$$$$LONG$$$$$DBinderService-NoticeCallbackProxy called"<(dbStubs[idx].GetRefPtr()); if (!DetachSessionObject(binderObject)) { DBINDER_LOGE(LOG_LABEL, "fail to detach session object"); + std::cout<<"$$$$$LONG$$$$$DBinderService-NoticeCallbackProxy fail to detach session object"< serviceNames = FindServicesByDeviceID(deviceID); if (serviceNames.empty()) { DBINDER_LOGE(LOG_LABEL, "the device does not have any registered service"); + std::cout<<"$$$$$LONG$$$$$DBinderService-NoticeDeviceDie the device does not have any registered service"< DBinderService::FindServicesByDeviceID(const std::strin return serviceNames; } +// LCOV_EXCL_START uint32_t DBinderService::GetRemoteTransType() { return IRemoteObject::DATABUS_TYPE; } +// LCOV_EXCL_STOP std::string DBinderService::ConvertToSecureDeviceID(const std::string &str) { diff --git a/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp b/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp index 45196ea3..17f02a54 100644 --- a/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp +++ b/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp @@ -14,6 +14,7 @@ */ #include "dbinder_remote_listener.h" +#include #include #include "securec.h" @@ -49,6 +50,7 @@ DBinderRemoteListener::~DBinderRemoteListener() void DBinderRemoteListener::ServerOnBind(int32_t socket, PeerSocketInfo info) { + std::cout<<"$$$$$LONG$$$$$DBinderRemoteListener-ServerOnBind called"< lockGuard(serverSocketMutex_); @@ -222,6 +224,7 @@ bool DBinderRemoteListener::StartListener() } // LCOV_EXCL_STOP +// LCOV_EXCL_START bool DBinderRemoteListener::StopListener() { ClearDeviceLock(); @@ -235,6 +238,7 @@ bool DBinderRemoteListener::StopListener() DBinderSoftbusClient::GetInstance().Shutdown(listenSocketId_); return true; } +// LCOV_EXCL_STOP std::shared_ptr DBinderRemoteListener::QueryOrNewDeviceLock(const std::string &networkId) { @@ -299,6 +303,7 @@ bool DBinderRemoteListener::SendDataToRemote(const std::string &networkId, const bool DBinderRemoteListener::SendDataReply(const std::string &networkId, const struct DHandleEntryTxRx *msg) { + std::cout<<"$$$$$LONG$$$$$DBinderRemoteListener-SendDataReply called"< #include #include "securec.h" #define private public @@ -1050,6 +1050,7 @@ HWTEST_F(DBinderServiceUnitTest, AllocFreeSocketPort001, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, IsSameLoadSaItem001, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-IsSameLoadSaItem001 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); std::string srcNetworkId = "aaaaaaaaaaaaaa"; @@ -1343,6 +1344,7 @@ HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest002, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest003, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-NoticeDeviceDieTest003 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); std::string deviceID("123456"); @@ -1388,6 +1390,7 @@ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest001, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest002, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-NoticeServiceDieInnerTest002 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); dBinderService->StartRemoteListener(); @@ -1403,6 +1406,7 @@ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest002, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, NoticeServiceDieInnerTest003, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-NoticeServiceDieInnerTest003 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); dBinderService->StartRemoteListener(); @@ -1442,6 +1446,7 @@ HWTEST_F(DBinderServiceUnitTest, ProcessCallbackProxyTest001, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, NoticeCallbackProxyTest001, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-NoticeCallbackProxyTest001 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); sptr object = new (std::nothrow) IPCObjectProxy(TEST_OBJECT_HANDLE); @@ -1924,6 +1929,7 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest002, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest003, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-PopLoadSaItemTest003 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); @@ -1967,6 +1973,7 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest003, TestSize.Level1) */ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest004, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-PopLoadSaItemTest004 called"< dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); @@ -2400,6 +2407,7 @@ HWTEST_F(DBinderServiceUnitTest, InvokerRemoteDBinderWhenRequest001, TestSize.Le */ HWTEST_F(DBinderServiceUnitTest, InvokerRemoteDBinderWhenWaitRsp001, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceUnitTest-InvokerRemoteDBinderWhenWaitRsp001 called"< dBinderService = DBinderService::GetInstance(); EXPECT_NE(dBinderService, nullptr); diff --git a/dbinder/test/unittest/mock_dbinder_remote_listener.h b/dbinder/test/unittest/mock_dbinder_remote_listener.h index 9a1aaf80..579ca6b7 100644 --- a/dbinder/test/unittest/mock_dbinder_remote_listener.h +++ b/dbinder/test/unittest/mock_dbinder_remote_listener.h @@ -15,7 +15,7 @@ #ifndef OHOS_MOCK_DBINDER_REMOTE_LISTENER_H #define OHOS_MOCK_DBINDER_REMOTE_LISTENER_H - +#include #include "gtest/gtest.h" #include "gmock/gmock.h" #include "dbinder_remote_listener.h" @@ -69,11 +69,13 @@ MockDBinderRemoteListener::~MockDBinderRemoteListener() void MockDBinderRemoteListener::SetResult(int32_t result) { + std::cout<<"$$$$$LONG$$$$$MockDBinderRemoteListener-GetResult called result is"<(data); diff --git a/ipc/native/src/core/dbinder/source/databus_socket_listener.cpp b/ipc/native/src/core/dbinder/source/databus_socket_listener.cpp index 620abfac..5e1fb27e 100644 --- a/ipc/native/src/core/dbinder/source/databus_socket_listener.cpp +++ b/ipc/native/src/core/dbinder/source/databus_socket_listener.cpp @@ -14,7 +14,7 @@ */ #include "databus_socket_listener.h" - +#include #include #include "dbinder_databus_invoker.h" #include "dsoftbus_interface.h" @@ -263,15 +263,19 @@ void DatabusSocketListener::EraseDeviceLock(DBinderSocketInfo info) } } +// LCOV_EXCL_START void DatabusSocketListener::RemoveSessionName(void) { + std::cout<<"DatabusSocketListener-RemoveSessionName Called"<RemoveSoftbusServer(); } +// LCOV_EXCL_STOP bool DatabusSocketListener::GetPidAndUidFromServiceName(const std::string &serviceName, int32_t &pid, int32_t &uid) { diff --git a/ipc/native/src/core/dbinder/source/dbinder_databus_invoker.cpp b/ipc/native/src/core/dbinder/source/dbinder_databus_invoker.cpp index e4b55c40..0963b023 100644 --- a/ipc/native/src/core/dbinder/source/dbinder_databus_invoker.cpp +++ b/ipc/native/src/core/dbinder/source/dbinder_databus_invoker.cpp @@ -14,7 +14,7 @@ */ #include "dbinder_databus_invoker.h" - +#include #include #include "string_ex.h" #include "securec.h" @@ -278,6 +278,10 @@ void DBinderDatabusInvoker::OnRawDataAvailable(int32_t socketId, uint64_t seqNum return; } + if (dataSize < sizeof(dbinder_transaction_data)) { + ZLOGE(LOG_LABEL, "dataSize:%{public}u is invalid", dataSize); + return; + } bool isSucc = false; uint32_t rawDataSize = dataSize - sizeof(dbinder_transaction_data); if (rawDataSize > 0 && rawDataSize <= MAX_RAWDATA_SIZE - sizeof(dbinder_transaction_data)) { @@ -885,13 +889,16 @@ uint64_t DBinderDatabusInvoker::MakeStubIndexByRemoteObject(IRemoteObject *stubO std::shared_ptr DBinderDatabusInvoker::MakeDefaultServerSessionObject(uint64_t stubIndex, const std::shared_ptr sessionObject) { + std::cout<<"DBinderDatabusInvoker-MakeDefaultServerSessionObject Called"<GetDatabusName(); std::string deviceId = current->GetLocalDeviceID(); + std::cout<<"DBinderDatabusInvoker serviceName is:"< DBinderDatabusInvoker::MakeDefaultServerSe auto session = std::make_shared(serviceName, deviceId, stubIndex, nullptr, sessionObject->GetTokenId()); if (session == nullptr) { + std::cout<<"DBinderDatabusInvoker-session is nullptr"< - +#include #include "check_instance_exit.h" #include "ipc_debug.h" #include "log_tags.h" @@ -43,6 +43,7 @@ DBinderSoftbusClient::~DBinderSoftbusClient() ZLOGI(LOG_LABEL, "destroy"); } +// LCOV_EXCL_START bool DBinderSoftbusClient::OpenSoftbusClientSo() { CHECK_INSTANCE_EXIT_WITH_RETVAL(exitFlag_, false); @@ -63,6 +64,7 @@ bool DBinderSoftbusClient::OpenSoftbusClientSo() return true; } +// LCOV_EXCL_STOP int32_t DBinderSoftbusClient::DBinderGrantPermission(int32_t uid, int32_t pid, const std::string &socketName) { @@ -199,6 +201,7 @@ int32_t DBinderSoftbusClient::Bind(int32_t socket, const QosTV qos[], uint32_t q int32_t DBinderSoftbusClient::SendBytes(int32_t socket, const void *data, uint32_t len) { + std::cout<<"$$$$$LONG$$$$$DBinderSoftbusClient-SendBytes called"< #include #include #include @@ -302,9 +302,11 @@ bool IPCProcessSkeleton::SetRegistryObject(sptr &object) bool IPCProcessSkeleton::SetMaxWorkThread(int maxThreadNum) { + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::SetMaxWorkThread called"<= INT_MIDMAX) { ZLOGE(LOG_LABEL, "Set Invalid thread Number:%{public}d", maxThreadNum); + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::SetMaxWorkThread maxThreadNum INVALID"<UpdateMaxThreadNum(maxThreadNum); IRemoteInvoker *invoker = IPCThreadSkeleton::GetRemoteInvoker(IRemoteObject::IF_PROT_DEFAULT); if (invoker != nullptr) { + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::invoker is not nullptr"<SetMaxWorkThread(maxThreadNum); } - + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::invoker is nullptr"< maxIPCThreadNum) { ZLOGE(LOG_LABEL, "numExecuting_++ is %{public}d", numExecuting_); } + if (threadPool_ ==nullptr) { + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::BlockUntilThreadAvailable threadPool_ is nullptr"<= threadPool_->GetMaxThreadNum()) { cv_.wait(lock); } @@ -433,7 +441,10 @@ void IPCProcessSkeleton::LockForNumExecuting() CHECK_INSTANCE_EXIT(exitFlag_); std::lock_guard lockGuard(mutex_); numExecuting_++; - + if (threadPool_ ==nullptr) { + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::UnlockForNumExecuting threadPool_ is nullptr"<GetMaxThreadNum()) { uint64_t curTime = static_cast(std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); @@ -447,7 +458,10 @@ void IPCProcessSkeleton::UnlockForNumExecuting() { CHECK_INSTANCE_EXIT(exitFlag_); std::lock_guard lockGuard(mutex_); - + if (threadPool_ ==nullptr) { + std::cout<<"$$$$$LONG$$$$$IPCProcessSkeleton::BlockUntilThreadAvailable threadPool_ is nullptr"<GetMaxThreadNum()) { uint64_t curTime = static_cast(std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()).count()); @@ -479,6 +493,7 @@ bool IPCProcessSkeleton::SetIPCProxyLimit(uint64_t num, std::function IPCProcessSkeleton::GetSAMgrObject() { + std::cout<<"IPCProcessSkeleton-GetSAMgrObject Called"< IPCProcessSkeleton::QueryThreadBySeqNumber(uint64_t seqNumber) { @@ -1303,6 +1322,7 @@ bool IPCProcessSkeleton::CreateSoftbusServer(const std::string &name) bool IPCProcessSkeleton::RemoveSoftbusServer() { + std::cout<<"IPCProcessSkeleton-RemoveSoftbusServer Called"< object = GetSAMgrObject(); if (object == nullptr) { ZLOGE(LOG_LABEL, "get object is null"); diff --git a/ipc/native/src/core/invoker/source/binder_invoker.cpp b/ipc/native/src/core/invoker/source/binder_invoker.cpp index e50d0755..d2d3b00d 100644 --- a/ipc/native/src/core/invoker/source/binder_invoker.cpp +++ b/ipc/native/src/core/invoker/source/binder_invoker.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "access_token_adapter.h" #include "backtrace_local.h" @@ -294,7 +295,7 @@ bool BinderInvoker::RemoveDeathRecipient(int32_t handle, void *cookie) // LCOV_EXCL_START sptr BinderInvoker::GetSAMgrObject() { - ZLOGI(LABEL, "get samgr object!"); + ZLOGD(LABEL, "get samgr object!"); IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent(); if (current != nullptr) { return current->GetRegistryObject(); @@ -449,14 +450,17 @@ bool BinderInvoker::UnFlattenDBinderObject(Parcel &parcel, dbinder_negotiation_d bool BinderInvoker::SetMaxWorkThread(int maxThreadNum) { + std::cout<<"$$$$$LONG$$$$$BinderInvoker::SetMaxWorkThread called"<IsDriverAlive())) { ZLOGE(LABEL, "died"); + std::cout<<"$$$$$LONG$$$$$BinderInvoker::driver died"<WriteBinder(BINDER_SET_MAX_THREADS, &maxThreadNum); if (error != ERR_NONE) { ZLOGE(LABEL, "SetMaxWorkThread error:%{public}d", error); + std::cout<<"$$$$$LONG$$$$$BinderInvoker::SetMaxWorkThread error"<SpawnThread(); } +// LCOV_EXCL_STOP void BinderInvoker::OnTransaction(uint32_t cmd, int32_t &error) { @@ -1038,7 +1044,7 @@ void BinderInvoker::JoinThread(bool initiative) output_.WriteUint32(BC_EXIT_LOOPER); // pass in nullptr directly FlushCommands(nullptr); - ZLOGE(LABEL, "Current Thread:%{public}d is leaving", getpid()); + ZLOGD(LABEL, "Current Thread:%{public}d is leaving", getpid()); } void BinderInvoker::JoinProcessThread(bool initiative) {} @@ -1245,7 +1251,7 @@ void BinderInvoker::DealWithCmd(MessageParcel *reply, bool &continueLoop, int32_ int BinderInvoker::WaitForCompletion(MessageParcel *reply) { if ((binderConnector_ == nullptr) || (!binderConnector_->IsDriverAlive())) { - ZLOGE(LABEL, "died"); + ZLOGD(LABEL, "died"); return IPC_INVOKER_CONNECT_ERR; } uint32_t cmd; @@ -1406,6 +1412,7 @@ uint64_t BinderInvoker::GetSelfTokenID() const } // LCOV_EXCL_STOP +// LCOV_EXCL_START uint64_t BinderInvoker::GetSelfFirstCallerTokenID() const { if ((binderConnector_ == nullptr) || (!binderConnector_->IsDriverAlive())) { @@ -1414,6 +1421,7 @@ uint64_t BinderInvoker::GetSelfFirstCallerTokenID() const uint64_t selfFirstCallerTokenId = binderConnector_->GetSelfFirstCallerTokenID(); return (selfFirstCallerTokenId == 0) ? static_cast(getuid()) : selfFirstCallerTokenId; } +// LCOV_EXCL_STOP uint32_t BinderInvoker::GetStatus() { @@ -1728,6 +1736,7 @@ bool BinderInvoker::IsSendRequesting() } // LCOV_EXCL_STOP +// LCOV_EXCL_START void BinderInvoker::ProcDeferredDecRefs() { if (input_.GetReadableBytes() > 0) { @@ -1762,6 +1771,7 @@ void BinderInvoker::ProcDeferredDecRefs() decStrongRefs_.clear(); } } +// LCOV_EXCL_STOP bool BinderInvoker::GetUint64ValueByStrSlice(const std::string &str, size_t offset, size_t length, uint64_t &value) { diff --git a/ipc/native/test/unittest/common/databus_socket_listener_unittest.cpp b/ipc/native/test/unittest/common/databus_socket_listener_unittest.cpp index 822d1bb9..10614e43 100644 --- a/ipc/native/test/unittest/common/databus_socket_listener_unittest.cpp +++ b/ipc/native/test/unittest/common/databus_socket_listener_unittest.cpp @@ -15,6 +15,7 @@ #include #include +#include #define private public #include "databus_socket_listener.h" @@ -72,16 +73,19 @@ static void *g_interface = nullptr; DatabusSocketListenerInterfaceMock::DatabusSocketListenerInterfaceMock() { + std::cout<<"DatabusSocketListenerInterfaceMock-DatabusSocketListenerInterfaceMock Called"<(this); } DatabusSocketListenerInterfaceMock::~DatabusSocketListenerInterfaceMock() { + std::cout<<"DatabusSocketListenerInterfaceMock-~DatabusSocketListenerInterfaceMock Called"<(g_interface); } @@ -132,6 +136,11 @@ extern "C" { } sptr IPCProcessSkeleton::GetSAMgrObject() { + std::cout<<"IPCProcessSkeleton-GetSAMgrObject Called"<GetSAMgrObject(); } std::string IPCProcessSkeleton::GetDatabusName() @@ -504,6 +513,7 @@ HWTEST_F(DatabusSocketListenerTest, RemoveSessionNameTest001, TestSize.Level1) */ HWTEST_F(DatabusSocketListenerTest, RemoveSessionNameTest002, TestSize.Level1) // line 273 { + std::cout<<"DatabusSocketListenerTest-RemoveSessionNameTest002 Called"< mock; diff --git a/ipc/native/test/unittest/common/ipc_binder_databus_invoker_unittest.cpp b/ipc/native/test/unittest/common/ipc_binder_databus_invoker_unittest.cpp index fcdd44f9..34379909 100644 --- a/ipc/native/test/unittest/common/ipc_binder_databus_invoker_unittest.cpp +++ b/ipc/native/test/unittest/common/ipc_binder_databus_invoker_unittest.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include #include #include #include "mock_iremote_object.h" @@ -646,16 +646,19 @@ HWTEST_F(IPCDbinderDataBusInvokerTest, CreateServerSessionObjectTest002, TestSiz */ HWTEST_F(IPCDbinderDataBusInvokerTest, MakeDefaultServerSessionObjectTest001, TestSize.Level1) { + std::cout<<"IPCDbinderDataBusInvokerTest-MakeDefaultServerSessionObjectTest001 Called"<(serviceName, serverDeviceId, 1, nullptr, 1); + std::cout<<"IPCDbinderDataBusInvokerTest-MakeDefaultServerSessionObjectTest001 Called 654"< ret = testInvoker.MakeDefaultServerSessionObject(1, object); EXPECT_EQ(ret, nullptr); IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent(); current->sessionName_ = SERVICE_NAME_TEST; ret = testInvoker.MakeDefaultServerSessionObject(1, object); + std::cout<<"IPCDbinderDataBusInvokerTest-MakeDefaultServerSessionObjectTest001 Called 661"< #include - +#include #define private public #include "dbinder_session_object.h" #include "ipc_process_skeleton.h" @@ -1987,17 +1987,19 @@ HWTEST_F(IPCProcessSkeletonUnitTest, AttachDBinderCallbackStubTest, TestSize.Lev */ HWTEST_F(IPCProcessSkeletonUnitTest, LockForNumExecutingTest001, TestSize.Level1) { + std::cout<<"IPCProcessSkeletonUnitTest-LockForNumExecutingTest001 Called"<threadPool_; skeleton->threadPool_ = nullptr; skeleton->SetMaxWorkThread(1); ASSERT_TRUE(skeleton->threadPool_ != nullptr); - + std::cout<<"IPCProcessSkeletonUnitTest-LockForNumExecutingTest001 Called 1997"<LockForNumExecuting(); skeleton->LockForNumExecuting(); EXPECT_NE(skeleton->numExecutingFullLastTime_, 0); + std::cout<<"IPCProcessSkeletonUnitTest-LockForNumExecutingTest001 Called 2002"<numExecuting_, skeleton->threadPool_->GetMaxThreadNum()); sleep(1); skeleton->UnlockForNumExecuting(); @@ -2005,7 +2007,9 @@ HWTEST_F(IPCProcessSkeletonUnitTest, LockForNumExecutingTest001, TestSize.Level1 EXPECT_EQ(skeleton->numExecutingFullLastTime_, 0); delete skeleton->threadPool_; skeleton->threadPool_ = nullptr; + std::cout<<"IPCProcessSkeletonUnitTest-LockForNumExecutingTest001 Called 2010"<SetMaxWorkThread(IPCProcessSkeleton::DEFAULT_WORK_THREAD_NUM); + std::cout<<"IPCProcessSkeletonUnitTest-LockForNumExecutingTest001 Called 2012"< #include #include - +#include #include "dbinder_service.h" #include "dbinder_remote_listener.h" #include "mock_iremote_invoker.h" @@ -431,6 +431,7 @@ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderTest002, TestSize.Level1) */ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderTest003, TestSize.Level1) { + std::cout<<"$$$$$LONG$$$$$DBinderServiceTest-InvokerRemoteDBinderTest003 called"< dBinderServiceStub = new DBinderServiceStub( RANDOM_SERVICENAME, RANDOM_DEVICEID, BINDER_OBJECT); @@ -443,7 +444,7 @@ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderTest003, TestSize.Level1) ASSERT_NE(entry, nullptr); EXPECT_CALL(mock, CreateMessage(_, _, _, _)).WillOnce(testing::Return(entry)); EXPECT_CALL(mock, GetLocalNodeDeviceId).WillOnce(testing::Return(SOFTBUS_CLIENT_SUCCESS)); - + std::cout<<"$$$$$LONG$$$$$DBinderServiceTest-InvokerRemoteDBinderTest003 called 447"< dBinderService = DBinderService::GetInstance(); EXPECT_NE(dBinderService, nullptr); -- Gitee From edd47d579709dcf70a3556a9146a74439d6bf299 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Fri, 22 Aug 2025 16:43:23 +0800 Subject: [PATCH 6/9] test UT Signed-off-by: hanlin15 --- dbinder/dbinder_service/src/dbinder_service.cpp | 16 +++++++++++++--- .../test/unittest/dbinder_service_unittest.cpp | 8 ++++---- .../src/dbinder_service_unittest.cpp | 9 ++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dbinder/dbinder_service/src/dbinder_service.cpp b/dbinder/dbinder_service/src/dbinder_service.cpp index 3b19b841..bc736beb 100644 --- a/dbinder/dbinder_service/src/dbinder_service.cpp +++ b/dbinder/dbinder_service/src/dbinder_service.cpp @@ -268,11 +268,14 @@ bool DBinderService::IsSameStubObject(const sptr &stub, cons std::vector> DBinderService::FindDBinderStub(const std::u16string &service, const std::string &device) { - std::cout<<"$$$$$LONG$$$$$DBinderService-FindDBinderStub called"<> result; std::lock_guard lockGuard(handleEntryMutex_); + for (auto it = DBinderStubRegisted_.begin(); it != DBinderStubRegisted_.end(); ++it) { if (((*it)->GetServiceName() == service) && ((*it)->GetDeviceID() == device)) { + std::cout<<"$$$$$LONG$$$$$DBinderService-FindDBinderStub-GetServiceName() is"<<(*it)->GetServiceName()<<"GetDeviceID is:"<<(*it)->GetDeviceID()< DBinderService::PopLoadSaItem(const std::string& srcNetworkId, int32_t systemAbilityId) { + std::cout<<"$$$$$LONG$$$$$DBinderService-PopLoadSaItem called"< loadSaItem) { return IsSameLoadSaItem(srcNetworkId, systemAbilityId, loadSaItem); }; std::lock_guard lockGuard(loadSaMutex_); + std::cout<<"$$$$$LONG$$$$$DBinderService-PopLoadSaItem loadSaReply_ size is:"< replymsg = (*it); it = loadSaReply_.erase(it); + std::cout<<"$$$$$LONG$$$$$DBinderService-PopLoadSaItem called" 693< object) { + std::cout<<"$$$$$LONG$$$$$DBinderService-AttachThreadLockInfo called"< lock(threadLockMutex_); object->networkId = networkId; auto result = threadLockInfo_.insert(std::pair>(seqNumber, object)); + std::cout<<"$$$$$LONG$$$$$DBinderService-AttachThreadLockInfo called reslut.first is:"< loadSaItem = std::make_shared(); EXPECT_TRUE(loadSaItem != nullptr); - loadSaItem->stubIndex = TEST_SYSTEM_ABILITY_ID; + loadSaItem->binderObject = TEST_SYSTEM_ABILITY_ID; strcpy_s(loadSaItem->deviceIdInfo.fromDeviceId, DEVICEID_LENGTH, "aaaaaaaaaaaaaa"); bool res = dBinderService->IsSameLoadSaItem(srcNetworkId, systemAbilityId, loadSaItem); EXPECT_EQ(res, true); @@ -1348,8 +1348,8 @@ HWTEST_F(DBinderServiceUnitTest, NoticeDeviceDieTest003, TestSize.Level1) sptr dBinderService = DBinderService::GetInstance(); EXPECT_TRUE(dBinderService != nullptr); std::string deviceID("123456"); - dBinderService->remoteListener_ = std::make_shared(); - EXPECT_TRUE(dBinderService->remoteListener_ != nullptr); + //dBinderService->remoteListener_ = std::make_shared(); + //EXPECT_TRUE(dBinderService->remoteListener_ != nullptr); EXPECT_EQ(dBinderService->NoticeDeviceDie(deviceID), DBINDER_SERVICE_NOTICE_DIE_ERR); } @@ -2417,7 +2417,7 @@ HWTEST_F(DBinderServiceUnitTest, InvokerRemoteDBinderWhenWaitRsp001, TestSize.Le uint32_t pid = TEST_PID; uint32_t uid = TEST_UID; uint32_t seqNumber = 0; - std::shared_ptr threadLockInfo; + std::shared_ptr threadLockInfo = std::make_shared(); sptr stub = new (std::nothrow) DBinderServiceStub(serviceName, deviceID, binderObject, pid, uid); diff --git a/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp b/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp index eedc5c10..72f0f45b 100644 --- a/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp +++ b/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp @@ -436,9 +436,9 @@ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderTest003, TestSize.Level1) sptr dBinderServiceStub = new DBinderServiceStub( RANDOM_SERVICENAME, RANDOM_DEVICEID, BINDER_OBJECT); NiceMock mock; - std::shared_ptr threadLockInfo = std::make_shared(); - dBinderService.remoteListener_ = std::make_shared(); - dBinderService.AttachThreadLockInfo(PID, RANDOM_DEVICEID, threadLockInfo); + //std::shared_ptr threadLockInfo = std::make_shared(); + //dBinderService.remoteListener_ = std::make_shared(); + //dBinderService.AttachThreadLockInfo(PID, RANDOM_DEVICEID, threadLockInfo); EXPECT_CALL(mock, SendDataToRemote).WillOnce(testing::Return(true)); std::shared_ptr entry = std::make_shared(); ASSERT_NE(entry, nullptr); @@ -687,8 +687,7 @@ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderWhenWaitRsp001, TestSize.Level1 uint32_t pid = PID; uint32_t uid = UID; uint32_t seqNumber = 0; - std::shared_ptr threadLockInfo; - + std::shared_ptr threadLockInfo = std::make_shared(); sptr stub = new (std::nothrow) DBinderServiceStub(serviceName, deviceID, binderObject, pid, uid); EXPECT_NE(stub, nullptr); -- Gitee From 1fad444d4ce2136aed0791ab40fec064af249ce2 Mon Sep 17 00:00:00 2001 From: hanlin15 Date: Fri, 22 Aug 2025 17:42:00 +0800 Subject: [PATCH 7/9] test UT Signed-off-by: hanlin15 --- dbinder/dbinder_service/src/dbinder_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbinder/dbinder_service/src/dbinder_service.cpp b/dbinder/dbinder_service/src/dbinder_service.cpp index bc736beb..d6af69cc 100644 --- a/dbinder/dbinder_service/src/dbinder_service.cpp +++ b/dbinder/dbinder_service/src/dbinder_service.cpp @@ -274,8 +274,8 @@ std::vector> DBinderService::FindDBinderStub(const std: for (auto it = DBinderStubRegisted_.begin(); it != DBinderStubRegisted_.end(); ++it) { if (((*it)->GetServiceName() == service) && ((*it)->GetDeviceID() == device)) { - std::cout<<"$$$$$LONG$$$$$DBinderService-FindDBinderStub-GetServiceName() is"<<(*it)->GetServiceName()<<"GetDeviceID is:"<<(*it)->GetDeviceID()<GetServiceName().c_str()<<"GetDeviceID is:"<<(*it)->GetDeviceID().c_str()< Date: Fri, 22 Aug 2025 18:27:41 +0800 Subject: [PATCH 8/9] test UT Signed-off-by: hanlin15 --- dbinder/dbinder_service/src/dbinder_service.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbinder/dbinder_service/src/dbinder_service.cpp b/dbinder/dbinder_service/src/dbinder_service.cpp index d6af69cc..fc452652 100644 --- a/dbinder/dbinder_service/src/dbinder_service.cpp +++ b/dbinder/dbinder_service/src/dbinder_service.cpp @@ -692,7 +692,7 @@ std::shared_ptr DBinderService::PopLoadSaItem(const std::strin } std::shared_ptr replymsg = (*it); it = loadSaReply_.erase(it); - std::cout<<"$$$$$LONG$$$$$DBinderService-PopLoadSaItem called" 693< object) { - std::cout<<"$$$$$LONG$$$$$DBinderService-AttachThreadLockInfo called"< lock(threadLockMutex_); object->networkId = networkId; auto result = threadLockInfo_.insert(std::pair>(seqNumber, object)); - std::cout<<"$$$$$LONG$$$$$DBinderService-AttachThreadLockInfo called reslut.first is:"<first<<"reslut.second is:"< Date: Mon, 25 Aug 2025 18:22:32 +0800 Subject: [PATCH 9/9] fix ut Signed-off-by: hanlin15 --- .../src/dbinder_service_unittest.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp b/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp index 72f0f45b..b00df2c2 100644 --- a/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp +++ b/test/unittest/dbinder/dbinder_service/src/dbinder_service_unittest.cpp @@ -436,14 +436,14 @@ HWTEST_F(DBinderServiceTest, InvokerRemoteDBinderTest003, TestSize.Level1) sptr dBinderServiceStub = new DBinderServiceStub( RANDOM_SERVICENAME, RANDOM_DEVICEID, BINDER_OBJECT); NiceMock mock; - //std::shared_ptr threadLockInfo = std::make_shared(); - //dBinderService.remoteListener_ = std::make_shared(); - //dBinderService.AttachThreadLockInfo(PID, RANDOM_DEVICEID, threadLockInfo); - EXPECT_CALL(mock, SendDataToRemote).WillOnce(testing::Return(true)); - std::shared_ptr entry = std::make_shared(); - ASSERT_NE(entry, nullptr); - EXPECT_CALL(mock, CreateMessage(_, _, _, _)).WillOnce(testing::Return(entry)); - EXPECT_CALL(mock, GetLocalNodeDeviceId).WillOnce(testing::Return(SOFTBUS_CLIENT_SUCCESS)); + std::shared_ptr threadLockInfo = std::make_shared(); + dBinderService.remoteListener_ = std::make_shared(); + dBinderService.AttachThreadLockInfo(PID, RANDOM_DEVICEID, threadLockInfo); + //EXPECT_CALL(mock, SendDataToRemote).WillOnce(testing::Return(true)); + //std::shared_ptr entry = std::make_shared(); + //ASSERT_NE(entry, nullptr); + //EXPECT_CALL(mock, CreateMessage(_, _, _, _)).WillOnce(testing::Return(entry)); + //EXPECT_CALL(mock, GetLocalNodeDeviceId).WillOnce(testing::Return(SOFTBUS_CLIENT_SUCCESS)); std::cout<<"$$$$$LONG$$$$$DBinderServiceTest-InvokerRemoteDBinderTest003 called 447"< threadLockInfo = std::make_shared(); + std::shared_ptr threadLockInfo; sptr stub = new (std::nothrow) DBinderServiceStub(serviceName, deviceID, binderObject, pid, uid); EXPECT_NE(stub, nullptr); int32_t ret = dBinderService->InvokerRemoteDBinderWhenWaitRsp(stub, seqNumber, pid, uid, threadLockInfo); EXPECT_EQ(ret, MAKE_THREADLOCK_FAILED); - + threadLockInfo = std::make_shared(); dBinderService->threadLockInfo_[seqNumber] = threadLockInfo; ret = dBinderService->InvokerRemoteDBinderWhenWaitRsp(stub, seqNumber, pid, uid, threadLockInfo); EXPECT_EQ(ret, DBINDER_OK); -- Gitee