1# Copyright (c) 2021-2023 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") 15 16if (defined(ohos_lite)) { 17 import("//build/lite/config/component/lite_component.gni") 18 import("//build/lite/config/test.gni") 19 20 if (ohos_build_type == "debug") { 21 unittest("test_processdump") { 22 output_extension = "bin" 23 output_dir = "$root_out_dir/test/unittest/faultloggerd" 24 25 include_dirs = [ 26 "$c_utils_include_path", 27 "$faultloggerd_common_path/dfxutil", 28 "$faultloggerd_interfaces_path/common", 29 "$faultloggerd_interfaces_path/innerkits/procinfo/include", 30 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 31 "$faultloggerd_path/example", 32 "$faultloggerd_path/test/utils", 33 "$faultloggerd_path/tools/process_dump", 34 "$faultloggerd_path/tools/process_dump/coredump", 35 "$hilog_lite_include_path", 36 ] 37 38 sources = [ 39 "multithread_constructor.c", 40 "process_dump_test.cpp", 41 ] 42 sources += [ "$c_utils_src_path/directory_ex.cpp" ] 43 44 deps = [ 45 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 46 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder", 47 "$faultloggerd_path/test/utils:dfx_test_util", 48 "$faultloggerd_path/tools/process_dump:process_info_src", 49 ] 50 51 external_deps = [ "hilog_lite:hilog_shared" ] 52 } 53 } 54 55 group("unittest") { 56 if (ohos_build_type == "debug") { 57 deps = [ ":test_processdump" ] 58 } 59 } 60} else { 61 import("//build/config/features.gni") 62 import("//build/test.gni") 63 64 config("module_private_config") { 65 visibility = [ ":*" ] 66 67 include_dirs = [ 68 "$faultloggerd_common_path/dfxutil", 69 "$faultloggerd_interfaces_path/common", 70 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 71 "$faultloggerd_path/example", 72 "$faultloggerd_path/test/utils", 73 "$faultloggerd_path/tools/process_dump", 74 "$faultloggerd_path/tools/process_dump/coredump", 75 "$faultloggerd_path/tools/process_dump/lperf", 76 ] 77 } 78 79 module_output_path = "faultloggerd/faultloggerd/process_dump" 80 81 ohos_unittest("test_processdump") { 82 module_out_path = module_output_path 83 sources = [ 84 "$faultloggerd_path/tools/process_dump/lperf/lperf_event_record.cpp", 85 "$faultloggerd_path/tools/process_dump/lperf/lperf_events.cpp", 86 "dfx_processdump_test.cpp", 87 "dump_info_header_test.cpp", 88 "dump_utils_test.cpp", 89 "fault_stack_test.cpp", 90 "lperf_event_record_test.cpp", 91 "lperf_events_test.cpp", 92 "maps_test.cpp", 93 "memory_near_register_test.cpp", 94 "multithread_constructor.c", 95 "open_files_test.cpp", 96 "process_dump_config_test.cpp", 97 "process_dump_test.cpp", 98 "registers_test.cpp", 99 "thread_dump_info_test.cpp", 100 ] 101 102 if (target_cpu == "arm64") { 103 sources += [ 104 "dfx_coredump_test.cpp", 105 "dfx_coredump_writer_test.cpp", 106 "extra_crash_info_test.cpp", 107 "submitter_stack_test.cpp", 108 ] 109 } 110 111 cflags_cc = [ "-Dprivate=public" ] 112 113 configs = [ 114 ":module_private_config", 115 "$faultloggerd_path/common/build:coverage_flags", 116 ] 117 118 defines = [ "UNITTEST" ] 119 120 deps = [ 121 "$faultloggerd_path/common/cutil:dfx_cutil", 122 "$faultloggerd_path/interfaces/innerkits/async_stack:libasync_stack", 123 "$faultloggerd_path/interfaces/innerkits/procinfo:dfx_procinfo_static", 124 "$faultloggerd_path/interfaces/innerkits/unwinder:libunwinder_static", 125 "$faultloggerd_path/test/utils:dfx_test_util", 126 "$faultloggerd_path/tools/process_dump:process_info_src", 127 ] 128 external_deps = [ 129 "bundle_framework:appexecfwk_base", 130 "bundle_framework:appexecfwk_core", 131 "c_utils:utils", 132 "googletest:gmock_main", 133 "googletest:gtest_main", 134 "hilog:libhilog", 135 "hitrace:libhitracechain", 136 "ipc:ipc_core", 137 "jsoncpp:jsoncpp", 138 "samgr:samgr_proxy", 139 ] 140 if (support_jsapi) { 141 deps += [ "$faultloggerd_path/test/resource:FaultloggerdJsTest" ] 142 } 143 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 144 } 145 group("unittest") { 146 testonly = true 147 deps = [ ":test_processdump" ] 148 } 149} 150