From f339d0c6fa6d2127760db150d4d8b4b1ff633b67 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Tue, 19 Mar 2024 15:01:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../common/ipc/dhfwk_sa_manager/BUILD.gn | 9 +++++- .../include/dhfwk_sa_manager_test.h | 4 +-- .../ipc/distributed_hardware_proxy/BUILD.gn | 7 +++++ .../include/distributed_hardware_proxy_test.h | 4 +-- .../ipc/publisher_listener_stub/BUILD.gn | 9 +++++- .../include/publisher_listener_stub_test.h | 4 +-- .../unittest/common/accessmanager/BUILD.gn | 9 +++++- .../accessmanager/access_manager_test.cpp | 4 +-- .../unittest/common/componentloader/BUILD.gn | 9 +++++- .../include/component_loader_test.h | 5 ++-- .../src/component_loader_test.cpp | 4 +-- .../component_monitior/BUILD.gn | 9 +++++- .../include/component_monitor_test.h | 4 +-- .../distributedhardwareservice/BUILD.gn | 10 ++++++- .../src/distributed_hardware_service_test.cpp | 6 +--- .../common/distributedhardwarestub/BUILD.gn | 9 +++++- .../include/distributed_hardware_stub_test.h | 4 +-- .../hidumphelper/enabledcompsdump/BUILD.gn | 9 +++++- .../src/enabled_comps_dump_test.cpp | 4 +-- .../test/unittest/common/ipc/BUILD.gn | 9 +++++- .../include/publisher_listener_proxy_test.h | 4 +-- .../localhardwaremanager/BUILD.gn | 9 +++++- .../src/local_hardware_manager_test.cpp | 4 +-- .../pluginlistenerimpl/BUILD.gn | 9 +++++- .../include/plugin_listener_impl_test.h | 4 +-- .../common/lowlatency/lowlatency/BUILD.gn | 9 +++++- .../lowlatency/include/low_latency_test.h | 4 +-- .../lowlatency/lowlatencylistener/BUILD.gn | 9 +++++- .../include/low_latency_listener_test.h | 4 +-- .../test/unittest/common/publisher/BUILD.gn | 9 +++++- .../publisher/include/publisher_item_test.h | 4 +-- .../unittest/common/resourcemanager/BUILD.gn | 9 +++++- .../src/resource_manager_test.cpp | 4 +-- .../test/unittest/common/task/BUILD.gn | 9 +++++- .../unittest/common/task/include/task_test.h | 4 +-- .../versioninfomanager/versioninfo/BUILD.gn | 9 +++++- .../versioninfo/src/version_info_test.cpp | 4 +-- .../versioninfomanager/BUILD.gn | 9 +++++- .../src/version_info_manager_test.cpp | 4 +-- .../unittest/common/versionmanager/BUILD.gn | 9 +++++- .../src/version_manager_test.cpp | 4 +-- utils/include/histreamer_query_tool.h | 9 ++++-- utils/src/anonymous_string.cpp | 11 ++++--- utils/src/dh_utils_tool.cpp | 30 ++++++++++--------- .../test/unittest/common/eventtrance/BUILD.gn | 9 +++++- .../common/eventtrance/event_trance_test.h | 4 +-- 46 files changed, 221 insertions(+), 108 deletions(-) diff --git a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn index 63b7f2bd..a2bdb174 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -46,6 +46,13 @@ ohos_unittest("DhfwkSaManagerTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"DhfwkSaManagerTest\"", diff --git a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h index ec8e533a..64ae9291 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h +++ b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -24,9 +24,7 @@ #include "distributed_hardware_errno.h" #include "idistributed_hardware.h" -#define private public #include "dhfwk_sa_manager.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/BUILD.gn index d613a9c5..75a2d9ec 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/BUILD.gn @@ -46,6 +46,13 @@ ohos_unittest("DistributedHardwareProxyTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"DistributedHardwareProxyTest\"", diff --git a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h index da187b0a..704ac0b6 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h +++ b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -23,9 +23,7 @@ #include "device_type.h" #include "distributed_hardware_errno.h" #include "idistributed_hardware.h" -#define private public #include "distributed_hardware_proxy.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn index 809b2f68..8de2a765 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -46,6 +46,13 @@ ohos_unittest("PublisherListenerStubTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"PublisherListenerStubTest\"", diff --git a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/include/publisher_listener_stub_test.h b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/include/publisher_listener_stub_test.h index 5f32cdef..85333c5f 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/include/publisher_listener_stub_test.h +++ b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/include/publisher_listener_stub_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -26,9 +26,7 @@ #include "ipublisher_listener.h" #include "iremote_stub.h" #include "idistributed_hardware.h" -#define private public #include "publisher_listener_stub.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn index dcbc89f5..cf4da5e2 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -43,6 +43,13 @@ ohos_unittest("AccessManagerTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp index 8955b075..833e90d4 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -21,10 +21,8 @@ #include "gtest/gtest.h" -#define private public #include "access_manager.h" #include "distributed_hardware_manager_factory.h" -#undef private #include "dm_device_info.h" #include "distributed_hardware_errno.h" using namespace testing::ext; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn index 193efc05..dcc6ed39 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -44,6 +44,13 @@ ohos_unittest("ComponentLoaderTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/include/component_loader_test.h b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/include/component_loader_test.h index d0d847d8..9143cff0 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/include/component_loader_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/include/component_loader_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -17,9 +17,8 @@ #define OHOS_DISTRIBUTED_HARDWARE_COMPONENT_LOADER_TEST_H #include -#define private public #include "componentloader/component_loader.cpp" -#undef private + namespace OHOS { namespace DistributedHardware { class ComponentLoaderTest : public testing::Test { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp index e18cd442..f050a65a 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -14,9 +14,7 @@ */ #include "component_loader_test.h" -#define private public #include "component_loader.h" -#undef private #include "distributed_hardware_log.h" #include "hitrace_meter.h" #include "hidump_helper.h" diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/BUILD.gn index b887fafe..9a0a2619 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -58,6 +58,13 @@ ohos_unittest("ComponentMonitorTest") { "samgr:samgr_proxy", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"ComponentMonitorTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/include/component_monitor_test.h b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/include/component_monitor_test.h index 66cbeec0..875c2496 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/include/component_monitor_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/include/component_monitor_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -18,9 +18,7 @@ #include "gtest/gtest.h" -#define private public #include "component_monitor.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/BUILD.gn index b1ffab8b..acec492e 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -48,6 +48,14 @@ ohos_unittest("DistributedHardwareServiceTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + "-Dprotected=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"DistributedHardwareServiceTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp index 2b37f317..fbb6915f 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -23,13 +23,9 @@ #include "dh_context.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -#define protected public -#define private public #include "distributed_hardware_service.h" #include "distributed_hardware_manager.h" #include "task_board.h" -#undef private -#undef protected #include "mock_publisher_listener.h" using namespace testing::ext; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn index bbde54fd..65d09344 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -48,6 +48,13 @@ ohos_unittest("DistributedHardwareStubTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"DistributedHardwareStubTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h index 460bf5e5..59b44d30 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -20,9 +20,7 @@ #include "distributed_hardware_errno.h" #include "distributed_hardware_fwk_kit_paras.h" -#define private public #include "distributed_hardware_stub.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn index 0e912ddb..b3bbb572 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -40,6 +40,13 @@ ohos_unittest("EnabledCompsDumpTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"EnabledCompsDumpTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/src/enabled_comps_dump_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/src/enabled_comps_dump_test.cpp index fceaced2..fe9d6df2 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/src/enabled_comps_dump_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/src/enabled_comps_dump_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -19,9 +19,7 @@ #include #include -#define private public #include "enabled_comps_dump.h" -#undef private using namespace testing::ext; namespace OHOS { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn index f188e1a6..fa57d758 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -38,6 +38,13 @@ ohos_unittest("PublisherListenerProxyTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"PublisherListenerProxyTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/ipc/include/publisher_listener_proxy_test.h b/services/distributedhardwarefwkservice/test/unittest/common/ipc/include/publisher_listener_proxy_test.h index e7afb95c..80f08fea 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/ipc/include/publisher_listener_proxy_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/ipc/include/publisher_listener_proxy_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -20,9 +20,7 @@ #include #include -#define private public #include "publisher_listener_proxy.h" -#undef private #include "distributed_hardware_errno.h" namespace OHOS { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/BUILD.gn index 7905c5e8..7c8f2c4a 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -48,6 +48,13 @@ ohos_unittest("LocalHardwareManagerTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "//third_party/googletest:gtest_main", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/src/local_hardware_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/src/local_hardware_manager_test.cpp index 045c6e6f..b9df061a 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/src/local_hardware_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/localhardwaremanager/src/local_hardware_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -15,12 +15,10 @@ #include "local_hardware_manager_test.h" -#define private public #include "capability_info_manager.h" #include "component_loader.h" #include "dh_context.h" #include "local_hardware_manager.h" -#undef private #include "mock_hardware_handler.h" using namespace testing::ext; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/BUILD.gn index 99d25e2f..f9fa7b30 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -46,6 +46,13 @@ ohos_unittest("PluginListenerImplTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "//third_party/googletest:gtest_main", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/include/plugin_listener_impl_test.h b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/include/plugin_listener_impl_test.h index a6d34db6..14bc9846 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/include/plugin_listener_impl_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/include/plugin_listener_impl_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -18,9 +18,7 @@ #include -#define private public #include "plugin_listener_impl.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn index 4d4ffd5d..70db2115 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -41,6 +41,13 @@ ohos_unittest("LowLatencyTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"LowLatencyTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/include/low_latency_test.h b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/include/low_latency_test.h index 91422211..5701c07c 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/include/low_latency_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/include/low_latency_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -20,9 +20,7 @@ #include #include -#define private public #include "low_latency.h" -#undef private #include "distributed_hardware_errno.h" namespace OHOS { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn index 3aea19cd..ba1409bb 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -41,6 +41,13 @@ ohos_unittest("LowLatencyListenerTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"LowLatencyListenerTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/include/low_latency_listener_test.h b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/include/low_latency_listener_test.h index 0a38cae4..5d6eadd9 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/include/low_latency_listener_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/include/low_latency_listener_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -20,10 +20,8 @@ #include #include -#define private public #include "low_latency_listener.h" #include "low_latency_timer.h" -#undef private #include "distributed_hardware_errno.h" namespace OHOS { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn index cda9ac00..9a3be618 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -38,6 +38,13 @@ ohos_unittest("PublisherItemTest") { "//third_party/googletest:gtest_main", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + external_deps = [ "c_utils:utils", "kv_store:distributeddata_inner", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/publisher/include/publisher_item_test.h b/services/distributedhardwarefwkservice/test/unittest/common/publisher/include/publisher_item_test.h index 419cd442..6938fc2b 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/publisher/include/publisher_item_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/publisher/include/publisher_item_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -19,9 +19,7 @@ #include #include -#define private public #include "publisher_item.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn index 15157c63..f7aac220 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -41,6 +41,13 @@ ohos_unittest("ResourceManagerTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp index 32ac7c31..a2c82ac7 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -20,11 +20,9 @@ #include #include -#define private public #include "capability_info.h" #include "capability_info_manager.h" #include "version_info_event.h" -#undef private #include "dh_context.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn index cbb8b49f..e660da3b 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 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 @@ -55,6 +55,13 @@ ohos_unittest("DHTaskTest") { external_deps = [ "c_utils:utils" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"TaskTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/include/task_test.h b/services/distributedhardwarefwkservice/test/unittest/common/task/include/task_test.h index 8f5f6987..5dc6f3f5 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/include/task_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/include/task_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -18,14 +18,12 @@ #include -#define private public #include "disable_task.h" #include "enable_task.h" #include "offline_task.h" #include "task.h" #include "task_board.h" #include "task_executor.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/BUILD.gn index ac50f7da..c2dcce67 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -41,6 +41,13 @@ ohos_unittest("VersionInfoTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/src/version_info_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/src/version_info_test.cpp index 34db268b..2b4aeeb4 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/src/version_info_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfo/src/version_info_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -19,11 +19,9 @@ #include #include -#define private public #include "version_info_manager.h" #include "version_manager.h" #include "version_info.h" -#undef private #include "dh_context.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn index d9cfa77b..b2cf3ffc 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -42,6 +42,13 @@ ohos_unittest("VersioninfoManagerTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp index db1694ab..af4847cc 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -19,11 +19,9 @@ #include #include -#define private public #include "version_info_manager.h" #include "version_manager.h" #include "version_info_event.h" -#undef private #include "dh_context.h" #include "distributed_hardware_log.h" diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn index e0984cb0..5a6483ef 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -53,6 +53,13 @@ ohos_unittest("VersionManagerTest") { "kv_store:distributeddata_inner", ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"VersionManagerTest\"", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp index 6c34d013..45383b2f 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -15,9 +15,7 @@ #include "version_manager_test.h" -#define private public #include "component_loader.h" -#undef private #include "version_manager.h" using namespace testing::ext; diff --git a/utils/include/histreamer_query_tool.h b/utils/include/histreamer_query_tool.h index dbbb1398..16d81f28 100644 --- a/utils/include/histreamer_query_tool.h +++ b/utils/include/histreamer_query_tool.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -13,6 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#ifndef OHOS_HISTREAMER_QUERY_TOOL_H +#define OHOS_HISTREAMER_QUERY_TOOL_H + #include #include #include "single_instance.h" @@ -34,4 +38,5 @@ private: void Init(); }; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/utils/src/anonymous_string.cpp b/utils/src/anonymous_string.cpp index be63436b..43b12921 100644 --- a/utils/src/anonymous_string.cpp +++ b/utils/src/anonymous_string.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -22,11 +22,15 @@ namespace OHOS { namespace DistributedHardware { -std::string GetAnonyString(const std::string &value) -{ +namespace { constexpr size_t INT32_SHORT_ID_LENGTH = 20; constexpr size_t INT32_PLAINTEXT_LENGTH = 4; constexpr size_t INT32_MIN_ID_LENGTH = 3; + constexpr int32_t INT32_STRING_LENGTH = 40; +} + +std::string GetAnonyString(const std::string &value) +{ std::string res; std::string tmpStr("******"); size_t strLen = value.length(); @@ -49,7 +53,6 @@ std::string GetAnonyString(const std::string &value) std::string GetAnonyInt32(const int32_t value) { - constexpr int32_t INT32_STRING_LENGTH = 40; char tempBuffer[INT32_STRING_LENGTH] = ""; int32_t secRet = sprintf_s(tempBuffer, INT32_STRING_LENGTH, "%d", value); if (secRet <= 0) { diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index 0533742a..c0f7eda2 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -31,9 +31,14 @@ namespace OHOS { namespace DistributedHardware { -constexpr int32_t MS_ONE_SECOND = 1000; -constexpr int32_t WORD_WIDTH_8 = 8; -constexpr int32_t WORD_WIDTH_4 = 4; +namespace { + constexpr int32_t MS_ONE_SECOND = 1000; + constexpr int32_t WORD_WIDTH_8 = 8; + constexpr int32_t WORD_WIDTH_4 = 4; + constexpr int32_t WIDTH = 4; + constexpr unsigned char MASK = 0x0F; + constexpr int32_t DOUBLE_TIMES = 2; +} int64_t GetCurrentTime() { @@ -91,24 +96,21 @@ std::string GetDeviceIdByUUID(const std::string &uuid) std::string Sha256(const std::string& in) { - unsigned char out[SHA256_DIGEST_LENGTH * 2 + 1] = {0}; + unsigned char result[SHA256_DIGEST_LENGTH * 2 + 1] = {0}; SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, in.data(), in.size()); - SHA256_Final(&out[SHA256_DIGEST_LENGTH], &ctx); + SHA256_Final(&result[SHA256_DIGEST_LENGTH], &ctx); // here we translate sha256 hash to hexadecimal. each 8-bit char will be presented by two characters([0-9a-f]) - constexpr int32_t WIDTH = 4; - constexpr unsigned char MASK = 0x0F; const char* hexCode = "0123456789abcdef"; - constexpr int32_t DOUBLE_TIMES = 2; for (int32_t i = 0; i < SHA256_DIGEST_LENGTH; ++i) { - unsigned char value = out[SHA256_DIGEST_LENGTH + i]; + unsigned char value = result[SHA256_DIGEST_LENGTH + i]; // uint8_t is 2 digits in hexadecimal. - out[i * DOUBLE_TIMES] = hexCode[(value >> WIDTH) & MASK]; - out[i * DOUBLE_TIMES + 1] = hexCode[value & MASK]; + result[i * DOUBLE_TIMES] = hexCode[(value >> WIDTH) & MASK]; + result[i * DOUBLE_TIMES + 1] = hexCode[value & MASK]; } - out[SHA256_DIGEST_LENGTH * DOUBLE_TIMES] = 0; - return reinterpret_cast(out); + result[SHA256_DIGEST_LENGTH * DOUBLE_TIMES] = 0; + return reinterpret_cast(result); } DeviceInfo GetLocalDeviceInfo() diff --git a/utils/test/unittest/common/eventtrance/BUILD.gn b/utils/test/unittest/common/eventtrance/BUILD.gn index e240e684..41bf0710 100644 --- a/utils/test/unittest/common/eventtrance/BUILD.gn +++ b/utils/test/unittest/common/eventtrance/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2024 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 @@ -41,6 +41,13 @@ ohos_unittest("EventTranceTest") { configs = [ ":module_private_config" ] + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + ] + deps = [ "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", diff --git a/utils/test/unittest/common/eventtrance/event_trance_test.h b/utils/test/unittest/common/eventtrance/event_trance_test.h index c5c74609..70d226fc 100644 --- a/utils/test/unittest/common/eventtrance/event_trance_test.h +++ b/utils/test/unittest/common/eventtrance/event_trance_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -18,9 +18,7 @@ #include -#define private public #include "dh_context.h" -#undef private #include "dh_utils_hisysevent.h" #include "dh_utils_hitrace.h" -- Gitee