diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index d48273cde1b44d34fb15a23c94794b684c9e82a0..9864d1169dd68650f86fc57db32c74784836f83e 100755 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -185,6 +185,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 b24857a4aa25304b4423df465710bd228cb68635..783a288f73fec3d2a80ebcc723694ad35451f00f 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 f470a518faf8d7d71611991aa80eed1ace378ed9..592db7f1b70dbd8f6119f417a6c5ade491344738 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 0f527338a5810de678353611839634df3453d05b..df7787f846c4fb5b7382bd5776317f408977f41e 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());