1# Copyright (c) 2023 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") 15import("//arkcompiler/runtime_core/ark_config.gni") 16import("$ark_root/tests/test_helper.gni") 17 18disasm_test_configs = [ 19 "$ark_root:ark_config", 20 "$ark_root/libpandabase:arkbase_public_config", 21 "$ark_root/libpandafile:arkfile_public_config", 22 sdk_libc_secshared_config, 23] 24 25disasm_test_deps = [ 26 "$ark_root/disassembler:arkdisassembler", 27 "$ark_root/libpandabase:libarkbase_static", 28 "$ark_root/libpandafile:libarkfile_static", 29] 30 31disasm_column_test_js_files = [ 32 "column-number1", 33 "column-number2", 34 "column-number3", 35 "column-number4", 36 "column-number5", 37 "column-number6", 38 "line-number1", 39 "line-number2", 40 "line-number3", 41 "line-number4", 42 "line-number5", 43] 44 45disasm_test_js_files = [ 46 "slot-number-annotation", 47 "script-string1", 48 "script-string2", 49] 50 51test_js_path = "//arkcompiler/runtime_core/disassembler/tests/js/" 52 53foreach(file, disasm_column_test_js_files) { 54 es2abc_gen_abc("gen_${file}_abc") { 55 test_js = "${test_js_path}${file}.js" 56 test_abc = "$target_out_dir/${file}.abc" 57 src_js = rebase_path(test_js) 58 dst_file = rebase_path(test_abc) 59 extra_args = [ 60 "--debug", 61 "--module", 62 ] 63 in_puts = [ test_js ] 64 out_puts = [ test_abc ] 65 } 66} 67 68disasm_module_test_js_files = [ 69 "module-requests-annotation-import", 70 "module-regular-import", 71 "module-namespace-import", 72 "module-local-export", 73 "module-indirect-export", 74 "module-start-export", 75] 76 77module_test_js_path = "//arkcompiler/runtime_core/disassembler/tests/module/" 78 79foreach(file, disasm_module_test_js_files) { 80 es2abc_gen_abc("gen_${file}_abc") { 81 test_js = "${module_test_js_path}${file}.js" 82 test_abc = "$target_out_dir/${file}.abc" 83 src_js = rebase_path(test_js) 84 85 dst_file = rebase_path(test_abc) 86 extra_args = [ 87 "--module", 88 "--merge-abc", 89 ] 90 in_puts = [ test_js ] 91 out_puts = [ test_abc ] 92 } 93} 94 95foreach(file, disasm_test_js_files) { 96 es2abc_gen_abc("gen_${file}_abc") { 97 test_js = "${test_js_path}${file}.js" 98 test_abc = "$target_out_dir/${file}.abc" 99 src_js = rebase_path(test_js) 100 101 dst_file = rebase_path(test_abc) 102 in_puts = [ test_js ] 103 out_puts = [ test_abc ] 104 } 105} 106 107disasm_include_dirs = [ 108 "$ark_root/disassembler", 109 "$ark_root/assembler", 110 "$target_gen_dir", 111 "$target_gen_dir/../", 112 "$target_gen_dir/../../assembler", 113] 114 115script_sources = [ 116 "disassembler_annotations_test.cpp", 117 "disassembler_column_number_test.cpp", 118 "disassembler_line_number_test.cpp", 119 "disassembler_string_test.cpp", 120] 121 122module_sources = [ 123 "disassembler_annotations_test.cpp", 124 "disassembler_module_literal_test.cpp", 125] 126 127host_unittest_action("DisasmModuleTest") { 128 module_out_path = module_output_path 129 sources = module_sources 130 include_dirs = disasm_include_dirs 131 configs = disasm_test_configs 132 deps = disasm_test_deps 133 test_abc_dir = rebase_path(target_out_dir) 134 defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ] 135 136 foreach(file, disasm_module_test_js_files) { 137 deps += [ ":gen_${file}_abc" ] 138 } 139} 140 141host_unittest_action("DisasmDebugTest") { 142 module_out_path = module_output_path 143 sources = script_sources 144 include_dirs = disasm_include_dirs 145 configs = disasm_test_configs 146 deps = disasm_test_deps 147 test_abc_dir = rebase_path(target_out_dir) 148 defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ] 149 150 foreach(file, disasm_column_test_js_files) { 151 deps += [ ":gen_${file}_abc" ] 152 } 153} 154 155host_unittest_action("DisasmScriptTest") { 156 module_out_path = module_output_path 157 sources = script_sources 158 include_dirs = disasm_include_dirs 159 configs = disasm_test_configs 160 deps = disasm_test_deps 161 test_abc_dir = rebase_path(target_out_dir) 162 defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ] 163 164 foreach(file, disasm_test_js_files) { 165 deps += [ ":gen_${file}_abc" ] 166 } 167} 168 169group("host_unittest") { 170 testonly = true 171 deps = [ 172 ":DisasmDebugTestAction", 173 ":DisasmModuleTestAction", 174 ":DisasmScriptTestAction", 175 ] 176} 177