提交 c014b4e1 编写于 作者: L liubb_0516

add ipc test case

Signed-off-by: Nliubb_0516 <liubeibei8@huawei.com>
上级 f40c9a9c
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Copyright (c) 2021 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
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//build/lite/config/component/lite_component.gni")
......
......@@ -15,11 +15,12 @@
#include <stdlib.h>
#include "rpc_log.h"
#include "rpc_errno.h"
#include "ipc_proxy.h"
#include "ipc_skeleton.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "serializer.h"
#include "ipc_proxy.h"
static SvcIdentity g_serverSid;
......@@ -55,17 +56,17 @@ int32_t RemoteRequest(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption op
return result;
}
void ServerDead1()
void ServerDead1(void)
{
RPC_LOG_INFO("#### server dead callback11 called ... ");
}
void ServerDead2()
void ServerDead2(void)
{
RPC_LOG_INFO("#### server dead callback22 called ... ");
}
void ServerDead3()
void ServerDead3(void)
{
RPC_LOG_INFO("#### server dead callback33 called ... ");
}
......@@ -76,7 +77,7 @@ static SvcIdentity g_samgr = {
MessageOption g_option = TF_OP_SYNC;
static void GetServerOne()
static void GetServerOne(void)
{
IpcIo data1;
uint8_t tmpData1[IPC_MAX_SIZE];
......@@ -90,7 +91,7 @@ static void GetServerOne()
EXPECT_EQ(ret, ERR_NONE);
}
static void CallServerAdd()
static void CallServerAdd(void)
{
IpcIo data2;
uint8_t tmpData2[IPC_MAX_SIZE];
......@@ -110,7 +111,7 @@ static void CallServerAdd()
EXPECT_EQ(res, tmpSum);
}
static void AnonymousTest()
static void AnonymousTest(void)
{
IpcObjectStub objectStub = {
.func = RemoteRequest,
......@@ -139,7 +140,7 @@ static void AnonymousTest()
EXPECT_EQ(res, ERR_NONE);
}
static void DeathCallbackTest()
static void DeathCallbackTest(void)
{
uint32_t cbId1 = -1;
uint32_t cbId2 = -1;
......@@ -167,14 +168,13 @@ static void DeathCallbackTest()
EXPECT_EQ(ret, ERR_NONE);
ret = RemoveDeathRecipient(g_serverSid, cbId3);
EXPECT_EQ(ret, ERR_NONE);
int handleOld = g_serverSid.handle;
g_serverSid.handle = 17;
++g_serverSid.handle;
ret = AddDeathRecipient(g_serverSid, ServerDead3, NULL, &cbId5); // failed
EXPECT_EQ(ret, ERR_INVALID_PARAM);
ret = RemoveDeathRecipient(g_serverSid, cbId3); // failed
EXPECT_EQ(ret, ERR_INVALID_PARAM);
g_serverSid.handle = handleOld;
--g_serverSid.handle;
ret = AddDeathRecipient(g_serverSid, ServerDead1, NULL, &cbId1);
EXPECT_EQ(ret, ERR_NONE);
......@@ -182,7 +182,7 @@ static void DeathCallbackTest()
EXPECT_EQ(ret, ERR_NONE);
}
int main()
int main(int argc, char *argv[])
{
RPC_LOG_INFO("Enter System Ability Client .... ");
GetServerOne();
......
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Copyright (c) 2021 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
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//build/lite/config/component/lite_component.gni")
......
......@@ -16,10 +16,10 @@
#include <stdlib.h>
#include <string.h>
#include "rpc_log.h"
#include "rpc_errno.h"
#include "ipc_skeleton.h"
#include "ipc_proxy.h"
#include "ipc_skeleton.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "serializer.h"
#include "utils_list.h"
......@@ -38,6 +38,9 @@ int32_t AddSystemAbility(int32_t saId, SvcIdentity *sid)
}
SvcInfo* node = (SvcInfo *)calloc(1, sizeof(SvcInfo));
if (node == NULL) {
return ERR_FAILED;
}
node->saId = saId;
node->sid = sid;
UtilsListAdd(g_saList, &node->list);
......
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Copyright (c) 2021 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
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//build/lite/config/component/lite_component.gni")
......
......@@ -13,15 +13,15 @@
* limitations under the License.
*/
#include <stdlib.h>
#include <pthread.h>
#include "rpc_log.h"
#include "rpc_errno.h"
#include "ipc_skeleton.h"
#include "serializer.h"
#include <stdlib.h>
#include <unistd.h>
#include "ipc_proxy.h"
#include "ipc_skeleton.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "serializer.h"
static SvcIdentity *sid = NULL;
......@@ -117,7 +117,7 @@ int32_t RemoteRequestTwo(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption
return result;
}
static void *ThreadHandler()
static void *ThreadHandler(void *args)
{
sleep(IPC_TEST_TIME_INTERVAL); // sleep 2 min
const char *str = "server call anonymos service new thread.";
......@@ -149,7 +149,7 @@ static SvcIdentity svcTwo = {
.cookie = (uintptr_t)&objectStubTwo
};
static void AddSaOne()
static void AddSaOne(void)
{
IpcIo data;
uint8_t tmpData1[IPC_MAX_SIZE];
......@@ -165,10 +165,10 @@ static void AddSaOne()
FreeBuffer((void *)ptr);
EXPECT_EQ(ret, ERR_NONE);
EXPECT_EQ(res, ERR_NONE);
sleep(2);
sleep(1);
}
static void AddSaTwo()
static void AddSaTwo(void)
{
IpcIo dataTwo;
uint8_t tmpData2[IPC_MAX_SIZE];
......@@ -184,10 +184,10 @@ static void AddSaTwo()
FreeBuffer((void *)ptr);
EXPECT_EQ(ret, ERR_NONE);
EXPECT_EQ(res, ERR_NONE);
sleep(2);
sleep(1);
}
int main()
int main(int argc, char *argv[])
{
RPC_LOG_INFO("Enter System Ability Server .... ");
AddSaOne();
......@@ -205,7 +205,7 @@ int main()
ReadRemoteObject(&reply, &sidOne);
FreeBuffer((void *)ptr);
EXPECT_EQ(ret, ERR_NONE);
sleep(2);
sleep(1);
RPC_LOG_INFO("====== call serverone OP_MULTI ======");
IpcIo data2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册