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_stackless_coroutine.gni") 19 20module_output_path = "ffrttest/" 21 22gtest_public_deps = [ "//third_party/googletest:gtest_main" ] 23 24config("ffrt_test_config") { 25 cflags = [ 26 "-fno-rtti", 27 "-Wno-unused-variable", 28 "-Wno-unused-function", 29 ] 30 31 defines = [ 32 "QOS_INTERVAL", 33 "QOS_DISPATCH", 34 "QOS_RTG", 35 "QOS_MULTI_RTG", 36 "QOS_RTG_RT", 37 "QOS_CHECKPOINT", 38 "QOS_SUBMIT", 39 "QOS_DEMO", 40 "ATRACE_MODE=0", # 0 is off, 5 is bytrace, 6 is pmu 41 "ATRACE_LEVEL=0", 42 "ATRACE_LOGI_ENABLE=0", 43 "ATRACE_LOGD_ENABLE=0", 44 "ATRACE_SCOPE_LOG_ENABLE=0", 45 "ATRACE_DURATION_LOG_ENABLE=0", 46 "FFRT_RELEASE", 47 "DISABLE_MONITOR", 48 ] 49 if (use_musl) { 50 defines += [ "TDD_MUSL" ] 51 } 52} 53 54ohos_unittest("frame_interval_test") { 55 module_out_path = module_output_path 56 57 cflags_cc = [ 58 "-frtti", 59 "-Xclang", 60 "-fcxx-exceptions", 61 "-std=c++11", 62 "-DFFRT_PERF_EVENT_ENABLE", 63 ] 64 65 sources = [ "frame_interval_test.cpp" ] 66 deps = [ 67 "../..:libffrt", 68 "//third_party/googletest:gtest", 69 "//third_party/jsoncpp:jsoncpp", 70 ] 71 external_deps = [ 72 "c_utils:utils", 73 "eventhandler:libeventhandler", 74 "ipc:ipc_core", 75 "safwk:system_ability_fwk", 76 "samgr:samgr_proxy", 77 ] 78 79 if (is_standard_system) { 80 public_deps = gtest_public_deps 81 } 82 83 install_enable = true 84 part_name = "ffrt" 85} 86 87ohos_unittest("deadline_test") { 88 module_out_path = module_output_path 89 90 configs = [ ":ffrt_test_config" ] 91 92 cflags_cc = [ 93 "-frtti", 94 "-Xclang", 95 "-fcxx-exceptions", 96 "-std=c++11", 97 "-DFFRT_PERF_EVENT_ENABLE", 98 ] 99 100 sources = [ "deadline_test.cpp" ] 101 deps = [ 102 "../..:libffrt", 103 "//third_party/googletest:gtest", 104 "//third_party/jsoncpp:jsoncpp", 105 ] 106 external_deps = [ 107 "c_utils:utils", 108 "eventhandler:libeventhandler", 109 "ipc:ipc_core", 110 "safwk:system_ability_fwk", 111 "samgr:samgr_proxy", 112 ] 113 114 if (is_standard_system) { 115 public_deps = gtest_public_deps 116 } 117 118 install_enable = true 119 part_name = "ffrt" 120} 121 122ohos_unittest("task_ctx_test") { 123 module_out_path = module_output_path 124 125 configs = [ ":ffrt_test_config" ] 126 127 cflags_cc = [ 128 "-frtti", 129 "-Xclang", 130 "-fcxx-exceptions", 131 "-std=c++11", 132 "-DFFRT_PERF_EVENT_ENABLE", 133 ] 134 135 sources = [ "task_ctx_test.cpp" ] 136 deps = [ 137 "../..:libffrt", 138 "//third_party/googletest:gtest", 139 "//third_party/jsoncpp:jsoncpp", 140 ] 141 external_deps = [ 142 "c_utils:utils", 143 "eventhandler:libeventhandler", 144 "ipc:ipc_core", 145 "safwk:system_ability_fwk", 146 "samgr:samgr_proxy", 147 ] 148 149 if (is_standard_system) { 150 public_deps = gtest_public_deps 151 } 152 153 install_enable = true 154 part_name = "ffrt" 155} 156 157ohos_unittest("cpu_monitor_test") { 158 module_out_path = module_output_path 159 160 configs = [ ":ffrt_test_config" ] 161 162 cflags_cc = [ 163 "-frtti", 164 "-Xclang", 165 "-fcxx-exceptions", 166 "-std=c++11", 167 "-DFFRT_PERF_EVENT_ENABLE", 168 ] 169 170 sources = [ "cpu_monitor_test.cpp" ] 171 deps = [ 172 "../..:libffrt", 173 "//third_party/googletest:gtest", 174 "//third_party/jsoncpp:jsoncpp", 175 ] 176 external_deps = [ 177 "c_utils:utils", 178 "eventhandler:libeventhandler", 179 "ipc:ipc_core", 180 "safwk:system_ability_fwk", 181 "samgr:samgr_proxy", 182 ] 183 184 if (is_standard_system) { 185 public_deps = gtest_public_deps 186 } 187 188 install_enable = true 189 part_name = "ffrt" 190} 191 192ohos_unittest("cpuworker_manager_test") { 193 module_out_path = module_output_path 194 195 configs = [ ":ffrt_test_config" ] 196 197 cflags_cc = [ 198 "-frtti", 199 "-Xclang", 200 "-fcxx-exceptions", 201 "-std=c++11", 202 "-DFFRT_PERF_EVENT_ENABLE", 203 ] 204 205 sources = [ "cpuworker_manager_test.cpp" ] 206 deps = [ 207 "../..:libffrt", 208 "//third_party/googletest:gtest", 209 "//third_party/jsoncpp:jsoncpp", 210 ] 211 external_deps = [ 212 "c_utils:utils", 213 "eventhandler:libeventhandler", 214 "ipc:ipc_core", 215 "safwk:system_ability_fwk", 216 "samgr:samgr_proxy", 217 ] 218 219 if (is_standard_system) { 220 public_deps = gtest_public_deps 221 } 222 223 install_enable = true 224 part_name = "ffrt" 225} 226 227ohos_unittest("execute_unit_test") { 228 module_out_path = module_output_path 229 230 configs = [ ":ffrt_test_config" ] 231 232 cflags_cc = [ 233 "-frtti", 234 "-Xclang", 235 "-fcxx-exceptions", 236 "-std=c++11", 237 "-DFFRT_PERF_EVENT_ENABLE", 238 ] 239 240 sources = [ "execute_unit_test.cpp" ] 241 deps = [ 242 "../..:libffrt", 243 "//third_party/googletest:gtest", 244 "//third_party/jsoncpp:jsoncpp", 245 ] 246 external_deps = [ 247 "c_utils:utils", 248 "eventhandler:libeventhandler", 249 "ipc:ipc_core", 250 "safwk:system_ability_fwk", 251 "samgr:samgr_proxy", 252 ] 253 254 if (is_standard_system) { 255 public_deps = gtest_public_deps 256 } 257 258 install_enable = true 259 part_name = "ffrt" 260} 261 262ohos_unittest("worker_thread_test") { 263 module_out_path = module_output_path 264 265 configs = [ ":ffrt_test_config" ] 266 267 cflags_cc = [ 268 "-frtti", 269 "-Xclang", 270 "-fcxx-exceptions", 271 "-std=c++11", 272 "-DFFRT_PERF_EVENT_ENABLE", 273 ] 274 275 sources = [ "worker_thread_test.cpp" ] 276 deps = [ 277 "../..:libffrt", 278 "//third_party/googletest:gtest", 279 "//third_party/jsoncpp:jsoncpp", 280 ] 281 external_deps = [ 282 "c_utils:utils", 283 "eventhandler:libeventhandler", 284 "ipc:ipc_core", 285 "safwk:system_ability_fwk", 286 "samgr:samgr_proxy", 287 ] 288 289 if (is_standard_system) { 290 public_deps = gtest_public_deps 291 } 292 293 install_enable = true 294 part_name = "ffrt" 295} 296 297ohos_unittest("qos_convert_test") { 298 module_out_path = module_output_path 299 300 configs = [ ":ffrt_test_config" ] 301 302 cflags_cc = [ 303 "-frtti", 304 "-Xclang", 305 "-fcxx-exceptions", 306 "-std=c++11", 307 "-DFFRT_PERF_EVENT_ENABLE", 308 ] 309 310 sources = [ "qos_convert_test.cpp" ] 311 deps = [ 312 "../..:libffrt", 313 "//third_party/googletest:gtest", 314 ] 315 external_deps = [ 316 "c_utils:utils", 317 "eventhandler:libeventhandler", 318 "ipc:ipc_core", 319 "safwk:system_ability_fwk", 320 "samgr:samgr_proxy", 321 ] 322 323 if (is_standard_system) { 324 public_deps = gtest_public_deps 325 } 326 327 install_enable = true 328 part_name = "ffrt" 329} 330 331ohos_unittest("ut_coroutine_test") { 332 module_out_path = module_output_path 333 334 configs = [ ":ffrt_test_config" ] 335 336 cflags_cc = [ 337 "-frtti", 338 "-Xclang", 339 "-fcxx-exceptions", 340 "-std=c++11", 341 "-DFFRT_PERF_EVENT_ENABLE", 342 ] 343 344 sources = [ "ut_coroutine_test.cpp" ] 345 deps = [ 346 "../..:libffrt", 347 "//third_party/googletest:gtest", 348 "//third_party/jsoncpp:jsoncpp", 349 ] 350 external_deps = [ 351 "c_utils:utils", 352 "eventhandler:libeventhandler", 353 "ipc:ipc_core", 354 "safwk:system_ability_fwk", 355 "samgr:samgr_proxy", 356 ] 357 358 if (is_standard_system) { 359 public_deps = gtest_public_deps 360 } 361 362 install_enable = true 363 part_name = "ffrt" 364} 365 366group("ffrt_unittest_ffrt") { 367 testonly = true 368 369 deps = [] 370 if (!is_asan) { 371 deps += [ 372 ":cpu_monitor_test", 373 ":cpuworker_manager_test", 374 ":deadline_test", 375 ":execute_unit_test", 376 ":frame_interval_test", 377 ":qos_convert_test", 378 ":task_ctx_test", 379 ":worker_thread_test", 380 ] 381 } 382} 383