1# Copyright (c) 2022-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_dumpcatcher") { 22 output_extension = "bin" 23 24 output_dir = "$root_out_dir/test/unittest/faultloggerd/faultloggerd" 25 26 sources = [ "dumpcatcher_interfaces_test.cpp" ] 27 28 include_dirs = [ 29 "include/", 30 "$faultloggerd_interfaces_path/common", 31 "$faultloggerd_path/interfaces/innerkits/backtrace/include", 32 "$faultloggerd_path/interfaces/innerkits/dump_catcher/include", 33 "$faultloggerd_path/interfaces/innerkits/dump_catcher", 34 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client/include", 35 "$faultloggerd_path/interfaces/innerkits/formatter/include", 36 "$faultloggerd_path/test/utils", 37 "$faultloggerd_path/tools/process_dump", 38 "$faultloggerd_path/utils", 39 "$hilog_lite_include_path", 40 ] 41 42 deps = [ 43 "$faultloggerd_path/interfaces/innerkits/dump_catcher:libdfx_dumpcatcher", 44 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 45 "$faultloggerd_path/test/utils:dfx_test_util", 46 ] 47 48 external_deps = [ "hilog_lite:hilog_shared" ] 49 } 50 } 51 52 group("unittest") { 53 deps = [ ":test_dumpcatcher" ] 54 } 55} else { 56 import("//build/config/features.gni") 57 import("//build/test.gni") 58 59 module_output_path = "faultloggerd/faultloggerd/dump_catcher" 60 61 ohos_unittest("test_dumpcatcher") { 62 module_out_path = module_output_path 63 64 visibility = [ "*:*" ] 65 66 include_dirs = [ 67 "$faultloggerd_interfaces_path/common", 68 "$faultloggerd_path/interfaces/innerkits/backtrace/include", 69 "$faultloggerd_path/interfaces/innerkits/dump_catcher/include", 70 "$faultloggerd_path/interfaces/innerkits/dump_catcher", 71 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client/include", 72 "$faultloggerd_path/interfaces/innerkits/formatter/include", 73 "$faultloggerd_path/test/utils", 74 ] 75 76 sources = [ 77 "$faultloggerd_path/interfaces/innerkits/dump_catcher/dfx_dump_catcher_slow_policy.cpp", 78 "$faultloggerd_path/interfaces/innerkits/dump_catcher/kernel_stack_async_collector.cpp", 79 "dumpcatcher_command_test.cpp", 80 "dumpcatcher_interfaces_test.cpp", 81 "dumpcatcher_slow_policy_test.cpp", 82 "kernelstack_async_collector_test.cpp", 83 ] 84 cflags_cc = [ "-Dprivate=public" ] 85 86 deps = [ 87 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 88 "$faultloggerd_common_path/dfxutil:dfx_util", 89 "$faultloggerd_interfaces_path/innerkits/backtrace:libbacktrace_local", 90 "$faultloggerd_interfaces_path/innerkits/formatter:libjson_stack_formatter", 91 "$faultloggerd_path/interfaces/innerkits/dump_catcher:libdfx_dumpcatcher", 92 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 93 "$faultloggerd_path/interfaces/innerkits/procinfo:libdfx_procinfo", 94 "$faultloggerd_path/test/utils:dfx_test_util", 95 ] 96 if (support_jsapi) { 97 deps += [ "$faultloggerd_path/test/resource:FaultloggerdJsTest" ] 98 } 99 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 100 external_deps = [ 101 "c_utils:utils", 102 "googletest:gtest_main", 103 "hilog:libhilog", 104 "jsoncpp:jsoncpp", 105 ] 106 } 107 108 ohos_unittest("test_liteperf") { 109 module_out_path = module_output_path 110 111 visibility = [ "*:*" ] 112 113 include_dirs = [ 114 "$faultloggerd_interfaces_path/common", 115 "$faultloggerd_path/interfaces/innerkits/dump_catcher/include", 116 "$faultloggerd_path/test/utils", 117 ] 118 119 sources = [ "lite_perf_test.cpp" ] 120 121 deps = [ 122 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 123 "$faultloggerd_path/interfaces/innerkits/dump_catcher:libdfx_dumpcatcher", 124 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 125 "$faultloggerd_path/test/utils:dfx_test_util", 126 ] 127 external_deps = [ 128 "c_utils:utils", 129 "googletest:gtest_main", 130 "hilog:libhilog", 131 ] 132 } 133 134 group("unittest") { 135 testonly = true 136 deps = [ 137 ":test_dumpcatcher", 138 ":test_liteperf", 139 ] 140 } 141} 142