# Copyright (c) 2022 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. import("//build/config/components/ets_frontend/es2abc_config.gni") import("//arkcompiler/runtime_core/ark_config.gni") import("$ark_root/tests/test_helper.gni") module_out_path = "$ark_root/bytecode_optimizer" bcopt_test_config = [ "$ark_root:ark_config", "$ark_root/abc2program:abc2program_public_config", "$ark_root/assembler:arkassembler_public_config", "$ark_root/libpandabase:arkbase_public_config", "$ark_root/libpandafile:arkfile_public_config", "$ark_root/compiler:arkcompiler_public_config", "$ark_root/bytecode_optimizer:bytecodeopt_public_config", ] bcopt_test_deps = [ "$ark_root/abc2program:abc2program", "$ark_root/assembler:libarkassembler", "$ark_root/bytecode_optimizer:libarkbytecodeopt", "$ark_root/compiler:libarkcompiler", "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", "$ark_root/libziparchive:libarkziparchive", ] test_js_path = "//arkcompiler/runtime_core/bytecode_optimizer/tests/js/" graph_test_js_files = [ "codegenTryCatch", "optimizeTryCatch", ] foreach(file, graph_test_js_files) { es2abc_gen_abc("gen_${file}_abc") { test_js = "${test_js_path}${file}.js" test_abc = "$target_out_dir/${file}.abc" src_js = rebase_path(test_js) dst_file = rebase_path(test_abc) in_puts = [ test_js ] out_puts = [ test_abc ] } } graph_test_js_files_un_opt = [ "bytecodeAnalysis", "constantProgagation", ] foreach(file, graph_test_js_files_un_opt) { es2abc_gen_abc("gen_${file}_abc") { test_js = "${test_js_path}${file}.js" test_abc = "$target_out_dir/${file}.abc" src_js = rebase_path(test_js) dst_file = rebase_path(test_abc) in_puts = [ test_js ] out_puts = [ test_abc ] extra_args = [ "--debug", "--module", "--merge-abc", ] } } host_unittest_action("BytecodeOptimizerTest") { module_out_path = module_output_path sources = [ "analysis_bytecode_test.cpp", "codegen_test.cpp", "constant_propagation_test.cpp", "excluded_keys_test.cpp", "optimize_bytecode_test.cpp", "reg_encoder_test.cpp", ] configs = bcopt_test_config deps = bcopt_test_deps external_deps = [ sdk_libc_secshared_dep ] test_abc_dir = rebase_path(target_out_dir) defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ] foreach(file, graph_test_js_files) { deps += [ ":gen_${file}_abc" ] } foreach(file, graph_test_js_files_un_opt) { deps += [ ":gen_${file}_abc" ] } defines += [ "ARK_INTRINSIC_SET", "ENABLE_BYTECODE_OPT", "PANDA_WITH_ECMASCRIPT", ] } group("host_unittest") { testonly = true deps = [ ":BytecodeOptimizerTestAction" ] }