# 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. declare_args() { SUITE_OUTPUT_PREFIX = "$root_out_dir/suites/" SUITE_ARCHIVE_DIR = "$root_out_dir/suites/testsuite" SUITE_TESTCASES_NAME = "testcases" SUITE_TOOLS_NAME = "tools" BUILD_DIR_PREFIX = "//test/xts/tools/lite/build/" } template("testsuite_common") { assert(defined(invoker.suite_name), "suite_name is required in target ${target_name}") assert(defined(invoker.subsystem_name), "subsystem_name is required in target ${target_name}") _suite_name = invoker.suite_name _output_file = invoker.output_file _project_dir = invoker.project_dir _project_type = invoker.project_type _archive_filename = invoker.archive_filename _deps = [] if (defined(invoker.deps)) { _deps += invoker.deps } _subsystem_name = invoker.subsystem_name _outputs_dir = "" if (defined(invoker.outputs_dir)) { _outputs_dir = invoker.outputs_dir } _hap_name = "," if (defined(invoker.hap_name)) { _hap_name = invoker.hap_name } _hap_sign = "," if (defined(invoker.hap_sign)) { _hap_sign = invoker.hap_sign } _args2 = [ "--method_name", "gen_suite_out", "--arguments", "suite_output_prefix=${SUITE_OUTPUT_PREFIX}#suite_names=${_suite_name}#out_suffix=${SUITE_TESTCASES_NAME}/${_subsystem_name}/${_outputs_dir}", ] _output_files = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args2, "list lines") _outputs = [] _out_paths = "" foreach(out, _output_files) { _outputs += [ "$out/$_archive_filename" ] _out_paths = _out_paths + rebase_path(out) + "," } _arguments = [ "build_module", "--build_target_name", target_name, "--target_file", _output_file, "--project_path", _project_dir, "--test_xml", rebase_path("Test.json"), "--project_type", _project_type, "--suite_out_paths", _out_paths, "--suite_filename", _archive_filename, "--subsystem_name", _subsystem_name, "--hap_name", _hap_name, "--hap_sign", _hap_sign, ] action(target_name) { deps = _deps script = rebase_path("$BUILD_DIR_PREFIX/suite.py") args = _arguments outputs = _outputs } } template("deploy_suite") { assert(defined(invoker.suite_name), "suite_name is required in target ${target_name}") _suite_name = invoker.suite_name _output_prefix = "$SUITE_OUTPUT_PREFIX" _args = [ "--method_name", "gen_suite_out", "--arguments", "suite_output_prefix=${_output_prefix}#suite_names=${_suite_name}#out_suffix=${SUITE_TOOLS_NAME}", ] _output_dirs = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args, "list lines") _outputs = "" foreach(dir, _output_dirs) { _outputs = _outputs + rebase_path(dir) + "," } _arguments = [ "build_xdevice", "--project_dir", rebase_path("//test/testfwk/xdevice"), "--output_dirs", _outputs, ] action(target_name) { deps = [] script = rebase_path("$BUILD_DIR_PREFIX/suite.py") args = _arguments outputs = _output_dirs } }