1# Copyright (c) 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_common") { 22 output_extension = "bin" 23 output_dir = "$root_out_dir/test/unittest/faultloggerd" 24 25 include_dirs = [ 26 "$c_utils_include_path", 27 "$hilog_lite_include_path", 28 "$faultloggerd_interfaces_path/common", 29 "$faultloggerd_path/common/dfxlog", 30 "$faultloggerd_path/common/dfxutil", 31 ] 32 33 sources = [ "common_test.cpp" ] 34 35 deps = [ 36 "$faultloggerd_path/common/dfxlog:dfx_hilog", 37 "$faultloggerd_path/common/dfxutil:dfx_util", 38 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 39 "$hilog_lite_deps_path", 40 ] 41 } 42 } 43 44 group("unittest") { 45 if (ohos_build_type == "debug") { 46 deps = [ ":test_common" ] 47 } 48 } 49} else { 50 import("//build/config/features.gni") 51 import("//build/test.gni") 52 53 config("module_private_config") { 54 visibility = [ ":*" ] 55 56 include_dirs = [ 57 "$faultloggerd_interfaces_path/common", 58 "$faultloggerd_path/common/cutil", 59 "$faultloggerd_path/common/dfxlog", 60 "$faultloggerd_path/common/dfxutil", 61 "$faultloggerd_path/common/trace/include", 62 ] 63 } 64 65 module_output_path = "faultloggerd/common" 66 67 ohos_unittest("test_common") { 68 module_out_path = module_output_path 69 sources = [ 70 "common_cutil_test.cpp", 71 "common_test.cpp", 72 ] 73 defines = [ "DFX_ENABLE_TRACE" ] 74 configs = [ ":module_private_config" ] 75 76 deps = [ 77 "$faultloggerd_common_path/trace:dfx_trace_dlsym", 78 "$faultloggerd_path/common/cutil:dfx_cutil", 79 "$faultloggerd_path/common/dfxutil:dfx_util", 80 ] 81 external_deps = [ 82 "c_utils:utils", 83 "googletest:gmock_main", 84 "googletest:gtest_main", 85 "hilog:libhilog", 86 ] 87 } 88 89 ohos_unittest("test_param") { 90 module_out_path = module_output_path 91 sources = [ 92 "$faultloggerd_path/common/trace/dfx_trace.cpp", 93 "param_test.cpp", 94 ] 95 configs = [ ":module_private_config" ] 96 97 defines = [ 98 "DFX_ENABLE_TRACE", 99 "ENABLE_PARAMETER", 100 ] 101 102 deps = [ "$faultloggerd_path/common/dfxutil:dfx_util" ] 103 external_deps = [ 104 "c_utils:utils", 105 "googletest:gmock_main", 106 "googletest:gtest_main", 107 "hitrace:hitrace_meter", 108 "init:libbegetutil", 109 ] 110 } 111 112 group("unittest") { 113 testonly = true 114 deps = [ ":test_common" ] 115 if (!defined(ohos_lite)) { 116 deps += [ ":test_param" ] 117 } 118 } 119} 120