# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("$build_root/config/clang/clang.gni") import("$build_root/templates/cxx/cxx.gni") # ohos test template template("_ohos_test") { assert(defined(invoker.test_type), "test_type is required.") assert(defined(invoker.module_out_path)) _deps = [] if (defined(invoker.deps)) { _deps += invoker.deps } test_output_dir = "$root_out_dir/tests/${invoker.test_type}/${invoker.module_out_path}" # copy fuzz config file if (defined(invoker.fuzz_config_file)) { fuzz_config_file = invoker.fuzz_config_file script = "//build/ohos/testfwk/fuzz_config_file_copy.py" _arguments = [] _arguments += [ "--fuzz-config-file-path", rebase_path(fuzz_config_file, root_build_dir), "--fuzz-config-file-output-path", rebase_path(root_out_dir + "/tests/res", root_build_dir), ] exec_script(script, _arguments) } _has_sources = defined(invoker.sources) && invoker.sources != [] if (_has_sources) { _c_sources_file = "$target_gen_dir/$target_name.sources" write_file(_c_sources_file, rebase_path(invoker.sources, root_build_dir)) } ohos_executable(target_name) { forward_variables_from(invoker, "*", [ "test_type", "module_out_path", "visibility", "resource_config_file", ]) forward_variables_from(invoker, [ "visibility" ]) subsystem_name = "tests" part_name = invoker.test_type testonly = true unit_test = true output_name = "$target_name" } } template("ohos_unittest") { _ohos_test(target_name) { forward_variables_from(invoker, "*") test_type = "unittest" deps = [] if (defined(invoker.deps)) { deps += invoker.deps } deps += [ "//arkcompiler/toolchain/build/third_party_gn/googletest:gtest_main" ] } }