• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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("//build/ohos.gni")
15
16import("//build/ohos_var.gni")
17import("//build/test.gni")
18import("//foundation/resourceschedule/ffrt/ffrt_io_task_scheuduler.gni")
19
20module_output_path = "ffrttest/"
21
22gtest_public_deps = [ "//third_party/googletest:gtest_main" ]
23
24ffrt_ut_base_deps = [
25  "../..:libffrt",
26  "//third_party/googletest:gtest",
27  "//third_party/jsoncpp:jsoncpp",
28]
29
30ffrt_ut_base_external_deps = [
31  "c_utils:utils",
32  "faultloggerd:libbacktrace_local",
33  "faultloggerd:libdfx_dumpcatcher",
34]
35
36config("ffrt_test_config") {
37  include_dirs = [
38    "../../src",
39    "../../src/dfx/log",
40    "../../src/dfx/trace",
41    "../../src/sched",
42  ]
43
44  cflags = [
45    "-fno-rtti",
46    "-Wno-unused-variable",
47    "-Wno-unused-function",
48  ]
49
50  defines = [
51    "QOS_INTERVAL",
52    "QOS_DISPATCH",
53    "QOS_RTG",
54    "QOS_MULTI_RTG",
55    "QOS_RTG_RT",
56    "QOS_CHECKPOINT",
57    "QOS_SUBMIT",
58    "QOS_DEMO",
59    "ATRACE_MODE=0",  # 0 is off, 5 is bytrace, 6 is pmu
60    "ATRACE_LEVEL=0",
61    "ATRACE_LOGI_ENABLE=0",
62    "ATRACE_LOGD_ENABLE=0",
63    "ATRACE_SCOPE_LOG_ENABLE=0",
64    "ATRACE_DURATION_LOG_ENABLE=0",
65    "FFRT_RELEASE",
66    "DISABLE_MONITOR",
67  ]
68  if (use_musl) {
69    defines += [ "TDD_MUSL" ]
70  }
71}
72
73ohos_unittest("frame_interval_test") {
74  module_out_path = module_output_path
75
76  configs = [ ":ffrt_test_config" ]
77
78  cflags_cc = [
79    "-frtti",
80    "-Xclang",
81    "-fcxx-exceptions",
82    "-std=c++11",
83    "-DFFRT_PERF_EVENT_ENABLE",
84  ]
85
86  sources = [ "frame_interval_test.cpp" ]
87  deps = ffrt_ut_base_deps
88  external_deps = ffrt_ut_base_external_deps
89
90  if (is_standard_system) {
91    public_deps = gtest_public_deps
92  }
93
94  install_enable = true
95  part_name = "ffrt"
96}
97
98ohos_unittest("deadline_test") {
99  module_out_path = module_output_path
100
101  configs = [ ":ffrt_test_config" ]
102
103  cflags_cc = [
104    "-frtti",
105    "-Xclang",
106    "-fcxx-exceptions",
107    "-std=c++11",
108    "-DFFRT_PERF_EVENT_ENABLE",
109  ]
110
111  sources = [ "deadline_test.cpp" ]
112  deps = ffrt_ut_base_deps
113  external_deps = ffrt_ut_base_external_deps
114
115  if (is_standard_system) {
116    public_deps = gtest_public_deps
117  }
118
119  install_enable = true
120  part_name = "ffrt"
121}
122
123ohos_unittest("task_ctx_test") {
124  module_out_path = module_output_path
125
126  configs = [ ":ffrt_test_config" ]
127
128  cflags_cc = [
129    "-frtti",
130    "-Xclang",
131    "-fcxx-exceptions",
132    "-std=c++11",
133    "-DFFRT_PERF_EVENT_ENABLE",
134  ]
135
136  sources = [ "task_ctx_test.cpp" ]
137  deps = ffrt_ut_base_deps
138  external_deps = ffrt_ut_base_external_deps
139
140  if (is_standard_system) {
141    public_deps = gtest_public_deps
142  }
143
144  install_enable = true
145  part_name = "ffrt"
146}
147
148ohos_unittest("cpu_monitor_test") {
149  module_out_path = module_output_path
150
151  configs = [ ":ffrt_test_config" ]
152
153  cflags_cc = [
154    "-frtti",
155    "-Xclang",
156    "-fcxx-exceptions",
157    "-std=c++11",
158    "-DFFRT_PERF_EVENT_ENABLE",
159  ]
160
161  sources = [ "cpu_monitor_test.cpp" ]
162  deps = ffrt_ut_base_deps
163  external_deps = ffrt_ut_base_external_deps
164
165  if (is_standard_system) {
166    public_deps = gtest_public_deps
167  }
168
169  install_enable = true
170  part_name = "ffrt"
171}
172
173ohos_unittest("cpuworker_manager_test") {
174  module_out_path = module_output_path
175
176  configs = [ ":ffrt_test_config" ]
177
178  cflags_cc = [
179    "-frtti",
180    "-Xclang",
181    "-fcxx-exceptions",
182    "-std=c++11",
183    "-DFFRT_PERF_EVENT_ENABLE",
184  ]
185
186  sources = [ "cpuworker_manager_test.cpp" ]
187  deps = ffrt_ut_base_deps
188  external_deps = ffrt_ut_base_external_deps
189
190  if (is_standard_system) {
191    public_deps = gtest_public_deps
192  }
193
194  install_enable = true
195  part_name = "ffrt"
196}
197
198ohos_unittest("execute_unit_test") {
199  module_out_path = module_output_path
200
201  configs = [ ":ffrt_test_config" ]
202
203  cflags_cc = [
204    "-frtti",
205    "-Xclang",
206    "-fcxx-exceptions",
207    "-std=c++11",
208    "-DFFRT_PERF_EVENT_ENABLE",
209  ]
210
211  sources = [ "execute_unit_test.cpp" ]
212  deps = ffrt_ut_base_deps
213  external_deps = ffrt_ut_base_external_deps
214
215  if (is_standard_system) {
216    public_deps = gtest_public_deps
217  }
218
219  install_enable = true
220  part_name = "ffrt"
221}
222
223ohos_unittest("worker_thread_test") {
224  module_out_path = module_output_path
225
226  configs = [ ":ffrt_test_config" ]
227
228  cflags_cc = [
229    "-frtti",
230    "-Xclang",
231    "-fcxx-exceptions",
232    "-std=c++11",
233    "-DFFRT_PERF_EVENT_ENABLE",
234  ]
235
236  sources = [ "worker_thread_test.cpp" ]
237  deps = ffrt_ut_base_deps
238  external_deps = ffrt_ut_base_external_deps
239
240  if (is_standard_system) {
241    public_deps = gtest_public_deps
242  }
243
244  install_enable = true
245  part_name = "ffrt"
246}
247
248ohos_unittest("qos_convert_test") {
249  module_out_path = module_output_path
250
251  configs = [ ":ffrt_test_config" ]
252
253  cflags_cc = [
254    "-frtti",
255    "-Xclang",
256    "-fcxx-exceptions",
257    "-std=c++11",
258    "-DFFRT_PERF_EVENT_ENABLE",
259  ]
260
261  sources = [ "qos_convert_test.cpp" ]
262  deps = ffrt_ut_base_deps
263  external_deps = ffrt_ut_base_external_deps
264
265  if (is_standard_system) {
266    public_deps = gtest_public_deps
267  }
268
269  install_enable = true
270  part_name = "ffrt"
271}
272
273ohos_unittest("ut_coroutine_test") {
274  module_out_path = module_output_path
275
276  configs = [ ":ffrt_test_config" ]
277
278  cflags_cc = [
279    "-frtti",
280    "-Xclang",
281    "-fcxx-exceptions",
282    "-std=c++11",
283    "-DFFRT_PERF_EVENT_ENABLE",
284  ]
285
286  sources = [ "ut_coroutine_test.cpp" ]
287  deps = ffrt_ut_base_deps
288  external_deps = ffrt_ut_base_external_deps
289
290  if (is_standard_system) {
291    public_deps = gtest_public_deps
292  }
293
294  install_enable = true
295  part_name = "ffrt"
296}
297
298group("ffrt_unittest_ffrt") {
299  testonly = true
300
301  deps = []
302  if (!is_asan) {
303    deps += [
304      ":cpu_monitor_test",
305      ":cpuworker_manager_test",
306      ":deadline_test",
307      ":execute_unit_test",
308      ":frame_interval_test",
309      ":qos_convert_test",
310      ":task_ctx_test",
311      ":worker_thread_test",
312    ]
313  }
314}
315