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/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 "$faultloggerd_path/test/utils", 32 ] 33 34 sources = [ "common_test.cpp" ] 35 36 deps = [ 37 "$faultloggerd_path/common/dfxlog:dfx_hilog", 38 "$faultloggerd_path/common/dfxutil:dfx_util", 39 "$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd", 40 "$faultloggerd_path/test/utils:dfx_test_util", 41 "$hilog_lite_deps_path", 42 ] 43 } 44 } 45 46 group("unittest") { 47 if (ohos_build_type == "debug") { 48 deps = [ ":test_common" ] 49 } 50 } 51} else { 52 import("//build/config/features.gni") 53 import("//build/test.gni") 54 55 config("module_private_config") { 56 visibility = [ ":*" ] 57 58 include_dirs = [ 59 "$faultloggerd_interfaces_path/common", 60 "$faultloggerd_path/common/cutil", 61 "$faultloggerd_path/common/dfxlog", 62 "$faultloggerd_path/common/dfxutil", 63 "$faultloggerd_path/common/trace/include", 64 "$faultloggerd_path/test/utils", 65 ] 66 defines = [ 67 "is_ohos=${is_ohos}", 68 "is_mingw=${is_mingw}", 69 ] 70 } 71 72 module_output_path = "faultloggerd/faultloggerd/common" 73 74 ohos_unittest("test_common") { 75 module_out_path = module_output_path 76 sources = [ 77 "common_cutil_test.cpp", 78 "common_test.cpp", 79 "proc_util_test.cpp", 80 ] 81 defines = [ "DFX_ENABLE_TRACE" ] 82 configs = [ ":module_private_config" ] 83 resource_config_file = "$faultloggerd_path/test/resource/ohos_test.xml" 84 85 deps = [ 86 "$faultloggerd_common_path/trace:dfx_trace_dlsym", 87 "$faultloggerd_path/common/cutil:dfx_cutil", 88 "$faultloggerd_path/common/dfxutil:dfx_util", 89 "$faultloggerd_path/test/utils:dfx_test_util", 90 ] 91 external_deps = [ 92 "c_utils:utils", 93 "googletest:gmock_main", 94 "googletest:gtest_main", 95 "hilog:libhilog", 96 ] 97 } 98 99 ohos_unittest("test_param") { 100 module_out_path = module_output_path 101 sources = [ 102 "$faultloggerd_path/common/trace/dfx_trace.cpp", 103 "param_test.cpp", 104 ] 105 configs = [ ":module_private_config" ] 106 107 defines = [ 108 "DFX_ENABLE_TRACE", 109 "ENABLE_PARAMETER", 110 ] 111 112 deps = [ "$faultloggerd_path/common/dfxutil:dfx_util" ] 113 external_deps = [ 114 "c_utils:utils", 115 "googletest:gmock_main", 116 "googletest:gtest_main", 117 "hitrace:hitrace_meter", 118 "init:libbegetutil", 119 ] 120 } 121 122 ohos_unittest("test_smartfd") { 123 module_out_path = module_output_path 124 sources = [ "smart_fd_test.cpp" ] 125 configs = [ ":module_private_config" ] 126 127 external_deps = [ 128 "c_utils:utils", 129 "googletest:gmock_main", 130 "googletest:gtest_main", 131 "init:libbegetutil", 132 ] 133 } 134 group("unittest") { 135 testonly = true 136 deps = [ 137 ":test_common", 138 ":test_smartfd", 139 ] 140 if (!defined(ohos_lite)) { 141 deps += [ ":test_param" ] 142 } 143 } 144} 145