未验证 提交 55aad9a7 编写于 作者: O openharmony_ci 提交者: Gitee

!443 解决init仓ut问题

Merge pull request !443 from 熊磊/initut1
......@@ -185,6 +185,8 @@ ohos_unittest("init_ut") {
]
defines = [
"READ_CHECK",
"PARAM_SUPPORT_DAC_CHECK",
"INIT_AGENT",
"STARTUP_INIT_TEST",
"PARAM_SUPPORT_SAVE_PERSIST",
......
......@@ -38,7 +38,9 @@ HWTEST_F(ServiceSocketUnitTest, TestCreateSocket, TestSize.Level0)
ASSERT_NE(service, nullptr);
ServiceSocket *sockopt = (ServiceSocket *)calloc(1, sizeof(ServiceSocket) + strlen(testSocName) + 1);
ASSERT_NE(sockopt, nullptr);
sockopt->type = SOCK_SEQPACKET;
sockopt->type = SOCK_STREAM;
sockopt->protocol = 0;
sockopt->family = PF_UNIX;
sockopt->sockFd = -1;
sockopt->uid = 1000;
sockopt->gid = 1000;
......
......@@ -23,6 +23,7 @@
#include "iwatcher_manager.h"
#include "message_parcel.h"
#include "param_utils.h"
#include "param_request.h"
#include "sys_param.h"
#include "system_ability_definition.h"
#include "watcher.h"
......@@ -43,7 +44,14 @@ public:
WatcherAgentUnitTest() {}
virtual ~WatcherAgentUnitTest() {}
void SetUp() {}
void SetUp()
{
ParamWorkSpace *space = GetClientParamWorkSpace();
if (space != nullptr && space->securityLabel != nullptr) {
space->securityLabel->cred.uid = 1000; // 1000 test uid
space->securityLabel->cred.gid = 1000; // 1000 test gid
}
}
void TearDown() {}
void TestBody() {}
......
......@@ -68,6 +68,7 @@ public:
MessageParcel reply;
MessageOption option;
data.WriteInterfaceToken(IWatcherManager::GetDescriptor());
data.WriteString(keyPrefix);
sptr<IWatcher> watcher = new TestWatcher();
bool ret = data.WriteRemoteObject(watcher->AsObject());
......@@ -87,6 +88,7 @@ public:
MessageParcel data;
MessageParcel reply;
MessageOption option;
data.WriteInterfaceToken(IWatcherManager::GetDescriptor());
data.WriteString(keyPrefix);
data.WriteUint32(watcherId);
watcherManager->OnRemoteRequest(IWatcherManager::DEL_WATCHER, data, reply, option);
......@@ -138,6 +140,8 @@ public:
MessageParcel data;
MessageParcel reply;
MessageOption option;
data.WriteInterfaceToken(IWatcherManager::GetDescriptor());
data.WriteString(keyPrefix);
sptr<IWatcher> watcher = new TestWatcher();
bool ret = data.WriteRemoteObject(watcher->AsObject());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册