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