# Copyright (c) 2021 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/test.gni") import("../../../hidumper.gni") module_output_path = "hiviewdfx/hidumper" source_path = "${hidumper_frameworks_path}" ############################################################################### config("module_private_config") { visibility = [ ":*" ] include_dirs = [ ".", "../../", "${hidumper_interface}/innerkits/include/", "${hidumper_interface}/native/innerkits/include/", "../../../utils/native/include/", "../../../services/zidl/include", "../../../services/native/include", "${source_path}/include", "${source_path}/", "${source_path}/manager", "${source_path}/dumpers", "include", "${hidumper_frameworks_path}", "${hidumper_frameworks_path}/include", "${hidumper_frameworks_path}/include/common", "${hidumper_frameworks_path}/include/executor", "${hidumper_frameworks_path}/include/factory", "${hidumper_service_path}:interface_include", "${hidumper_service_path}/zidl/include", "${hidumper_service_path}/native/include", ] cflags_cc = [ "-DDUMP_TEST_MODE" ] } ##############################unittest########################################## ohos_unittest("HidumperServiceTest") { module_out_path = module_output_path sources = [ "hidumper_service_test.cpp" ] configs = [ "${hidumper_utils_path}:utils_config", ":module_private_config", ] deps = [ "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] cflags = [ "-Dprivate=public", #allow test code access private members ] } ohos_unittest("HidumperDumpersTest") { module_out_path = module_output_path sources = [ "hidumper_dumpers_test.cpp" ] configs = [ "${hidumper_utils_path}:utils_config", ":module_private_config", ] deps = [ "${hidumper_service_path}:hidumperservice_cpu_source_test", "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", ] external_deps = [ "hilog:libhilog" ] } ohos_unittest("HidumperOutputTest") { module_out_path = module_output_path sources = [ "hidumper_output_test.cpp" ] configs = [ "${hidumper_utils_path}:utils_config", ":module_private_config", ] deps = [ "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", "//third_party/zlib:libz", ] external_deps = [ "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", ] } ohos_unittest("HidumperConfigUtilsTest") { module_out_path = module_output_path sources = [ "${hidumper_service_path}/native/src/dump_common_utils.cpp", "${source_path}/dump_utils.cpp", "${source_path}/src/common/dump_cfg.cpp", "${source_path}/src/common/dumper_parameter.cpp", "${source_path}/src/common/option_args.cpp", "${source_path}/src/util/config_data.cpp", "${source_path}/src/util/config_utils.cpp", "${source_path}/src/util/file_utils.cpp", "${source_path}/src/util/zip/zip_writer.cpp", "hidumper_configutils_test.cpp", ] configs = [ "${hidumper_utils_path}:utils_config", ":module_private_config", ] deps = [ "//third_party/googletest:gtest_main", "//third_party/zlib:libz", ] external_deps = [ "c_utils:utils", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", "safwk:system_ability_fwk", ] } ohos_unittest("MemoryDumperTest") { module_out_path = module_output_path sources = [ "hidumper_test_utils.cpp", "memory_dumper_test.cpp", ] configs = [ ":module_private_config" ] deps = [ "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "drivers_interface_memorytracker:libmemorytracker_proxy_1.0", "hilog:libhilog", ] } ohos_unittest("HidumperPrivacyTest") { module_out_path = module_output_path sources = [ "hidumper_privacy_test.cpp", "hidumper_test_utils.cpp", ] configs = [ ":module_private_config" ] deps = [ "//third_party/googletest:gtest_main" ] external_deps = [ "c_utils:utils" ] } ohos_unittest("HidumperInnerkitsTest") { module_out_path = module_output_path sources = [ "hidumper_innerkits_test.cpp" ] configs = [ ":module_private_config" ] deps = [ "${hidumper_service_path}:hidumperservice_source", "../../../interfaces/innerkits:lib_dump_usage", "//third_party/googletest:gtest_main", ] external_deps = [ "drivers_interface_memorytracker:libmemorytracker_proxy_1.0", "hilog:libhilog", ] } ohos_unittest("HidumperManagerTest") { module_out_path = module_output_path sources = [ "hidumper_manager_test.cpp", "hidumper_test_utils.cpp", ] configs = [ ":module_private_config" ] deps = [ "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", ] external_deps = [ "hilog:libhilog", "init:libbegetutil", ] cflags = [ "-Dprivate=public", #allow test code access private members ] } ohos_unittest("HidumperCpuServiceTest") { module_out_path = module_output_path sources = [ "hidumper_cpu_service_test.cpp" ] configs = [ "${hidumper_utils_path}:utils_config", ":module_private_config", ] deps = [ "${hidumper_service_path}:hidumperservice_cpu_source_test", "${hidumper_service_path}:hidumperservice_source", "//third_party/googletest:gtest_main", ] external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] defines = [] if (hidumper_ablility_base_enable) { external_deps += [ "ability_base:want" ] external_deps += [ "ability_runtime:app_manager" ] defines += [ "HIDUMPER_ABILITY_BASE_ENABLE" ] } if (hidumper_battery_manager_enable && hidumper_common_event_enable) { external_deps += [ "battery_manager:batterysrv_client" ] external_deps += [ "common_event_service:cesfwk_innerkits" ] defines += [ "HIDUMPER_BATTERY_ENABLE" ] } cflags = [ "-Dprivate=public", #allow test code access private members ] } ############################################################################### group("unittest") { testonly = true deps = [] deps += [ # deps file ":HidumperConfigUtilsTest", ":HidumperCpuServiceTest", ":HidumperDumpersTest", ":HidumperInnerkitsTest", ":HidumperManagerTest", ":HidumperOutputTest", ":HidumperPrivacyTest", ":HidumperServiceTest", ":MemoryDumperTest", ] } ###############################################################################