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 14declare_args() { 15 SUITE_OUTPUT_PREFIX = "$root_out_dir/suites/" 16 SUITE_ARCHIVE_DIR = "$root_out_dir/suites/testsuite" 17 SUITE_TESTCASES_NAME = "testcases" 18 SUITE_TOOLS_NAME = "tools" 19 BUILD_DIR_PREFIX = "//test/xts/tools/lite/build/" 20} 21template("testsuite_common") { 22 assert(defined(invoker.suite_name), 23 "suite_name is required in target ${target_name}") 24 assert(defined(invoker.subsystem_name), 25 "subsystem_name is required in target ${target_name}") 26 27 _suite_name = invoker.suite_name 28 _output_file = invoker.output_file 29 _project_dir = invoker.project_dir 30 _project_type = invoker.project_type 31 _archive_filename = invoker.archive_filename 32 _deps = [] 33 if (defined(invoker.deps)) { 34 _deps += invoker.deps 35 } 36 _subsystem_name = invoker.subsystem_name 37 38 _outputs_dir = "" 39 if (defined(invoker.outputs_dir)) { 40 _outputs_dir = invoker.outputs_dir 41 } 42 43 _hap_name = "," 44 if (defined(invoker.hap_name)) { 45 _hap_name = invoker.hap_name 46 } 47 48 _hap_sign = "," 49 if (defined(invoker.hap_sign)) { 50 _hap_sign = invoker.hap_sign 51 } 52 _args2 = [ 53 "--method_name", 54 "gen_suite_out", 55 "--arguments", 56 "suite_output_prefix=${SUITE_OUTPUT_PREFIX}#suite_names=${_suite_name}#out_suffix=${SUITE_TESTCASES_NAME}/${_subsystem_name}/${_outputs_dir}", 57 ] 58 _output_files = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), 59 _args2, 60 "list lines") 61 _outputs = [] 62 _out_paths = "" 63 foreach(out, _output_files) { 64 _outputs += [ "$out/$_archive_filename" ] 65 _out_paths = _out_paths + rebase_path(out) + "," 66 } 67 68 _arguments = [ 69 "build_module", 70 "--build_target_name", 71 target_name, 72 "--target_file", 73 _output_file, 74 "--project_path", 75 _project_dir, 76 "--test_xml", 77 rebase_path("Test.json"), 78 "--project_type", 79 _project_type, 80 "--suite_out_paths", 81 _out_paths, 82 "--suite_filename", 83 _archive_filename, 84 "--subsystem_name", 85 _subsystem_name, 86 "--hap_name", 87 _hap_name, 88 "--hap_sign", 89 _hap_sign, 90 ] 91 92 action(target_name) { 93 deps = _deps 94 script = rebase_path("$BUILD_DIR_PREFIX/suite.py") 95 args = _arguments 96 outputs = _outputs 97 } 98} 99 100template("deploy_suite") { 101 assert(defined(invoker.suite_name), 102 "suite_name is required in target ${target_name}") 103 _suite_name = invoker.suite_name 104 _output_prefix = "$SUITE_OUTPUT_PREFIX" 105 _args = [ 106 "--method_name", 107 "gen_suite_out", 108 "--arguments", 109 "suite_output_prefix=${_output_prefix}#suite_names=${_suite_name}#out_suffix=${SUITE_TOOLS_NAME}", 110 ] 111 _output_dirs = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), 112 _args, 113 "list lines") 114 _outputs = "" 115 foreach(dir, _output_dirs) { 116 _outputs = _outputs + rebase_path(dir) + "," 117 } 118 _arguments = [ 119 "build_xdevice", 120 "--project_dir", 121 rebase_path("//test/testfwk/xdevice"), 122 "--output_dirs", 123 _outputs, 124 ] 125 action(target_name) { 126 deps = [] 127 script = rebase_path("$BUILD_DIR_PREFIX/suite.py") 128 args = _arguments 129 outputs = _output_dirs 130 } 131} 132