From 542162608fb1d0a14791c9e49f5231394f09a7bc Mon Sep 17 00:00:00 2001 From: liubb_0516 Date: Fri, 6 May 2022 13:56:09 +0800 Subject: [PATCH] =?UTF-8?q?ipc=E6=8E=A5=E5=8F=A3=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liubb_0516 --- aafwk_lite/ability_posix/BUILD.gn | 2 +- .../ability_posix/src/AbilityMgrTest.cpp | 20 ++++++++++--------- .../ability_posix/src/AbilityMgrTest2.cpp | 6 +++--- appexecfwk_lite/appexecfwk_posix/BUILD.gn | 2 +- .../distributed_schedule_posix/BUILD.gn | 2 +- .../system_ability_manager_posix/BUILD.gn | 4 ++-- .../src/LiteIPCClientTest.cpp | 13 ++++++------ .../src/LiteIPCFeatureTest.cpp | 2 +- .../src/LiteIPCServiceTest.cpp | 4 ++-- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/aafwk_lite/ability_posix/BUILD.gn b/aafwk_lite/ability_posix/BUILD.gn index 9f0d1c4e7..b9e235825 100755 --- a/aafwk_lite/ability_posix/BUILD.gn +++ b/aafwk_lite/ability_posix/BUILD.gn @@ -26,7 +26,7 @@ hcpptest_suite("ActsAbilityMgrTest") { "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite", "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//utils/native/lite/kv_store:kv_store", ] diff --git a/aafwk_lite/ability_posix/src/AbilityMgrTest.cpp b/aafwk_lite/ability_posix/src/AbilityMgrTest.cpp index 5b0865a98..869afea6c 100755 --- a/aafwk_lite/ability_posix/src/AbilityMgrTest.cpp +++ b/aafwk_lite/ability_posix/src/AbilityMgrTest.cpp @@ -85,22 +85,24 @@ static void OnAbilityConnectDone(ElementName *elementName, SvcIdentity *serviceS printf("ipc callback success \n"); // push data IpcIo request; - char data[IPC_IO_DATA_MAX]; - IpcIoInit(&request, data, IPC_IO_DATA_MAX, 0); + char data[MAX_IO_SIZE]; + IpcIoInit(&request, data, MAX_IO_SIZE, 0); int32_t data1 = 10; int32_t data2 = 6; - IpcIoPushInt32(&request, data1); - IpcIoPushInt32(&request, data2); + WriteInt32(&request, data1); + WriteInt32(&request, data2); // send and getReply IpcIo reply = {nullptr}; uintptr_t ptr = 0; - Transact(NULL, *serviceSid, 0, &request, &reply, LITEIPC_FLAG_DEFAULT, &ptr); - g_errorCode = IpcIoPopInt32(&reply); + MessageOption option; + MessageOptionInit(&option); + SendRequest(*serviceSid, 0, &request, &reply, option, &ptr); + ReadInt32(&reply, &g_errorCode); if (g_errorCode != 0) { printf("execute add method, result is %d\n", g_errorCode); } if (ptr != 0) { - FreeBuffer(nullptr, reinterpret_cast(ptr)); + FreeBuffer(reinterpret_cast(ptr)); } sem_post(&g_sem); } @@ -709,10 +711,10 @@ HWTEST_F(AbilityMgrTest, testDisConnectAbilityIllegal, Function | MediumTest | L ts.tv_sec += WAIT_TIMEOUT; sem_timedwait(&g_sem, &ts); printf("sem exit \n"); - printf("ret is of connect is %d \n ", g_errorCode); + printf("ret of connect is %d \n ", result); EXPECT_EQ(result, 0); g_errorCode = DisconnectAbility(nullptr); - int expect = -10; + int expect = -2; EXPECT_EQ(g_errorCode, expect); printf("ret of disconnect is %d \n ", g_errorCode); ClearElement(&element); diff --git a/aafwk_lite/ability_posix/src/AbilityMgrTest2.cpp b/aafwk_lite/ability_posix/src/AbilityMgrTest2.cpp index 76235c4ba..81d1fc8ae 100755 --- a/aafwk_lite/ability_posix/src/AbilityMgrTest2.cpp +++ b/aafwk_lite/ability_posix/src/AbilityMgrTest2.cpp @@ -89,13 +89,13 @@ static void OnAbilityConnectDone(ElementName *elementName, SvcIdentity *serviceS IpcIoInit(&request, data, IPC_IO_DATA_MAX, 0); int32_t data1 = 10; int32_t data2 = 6; - IpcIoPushInt32(&request, data1); - IpcIoPushInt32(&request, data2); + WreitInt32(&request, data1); + WriteInt32(&request, data2); // send and getReply IpcIo reply = {nullptr}; uintptr_t ptr = 0; Transact(NULL, *serviceSid, 0, &request, &reply, LITEIPC_FLAG_DEFAULT, &ptr); - g_errorCode = IpcIoPopInt32(&reply); + ReadInt32(&reply, &g_errorCode); if (g_errorCode != 0) { printf("execute add method, result is %d\n", g_errorCode); } diff --git a/appexecfwk_lite/appexecfwk_posix/BUILD.gn b/appexecfwk_lite/appexecfwk_posix/BUILD.gn index 5066813bc..afaa8b266 100755 --- a/appexecfwk_lite/appexecfwk_posix/BUILD.gn +++ b/appexecfwk_lite/appexecfwk_posix/BUILD.gn @@ -36,7 +36,7 @@ hcpptest_suite("ActsBundleMgrTest") { deps = [ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", "//foundation/distributedschedule/samgr_lite/samgr:samgr", ] diff --git a/distributed_schedule_lite/distributed_schedule_posix/BUILD.gn b/distributed_schedule_lite/distributed_schedule_posix/BUILD.gn index b274cca84..f02fef17a 100755 --- a/distributed_schedule_lite/distributed_schedule_posix/BUILD.gn +++ b/distributed_schedule_lite/distributed_schedule_posix/BUILD.gn @@ -27,7 +27,7 @@ hcpptest_suite("ActsDMSTest") { "src/utils", "//utils/native/lite/include", "//third_party/bounds_checking_function/include", - "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//foundation/distributedschedule/dmsfwk_lite/include", diff --git a/distributed_schedule_lite/system_ability_manager_posix/BUILD.gn b/distributed_schedule_lite/system_ability_manager_posix/BUILD.gn index 8ffae2b21..348adc565 100755 --- a/distributed_schedule_lite/system_ability_manager_posix/BUILD.gn +++ b/distributed_schedule_lite/system_ability_manager_posix/BUILD.gn @@ -48,7 +48,7 @@ hcpptest_suite("ActsSamgrTest") { "src/FeatureTest.cpp", "src/IUnknownTest.cpp", - # "src/LiteIPCClientTest.cpp", + "src/LiteIPCClientTest.cpp", "src/LiteIPCFeatureTest.cpp", "src/LiteIPCServiceTest.cpp", "src/SendRequestTest.cpp", @@ -76,7 +76,7 @@ hcpptest_suite("ActsSamgrTest") { ] deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", "//foundation/distributedschedule/samgr_lite/communication/broadcast:broadcast", "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//third_party/bounds_checking_function:libsec_shared", diff --git a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCClientTest.cpp b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCClientTest.cpp index 59cc07b16..e657aa114 100755 --- a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCClientTest.cpp +++ b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCClientTest.cpp @@ -22,7 +22,6 @@ using namespace testing::ext; -static const int MAX_IO_SIZE = 8192; static const int NORMAL_IO_SIZE = 250; static IClientProxy *GetRemoteIUnknown(const char *serviceName, const char *featureName) @@ -48,7 +47,7 @@ static int CurrentCallback(IOwner owner, int code, IpcIo *reply) { printf("[hcpptest]CurrentCallback run \n"); size_t len = 0; - char *response = (char *)IpcIoPopString(reply, &len); + char *response = (char *)ReadString(reply, &len); printf("[hcpptest]response %s \n", response); return 0; } @@ -130,7 +129,7 @@ HWTEST_F(LiteIPCClientTest, testIPCClient0040, Function | MediumTest | Level1) char data[NORMAL_IO_SIZE]; IpcIoInit(&request, data, sizeof(data), 0); char *buff = (char*)"test xxxx"; - IpcIoPushString(&request, buff); + WriteString(&request, buff); char data2[NORMAL_IO_SIZE]; int funcId = 0; @@ -154,7 +153,7 @@ HWTEST_F(LiteIPCClientTest, testIPCClient0050, Function | MediumTest | Level2) int funcId = 0; int result = remoteApi->Invoke(remoteApi, funcId, nullptr, data2, CurrentCallback); printf("[hcpptest]result is: %d \n", result); - ASSERT_EQ(result, EC_SUCCESS); + ASSERT_EQ(result, EC_INVALID); ReleaseIUnknown((IUnknown *)remoteApi); }; @@ -173,7 +172,7 @@ HWTEST_F(LiteIPCClientTest, testIPCClient0060, Function | MediumTest | Level2) char data[NORMAL_IO_SIZE]; IpcIoInit(&request, data, sizeof(data), 0); char *buff = (char*)"test xxxx"; - IpcIoPushString(&request, buff); + WriteString(&request, buff); int funcId = 0; int result = remoteApi->Invoke(remoteApi, funcId, &request, nullptr, nullptr); @@ -197,13 +196,13 @@ HWTEST_F(LiteIPCClientTest, testIPCClient0070, Function | MediumTest | Level2) char data[MAX_IO_SIZE + 1]; IpcIoInit(&request, data, sizeof(data), 0); char *buff = (char*)"test xxxx"; - IpcIoPushString(&request, buff); + WriteString(&request, buff); char data2[NORMAL_IO_SIZE]; int funcId = 0; int result = remoteApi->Invoke(remoteApi, funcId, &request, data2, CurrentCallback); printf("[hcpptest]result is: %d \n", result); - ASSERT_EQ(result, EC_FAILURE); + ASSERT_EQ(result, EC_INVALID); ReleaseIUnknown((IUnknown *)remoteApi); }; diff --git a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCFeatureTest.cpp b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCFeatureTest.cpp index 428d8a6a8..86bc2a071 100755 --- a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCFeatureTest.cpp +++ b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCFeatureTest.cpp @@ -130,7 +130,7 @@ static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, { printf("[hcpptest][TID:0x%lx]Feature Remote Invoke is called! <%p, %d, %p, %p, %p>", pthread_self(), iProxy, funcId, origin, req, reply); - IpcIoPushBool(reply, TRUE); + WriteBool(reply, TRUE); return EC_SUCCESS; } diff --git a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCServiceTest.cpp b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCServiceTest.cpp index 62e52cd28..34f3fcac9 100755 --- a/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCServiceTest.cpp +++ b/distributed_schedule_lite/system_ability_manager_posix/src/LiteIPCServiceTest.cpp @@ -79,7 +79,7 @@ static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, pthread_self(), iProxy, funcId, origin, req, reply); size_t len = 0; - char *requestStr = (char *)IpcIoPopString(req, &len); + char *requestStr = (char *)ReadString(req, &len); if (requestStr != nullptr) { printf("[hcpptest]requestStr is %s", requestStr); } else { @@ -91,7 +91,7 @@ static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, defaultApi->SyncCall((IUnknown *)iProxy); } - IpcIoPushString(reply, "Yes, you did!"); + WriteString(reply, "Yes, you did!"); return EC_SUCCESS; } static DemoService g_service = { -- GitLab