From d4ddf9f5c3c659bc1c8026b85ce70241d40f4075 Mon Sep 17 00:00:00 2001 From: huyx Date: Sat, 10 Aug 2024 20:29:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?TDD=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E7=8E=87=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/hdi/test/BUILD.gn | 1 + .../object_collector_test.cpp | 11 ++++++ .../servmgr/service_manager_hdi_c_test.cpp | 10 ++++++ .../uhdf2/host/test/unittest/devhost_test.cpp | 5 ++- .../uhdf2/host/test/unittest/devmgr_test.cpp | 34 ++++++++++++++++++- .../common/hdf_remote_adapter_test.cpp | 1 + .../unittest/common/hdf_core_shared_test.cpp | 6 ++++ 7 files changed, 66 insertions(+), 2 deletions(-) diff --git a/adapter/uhdf2/hdi/test/BUILD.gn b/adapter/uhdf2/hdi/test/BUILD.gn index 5b4240dc8..fcd96a101 100644 --- a/adapter/uhdf2/hdi/test/BUILD.gn +++ b/adapter/uhdf2/hdi/test/BUILD.gn @@ -33,6 +33,7 @@ ohos_unittest("HdiServiceManagerTest") { include_dirs = [ "$hdf_uhdf_path/host/test/unittest/sample_driver", "$hdf_uhdf_path/utils/include", + "$hdf_framework_path/core/shared/include", ] if (with_sample) { diff --git a/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp b/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp index f95c85567..027008e9c 100644 --- a/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp +++ b/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp @@ -38,10 +38,21 @@ public: void SetUp() {}; void TearDown() {}; }; +static bool TestRemove() +{ + return HDI::ObjectCollector::GetInstance().RemoveObject(nullptr); +} HWTEST_F(ObjectCollectorTest, ObjectCollectorTest001, TestSize.Level1) { sptr object = HDI::ObjectCollector::GetInstance().NewObject(nullptr, INTERFACE_NAME); ASSERT_EQ(object, nullptr); + object = HDI::ObjectCollector::GetInstance().GetOrNewObject(nullptr, INTERFACE_NAME); + ASSERT_EQ(object, nullptr); + bool remove = false; + if(!TestRemove()){ + remove = true; + } + ASSERT_EQ(remove, true); } } // namespace OHOS \ No newline at end of file diff --git a/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp b/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp index 291c9ac7f..2b4350f80 100644 --- a/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp +++ b/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,8 @@ #include "sample_hdi.h" #include "hdi_support.h" +#include +#include #define HDF_LOG_TAG service_manager_test @@ -805,4 +808,11 @@ HWTEST_F(HdfServiceMangerHdiCTest, HdiSupportTest, TestSize.Level1) ASSERT_EQ(LoadHdiImpl(NULL, NULL), nullptr); UnloadHdiImpl(NULL, NULL, NULL); } + +HWTEST_F(HdfServiceMangerHdiCTest, ServMgrTest019, TestSize.Level1) +{ + struct ServiceStatusListener *listener = HdiServiceStatusListenerNewInstance(); + HdiServiceStatusListenerFree(nullptr); + HdiServiceStatusListenerFree(listener); +} } // namespace OHOS \ No newline at end of file diff --git a/adapter/uhdf2/host/test/unittest/devhost_test.cpp b/adapter/uhdf2/host/test/unittest/devhost_test.cpp index 69d1286f1..7979d741b 100644 --- a/adapter/uhdf2/host/test/unittest/devhost_test.cpp +++ b/adapter/uhdf2/host/test/unittest/devhost_test.cpp @@ -275,6 +275,7 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest2, TestSize.Level1) struct HdfDeviceNode *devNode = HdfDeviceNodeNewInstance(&deviceInfo, &driver); ASSERT_TRUE(devNode != nullptr); HdfDeviceNodeConstruct(devNode); + devNode->hostService = nullptr; struct IDeviceNode *nodeIf = &devNode->super; int32_t ret = nodeIf->LaunchNode(devNode); @@ -283,13 +284,15 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest2, TestSize.Level1) devNode = HdfDeviceNodeNewInstance(&deviceInfo, &driver); ASSERT_TRUE(devNode != nullptr); HdfDeviceNodeConstruct(devNode); - nodeIf = &devNode->super; + nodeIf = &devNode->super;\ + devNode->hostService = nullptr; ret = nodeIf->LaunchNode(devNode); entry.Init = nullptr; devNode = HdfDeviceNodeNewInstance(&deviceInfo, &driver); ASSERT_TRUE(devNode != nullptr); HdfDeviceNodeConstruct(devNode); + devNode->hostService = nullptr; nodeIf = &devNode->super; ret = nodeIf->LaunchNode(devNode); ASSERT_TRUE(ret != HDF_SUCCESS); diff --git a/adapter/uhdf2/host/test/unittest/devmgr_test.cpp b/adapter/uhdf2/host/test/unittest/devmgr_test.cpp index 45ea7f5c1..7678e47bc 100644 --- a/adapter/uhdf2/host/test/unittest/devmgr_test.cpp +++ b/adapter/uhdf2/host/test/unittest/devmgr_test.cpp @@ -21,6 +21,8 @@ #include #include "hdf_dump.h" #include "hdf_dump_reg.h" +#include "hcs_tree_if.h" +#include "hcs_dm_parser.h" #define HDF_LOG_TAG driver_manager @@ -148,15 +150,45 @@ HWTEST_F(DevMgrTest, DriverTest, TestSize.Level1) } #endif +static int TestDump(struct HdfSBuf *, struct HdfSBuf *) +{ + return HDF_SUCCESS; +} + HWTEST_F(DevMgrTest, DevMgrDumpErrorTest, TestSize.Level1) { ASSERT_TRUE(servmgr != nullptr); ASSERT_TRUE(devmgr != nullptr); HdfRegisterDumpFunc(nullptr); + int32_t fd = 0; + HdfRegisterDumpFunc(TestDump); + const std::vector vcr = {u"123", u"456"}; + const std::vector vcr1 = { + u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"10", + u"11", u"12", u"13", u"14", u"15", u"16", u"17", u"18", u"19", u"20", + u"21", u"22", u"23", u"24" + }; + int ret = HdfDump(fd, vcr); + ASSERT_TRUE(ret != HDF_SUCCESS); + fd = 1; + ret = HdfDump(fd, vcr1); + ASSERT_TRUE(ret != HDF_SUCCESS); int32_t illegalFd = -1; std::vector illegalArgs = {}; - int ret = HdfDump(illegalFd, illegalArgs); + ret = HdfDump(illegalFd, illegalArgs); ASSERT_TRUE(ret != HDF_SUCCESS); } + +HWTEST_F(DevMgrTest, HdfUtilsTest, TestSize.Level1) +{ + std::string CONFIGPATH = "/system/etc/hdfconfig/default"; + std::string CONFIGPATH1 = "/system/etc/hdfconfig/default.hcb"; + SetHcsBlobPath(CONFIGPATH.c_str()); + const struct DeviceResourceNode *node = HcsGetRootNode(); + ASSERT_TRUE(node == nullptr); + SetHcsBlobPath(CONFIGPATH1.c_str()); + const struct DeviceResourceNode *node1 = HcsGetRootNode(); + ASSERT_TRUE(node1 == nullptr); +} } // namespace OHOS diff --git a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp index f744bdc60..924e91d76 100644 --- a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp +++ b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp @@ -21,6 +21,7 @@ #include "hdf_remote_adapter.h" #include "hdf_remote_adapter_if.h" #include "hdf_sbuf_ipc.h" +#include "hdf_dump.h" namespace OHOS { using namespace testing::ext; diff --git a/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp b/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp index 7589bf87b..6b5147a6c 100644 --- a/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp +++ b/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp @@ -70,7 +70,13 @@ HWTEST_F(HdfCoreSharedTest, ServiceStatusMarshallingTest, TestSize.Level1) ASSERT_NE(status, nullptr); ret = ServiceStatusMarshalling(status, nullptr); ASSERT_EQ(ret, HDF_ERR_INVALID_PARAM); + HdfSBuf *sBuf = HdfSbufTypedObtain(SBUF_IPC); + const char *serviceName = "testServiceName"; + HdfSbufWriteString(sBuf, serviceName); + ret = ServiceStatusMarshalling(status, sBuf); + ASSERT_EQ(ret, HDF_FAILURE); OsalMemFree(status); + HdfSbufRecycle(sBuf); } HWTEST_F(HdfCoreSharedTest, ServiceStatusUnMarshallingTest, TestSize.Level1) -- Gitee From 88d6147bc8d8cd00356fe455fe3a07997dc247fb Mon Sep 17 00:00:00 2001 From: huyx Date: Sat, 10 Aug 2024 22:27:52 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- .../uhdf2/host/test/unittest/devhost_test.cpp | 34 +++++++++++++++++++ .../unittest/common/hdf_core_shared_test.cpp | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/adapter/uhdf2/host/test/unittest/devhost_test.cpp b/adapter/uhdf2/host/test/unittest/devhost_test.cpp index 7979d741b..7c0c6e63f 100644 --- a/adapter/uhdf2/host/test/unittest/devhost_test.cpp +++ b/adapter/uhdf2/host/test/unittest/devhost_test.cpp @@ -32,6 +32,8 @@ #include "hdf_log.h" #include "hdf_sbuf.h" #include "osal_mem.h" +#include "hdf_device_object.h" + #define HDF_LOG_TAG host_test @@ -74,6 +76,9 @@ HWTEST_F(DevHostTest, DevHostDevMgrServiceProxyTest, TestSize.Level1) ASSERT_TRUE(ret != HDF_SUCCESS); ret = instance->LoadDevice(instance, nullptr); ASSERT_TRUE(ret != HDF_SUCCESS); + const char *name = "test_svcName"; + ret = instance->LoadDevice(instance, name); + ASSERT_TRUE(ret == HDF_SUCCESS); struct DevmgrServiceProxy *proxy = reinterpret_cast(object); HdfRemoteServiceRecycle(proxy->remote); @@ -140,6 +145,7 @@ HWTEST_F(DevHostTest, DevHostDevSvcMgrProxyTest, TestSize.Level1) instance->RemoveService(instance, "test", nullptr); DevSvcManagerProxyRelease(object); DevSvcManagerProxyRelease(nullptr); + HdfDeviceObjectCheckInterfaceDesc(nullptr, nullptr); } HWTEST_F(DevHostTest, DevHostServiceTest, TestSize.Level1) @@ -278,6 +284,8 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest2, TestSize.Level1) devNode->hostService = nullptr; struct IDeviceNode *nodeIf = &devNode->super; int32_t ret = nodeIf->LaunchNode(devNode); + devNode->devStatus = DEVNODE_NONE; + nodeIf->UnlaunchNode(devNode); entry.Bind = HdfTestFailBind; entry.Init = HdfTestInit; @@ -299,6 +307,7 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest2, TestSize.Level1) devNode->devStatus = DEVNODE_NONE; nodeIf->UnlaunchNode(devNode); + DevmgrServiceClntDetachDevice(devNode->devId); } HWTEST_F(DevHostTest, DevHostDeviceNodeTest3, TestSize.Level1) @@ -324,6 +333,8 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest3, TestSize.Level1) HdfDeviceNodeRemovePowerStateListener(nullptr, nullptr); HdfDeviceNodeRemovePowerStateListener(devNode, nullptr); HdfDeviceNodeRemovePowerStateListener(devNode, nullptr); + ret = HdfDeviceNodePublishPublicService(devNode); + ASSERT_TRUE(ret != HDF_SUCCESS); devNode->deviceObject.service = nullptr; ret = HdfDeviceNodePublishPublicService(devNode); ASSERT_TRUE(ret != HDF_SUCCESS); @@ -343,10 +354,30 @@ HWTEST_F(DevHostTest, DevHostDeviceNodeTest3, TestSize.Level1) HWTEST_F(DevHostTest, DevHostDeviceTest, TestSize.Level1) { + struct HdfDriverEntry entry; + entry.Bind = nullptr; + struct HdfDriver driver; + driver.entry = &entry; + struct HdfDeviceInfo deviceInfo; + deviceInfo.deviceId = 0; + deviceInfo.permission = 0; + deviceInfo.preload = 0; + deviceInfo.deviceType = 0; + deviceInfo.svcName = "driver_service"; + deviceInfo.deviceName = "driver_module"; + + deviceInfo.policy = SERVICE_POLICY_PUBLIC; + entry.Bind = HdfTestSuccBind; + entry.Init = HdfTestInit; + struct HdfDeviceNode *devNode = HdfDeviceNodeNewInstance(&deviceInfo, &driver); + ASSERT_TRUE(devNode != nullptr); + HdfDeviceNodeConstruct(devNode); struct HdfObject *object = HdfDeviceCreate(); ASSERT_TRUE(object != nullptr); struct IHdfDevice *device = reinterpret_cast(object); + devNode->devId = 0; + device->Attach(device, devNode); int32_t ret = device->Attach(device, nullptr); ASSERT_TRUE(ret != HDF_SUCCESS); ret = device->Attach(nullptr, nullptr); @@ -359,6 +390,9 @@ HWTEST_F(DevHostTest, DevHostDeviceTest, TestSize.Level1) ASSERT_TRUE(ret != HDF_SUCCESS); ret = HdfDeviceDetach(device, nullptr); ASSERT_TRUE(ret != HDF_SUCCESS); + devNode->servStatus = true; + struct IDeviceNode *deviceIf = reinterpret_cast(object); + ret = deviceIf->RemoveService(devNode); HdfDeviceRelease(nullptr); HdfDeviceFreeInstance(nullptr); } diff --git a/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp b/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp index 6b5147a6c..3380d3ec2 100644 --- a/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp +++ b/framework/core/shared/test/unittest/common/hdf_core_shared_test.cpp @@ -74,7 +74,7 @@ HWTEST_F(HdfCoreSharedTest, ServiceStatusMarshallingTest, TestSize.Level1) const char *serviceName = "testServiceName"; HdfSbufWriteString(sBuf, serviceName); ret = ServiceStatusMarshalling(status, sBuf); - ASSERT_EQ(ret, HDF_FAILURE); + ASSERT_TRUE(ret !=HDF_FAILURE); OsalMemFree(status); HdfSbufRecycle(sBuf); } -- Gitee From 2415b1e7dfcdabf9fc89c3760f742fc1ac942d90 Mon Sep 17 00:00:00 2001 From: huyx Date: Sat, 10 Aug 2024 22:29:41 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- .../uhdf2/hdi/test/object_collector/object_collector_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp b/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp index 027008e9c..a632492e5 100644 --- a/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp +++ b/adapter/uhdf2/hdi/test/object_collector/object_collector_test.cpp @@ -50,7 +50,7 @@ HWTEST_F(ObjectCollectorTest, ObjectCollectorTest001, TestSize.Level1) object = HDI::ObjectCollector::GetInstance().GetOrNewObject(nullptr, INTERFACE_NAME); ASSERT_EQ(object, nullptr); bool remove = false; - if(!TestRemove()){ + if (!TestRemove()) { remove = true; } ASSERT_EQ(remove, true); -- Gitee From f1064f970e2ecd76a4d4d426457c75e02a69fac6 Mon Sep 17 00:00:00 2001 From: huyx Date: Mon, 12 Aug 2024 18:50:17 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- .../servmgr/service_manager_hdi_c_test.cpp | 9 ++++ adapter/uhdf2/hdi/test/smq_test/smq_test.cpp | 43 ++++++++++++++++++- .../uhdf2/host/test/unittest/devhost_test.cpp | 2 +- .../common/hdf_remote_adapter_test.cpp | 7 +++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp b/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp index 2b4350f80..f31fc00d4 100644 --- a/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp +++ b/adapter/uhdf2/hdi/test/servmgr/service_manager_hdi_c_test.cpp @@ -813,6 +813,15 @@ HWTEST_F(HdfServiceMangerHdiCTest, ServMgrTest019, TestSize.Level1) { struct ServiceStatusListener *listener = HdiServiceStatusListenerNewInstance(); HdiServiceStatusListenerFree(nullptr); + struct HDIServiceManager *servmgr = HDIServiceManagerGet(); + int ret = servmgr->RegisterServiceStatusListener(servmgr, listener, DEVICE_CLASS_DEFAULT); + ASSERT_TRUE(ret == HDF_SUCCESS); + ret = servmgr->UnregisterServiceStatusListener(servmgr, listener); + ASSERT_TRUE(ret != HDF_SUCCESS); + struct HdiServiceSet *serviceSet = (struct HdiServiceSet *)OsalMemAlloc(sizeof(struct HdiServiceSet)); + serviceSet->count = 20; + ret = HdiServiceSetRelease(serviceSet); + ASSERT_TRUE(ret != HDF_SUCCESS); HdiServiceStatusListenerFree(listener); } } // namespace OHOS \ No newline at end of file diff --git a/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp b/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp index f2584fc9f..97253033f 100644 --- a/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp +++ b/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp @@ -14,6 +14,10 @@ */ #include +#include +#include +#include "osal_mem.h" +#include #include #include #include @@ -306,4 +310,41 @@ HWTEST_F(SmqTest, SmqTest002, TestSize.Level1) PrintFds("sample_host unclosed fds:", servHostUnclosedFds); } } -#endif \ No newline at end of file +#endif + +static uintptr_t MapMemZone(uint32_t zoneType) +{ + std::shared_ptr> meta_ = + std::make_shared>(300, SmqType::SYNCED_SMQ); + auto memzone = meta_->GetMemZone(zoneType); + if (memzone == nullptr) { + HDF_LOGE("invalid smq mem zone type %{public}u", zoneType); + return reinterpret_cast(nullptr); + } + + int offset = (static_cast(memzone->offset) / PAGE_SIZE) * PAGE_SIZE; + int length = static_cast(memzone->offset) - offset + static_cast(memzone->size); + + void *ptr = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, meta_->GetFd(), offset); + if (ptr == MAP_FAILED) { + HDF_LOGE( + "failed to map memzone %{public}u, size %{public}u, offset %{public}u , fd %{public}d, errnor=%{public}d", + zoneType, length, offset, meta_->GetFd(), errno); + unsigned int num = 20; + unsigned int *uptr = # + return reinterpret_cast(uptr); + } + return (reinterpret_cast(ptr) + (static_cast(memzone->offset) - offset)); +} + +HWTEST_F(SmqTest, SmqTest003, TestSize.Level1) +{ + std::atomic *syncerPtr_ = + reinterpret_cast *>(MapMemZone(SharedMemQueueMeta::MEMZONE_SYNCER)); + std::unique_ptr syncer_ = + std::make_unique(syncerPtr_); + syncer_->Wake(OHOS::HDI::Base::SharedMemQueueSyncer::SYNC_WORD_WRITE); + syncer_->Wait(OHOS::HDI::Base::SharedMemQueueSyncer::SYNC_WORD_WRITE, 0); + syncer_->Wake(OHOS::HDI::Base::SharedMemQueueSyncer::SYNC_WORD_WRITE); + syncer_->Wait(OHOS::HDI::Base::SharedMemQueueSyncer::SYNC_WORD_WRITE, 5); +} \ No newline at end of file diff --git a/adapter/uhdf2/host/test/unittest/devhost_test.cpp b/adapter/uhdf2/host/test/unittest/devhost_test.cpp index 7c0c6e63f..cf51c647b 100644 --- a/adapter/uhdf2/host/test/unittest/devhost_test.cpp +++ b/adapter/uhdf2/host/test/unittest/devhost_test.cpp @@ -78,7 +78,7 @@ HWTEST_F(DevHostTest, DevHostDevMgrServiceProxyTest, TestSize.Level1) ASSERT_TRUE(ret != HDF_SUCCESS); const char *name = "test_svcName"; ret = instance->LoadDevice(instance, name); - ASSERT_TRUE(ret == HDF_SUCCESS); + ASSERT_TRUE(ret != HDF_SUCCESS); struct DevmgrServiceProxy *proxy = reinterpret_cast(object); HdfRemoteServiceRecycle(proxy->remote); diff --git a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp index 924e91d76..04754bffc 100644 --- a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp +++ b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp @@ -62,6 +62,13 @@ HWTEST_F(HdfRemoteAdapterTest, HdfRemoteAdapterTest002, TestSize.Level1) ret = HdfRemoteAdapterAddService(name, NULL); ASSERT_EQ(ret, HDF_ERR_INVALID_PARAM); + const char *serviceName = "test_service"; + HdfRemoteService *remoteService = HdfRemoteAdapterObtain(); + ret = HdfRemoteAdapterAddService(serviceName, remoteService); + ASSERT_TRUE(ret != HDF_SUCCESS); + ret = HdfRemoteAdapterAddSa(-1, remoteService); + ASSERT_TRUE(ret != HDF_SUCCESS); + HdfRemoteService *remote = HdfRemoteAdapterGetService(NULL); ASSERT_EQ(remote, nullptr); remote = HdfRemoteAdapterGetService(name); -- Gitee From abf6e094a9e8fd638c764bb5fc0bd888eea609d3 Mon Sep 17 00:00:00 2001 From: huyx Date: Mon, 12 Aug 2024 19:36:18 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/hdi/test/smq_test/smq_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp b/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp index 97253033f..1fed1af9b 100644 --- a/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp +++ b/adapter/uhdf2/hdi/test/smq_test/smq_test.cpp @@ -42,6 +42,7 @@ using OHOS::HDI::Base::SmqType; using OHOS::HDI::DeviceManager::V1_0::IDeviceManager; using OHOS::HDI::ServiceManager::V1_0::IServiceManager; +static constexpr const uint32_t TEST_NUM = 300; #ifdef SAMPLE_DRIVER static constexpr const char *TEST_SERVICE_HOST_NAME = "sample_host"; static constexpr const char *SERVICE_NAME = "sample_driver_service"; @@ -315,7 +316,7 @@ HWTEST_F(SmqTest, SmqTest002, TestSize.Level1) static uintptr_t MapMemZone(uint32_t zoneType) { std::shared_ptr> meta_ = - std::make_shared>(300, SmqType::SYNCED_SMQ); + std::make_shared>(TEST_NUM, SmqType::SYNCED_SMQ); auto memzone = meta_->GetMemZone(zoneType); if (memzone == nullptr) { HDF_LOGE("invalid smq mem zone type %{public}u", zoneType); -- Gitee