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    deps = [ ":test_common" ]
46  }
47} else {
48  import("//build/config/features.gni")
49  import("//build/test.gni")
50
51  config("module_private_config") {
52    visibility = [ ":*" ]
53
54    include_dirs = [
55      "$faultloggerd_interfaces_path/common",
56      "$faultloggerd_path/common/cutil",
57      "$faultloggerd_path/common/dfxlog",
58      "$faultloggerd_path/common/dfxutil",
59      "$faultloggerd_path/common/trace/include",
60    ]
61  }
62
63  module_output_path = "faultloggerd/common"
64
65  ohos_unittest("test_common") {
66    module_out_path = module_output_path
67    sources = [
68      "$faultloggerd_path/common/dfxlog/dfx_log.cpp",
69      "common_cutil_test.cpp",
70      "common_test.cpp",
71    ]
72    defines = [
73      "DFX_ENABLE_TRACE",
74      "DFX_LOG_DMESG",
75    ]
76    configs = [ ":module_private_config" ]
77
78    deps = [
79      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
80      "$faultloggerd_path/common/cutil:dfx_cutil",
81      "$faultloggerd_path/common/dfxutil:dfx_util",
82    ]
83    external_deps = [
84      "c_utils:utils",
85      "googletest:gmock_main",
86      "googletest:gtest_main",
87      "hilog:libhilog",
88    ]
89  }
90
91  ohos_unittest("test_param") {
92    module_out_path = module_output_path
93    sources = [
94      "$faultloggerd_path/common/trace/dfx_trace.cpp",
95      "param_test.cpp",
96    ]
97    configs = [ ":module_private_config" ]
98
99    defines = [
100      "DFX_ENABLE_TRACE",
101      "ENABLE_PARAMETER",
102    ]
103
104    deps = [ "$faultloggerd_path/common/dfxutil:dfx_util" ]
105    external_deps = [
106      "c_utils:utils",
107      "googletest:gmock_main",
108      "googletest:gtest_main",
109      "hitrace:hitrace_meter",
110      "init:libbegetutil",
111    ]
112  }
113
114  group("unittest") {
115    testonly = true
116    deps = [ ":test_common" ]
117    if (!defined(ohos_lite)) {
118      deps += [ ":test_param" ]
119    }
120  }
121}
122