1# Copyright (c) 2022 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 18module_out_path = "$ark_root/bytecode_optimizer" 19 20bcopt_test_config = [ 21 "$ark_root:ark_config", 22 "$ark_root/abc2program:abc2program_public_config", 23 "$ark_root/assembler:arkassembler_public_config", 24 "$ark_root/libpandabase:arkbase_public_config", 25 "$ark_root/libpandafile:arkfile_public_config", 26 "$ark_root/compiler:arkcompiler_public_config", 27 "$ark_root/bytecode_optimizer:bytecodeopt_public_config", 28 sdk_libc_secshared_config, 29] 30 31bcopt_test_deps = [ 32 "$ark_root/abc2program:abc2program", 33 "$ark_root/assembler:libarkassembler", 34 "$ark_root/bytecode_optimizer:libarkbytecodeopt", 35 "$ark_root/compiler:libarkcompiler", 36 "$ark_root/libpandabase:libarkbase", 37 "$ark_root/libpandafile:libarkfile", 38 "$ark_root/libziparchive:libarkziparchive", 39] 40 41test_js_path = "//arkcompiler/runtime_core/bytecode_optimizer/tests/js/" 42graph_test_js_files = [ 43 "codegenTryCatch", 44 "optimizeTryCatch", 45] 46 47foreach(file, graph_test_js_files) { 48 es2abc_gen_abc("gen_${file}_abc") { 49 test_js = "${test_js_path}${file}.js" 50 test_abc = "$target_out_dir/${file}.abc" 51 52 src_js = rebase_path(test_js) 53 dst_file = rebase_path(test_abc) 54 55 in_puts = [ test_js ] 56 out_puts = [ test_abc ] 57 } 58} 59 60graph_test_js_files_un_opt = [ 61 "bytecodeAnalysis", 62 "constantProgagation", 63] 64 65foreach(file, graph_test_js_files_un_opt) { 66 es2abc_gen_abc("gen_${file}_abc") { 67 test_js = "${test_js_path}${file}.js" 68 test_abc = "$target_out_dir/${file}.abc" 69 70 src_js = rebase_path(test_js) 71 dst_file = rebase_path(test_abc) 72 73 in_puts = [ test_js ] 74 out_puts = [ test_abc ] 75 76 extra_args = [ 77 "--debug", 78 "--module", 79 "--merge-abc", 80 ] 81 } 82} 83 84host_unittest_action("BytecodeOptimizerTest") { 85 module_out_path = module_output_path 86 sources = [ 87 "analysis_bytecode_test.cpp", 88 "codegen_test.cpp", 89 "constant_propagation_test.cpp", 90 "excluded_keys_test.cpp", 91 "optimize_bytecode_test.cpp", 92 "reg_encoder_test.cpp", 93 ] 94 configs = bcopt_test_config 95 deps = bcopt_test_deps 96 external_deps = [ sdk_libc_secshared_dep ] 97 test_abc_dir = rebase_path(target_out_dir) 98 99 defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ] 100 101 foreach(file, graph_test_js_files) { 102 deps += [ ":gen_${file}_abc" ] 103 } 104 foreach(file, graph_test_js_files_un_opt) { 105 deps += [ ":gen_${file}_abc" ] 106 } 107 108 defines += [ 109 "ARK_INTRINSIC_SET", 110 "ENABLE_BYTECODE_OPT", 111 "PANDA_WITH_ECMASCRIPT", 112 ] 113} 114 115group("host_unittest") { 116 testonly = true 117 deps = [ ":BytecodeOptimizerTestAction" ] 118} 119