From 04bd26e047b2e062ad3524ffbefb51a731ce6319 Mon Sep 17 00:00:00 2001 From: xionglei6 Date: Thu, 17 Mar 2022 21:37:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Aut=E7=94=A8=E4=BE=8B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xionglei6 --- test/unittest/BUILD.gn | 2 ++ test/unittest/init/service_socket_unittest.cpp | 4 +++- test/unittest/param/watcher_agent_unittest.cpp | 10 +++++++++- test/unittest/param/watcher_proxy_unittest.cpp | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 64fc776d..b4fbaea8 100755 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -182,6 +182,8 @@ ohos_unittest("init_ut") { ] defines = [ + "READ_CHECK", + "PARAM_SUPPORT_DAC_CHECK", "INIT_AGENT", "STARTUP_INIT_TEST", "PARAM_SUPPORT_SAVE_PERSIST", diff --git a/test/unittest/init/service_socket_unittest.cpp b/test/unittest/init/service_socket_unittest.cpp index b24857a4..783a288f 100755 --- a/test/unittest/init/service_socket_unittest.cpp +++ b/test/unittest/init/service_socket_unittest.cpp @@ -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; diff --git a/test/unittest/param/watcher_agent_unittest.cpp b/test/unittest/param/watcher_agent_unittest.cpp index f470a518..592db7f1 100755 --- a/test/unittest/param/watcher_agent_unittest.cpp +++ b/test/unittest/param/watcher_agent_unittest.cpp @@ -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() {} diff --git a/test/unittest/param/watcher_proxy_unittest.cpp b/test/unittest/param/watcher_proxy_unittest.cpp index 0f527338..df7787f8 100755 --- a/test/unittest/param/watcher_proxy_unittest.cpp +++ b/test/unittest/param/watcher_proxy_unittest.cpp @@ -68,6 +68,7 @@ public: MessageParcel reply; MessageOption option; + data.WriteInterfaceToken(IWatcherManager::GetDescriptor()); data.WriteString(keyPrefix); sptr 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 watcher = new TestWatcher(); bool ret = data.WriteRemoteObject(watcher->AsObject()); -- GitLab