mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
8239a5e80f
Description: Currently the typeinfer test compares the gatetypes of gates with the expected types by printing the bytecode name log and gatetype log. In order to pass the tests, it relies on front end keeping the functions and bytecodes' order unchanged. This is inappropriate and does not adapt to the increasing optimization of the front end. Therefore, We need to take a more appropriate solution. We plan to compare gatetypes of gates in Circuit IR and expected types at compile time. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5HSKP Change-Id: Id62a39ec0fc2327ede4e3ee1e770bc65bfc891d4 Signed-off-by: huoqingyi <huoqingyi@huawei.com>
383 lines
11 KiB
Plaintext
383 lines
11 KiB
Plaintext
# Copyright (c) 2021 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("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni")
|
|
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
|
import("//build/ohos.gni")
|
|
import("//build/test.gni")
|
|
|
|
if (is_standard_system) {
|
|
_icu_path_ = "thirdparty/icu"
|
|
} else {
|
|
_icu_path_ = "global/i18n"
|
|
}
|
|
|
|
template("host_unittest_action") {
|
|
_target_name_ = "${target_name}"
|
|
|
|
# unittest for phone running
|
|
ohos_unittest(_target_name_) {
|
|
resource_config_file =
|
|
"//arkcompiler/ets_runtime/test/resource/js_runtime/ohos_test.xml"
|
|
forward_variables_from(invoker, "*")
|
|
}
|
|
|
|
_module_out_path_ = invoker.module_out_path
|
|
|
|
# unittest for host running
|
|
action("${_target_name_}Action") {
|
|
testonly = true
|
|
|
|
_host_test_target_ = ":${_target_name_}(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
|
|
|
|
deps = [ _host_test_target_ ]
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) +
|
|
"/tests/unittest/${_module_out_path_}/${_target_name_}",
|
|
"--expect-output",
|
|
"0",
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) + "/test/test:" +
|
|
rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
"--timeout-limit",
|
|
"1200",
|
|
]
|
|
|
|
inputs = [
|
|
"$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
|
|
]
|
|
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
|
}
|
|
}
|
|
|
|
template("host_moduletest_action") {
|
|
_target_name_ = "${target_name}"
|
|
_deps_ = invoker.deps
|
|
_is_module_ = false
|
|
if (defined(invoker.is_module) && invoker.is_module) {
|
|
_is_module_ = true
|
|
}
|
|
_is_commonjs_ = false
|
|
if (defined(invoker.is_commonjs) && invoker.is_commonjs) {
|
|
_is_commonjs_ = true
|
|
}
|
|
|
|
_test_js_path_ = "./${_target_name_}.js"
|
|
_test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
|
|
_test_expect_path_ = "./expect_output.txt"
|
|
|
|
ts2abc_gen_abc("gen_${_target_name_}_abc") {
|
|
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
|
extra_dependencies = _deps_
|
|
src_js = rebase_path(_test_js_path_)
|
|
dst_file = rebase_path(_test_abc_path_)
|
|
extra_args = [ "--debug" ]
|
|
if (_is_module_) {
|
|
extra_args += [ "--module" ]
|
|
}
|
|
if (_is_commonjs_) {
|
|
extra_args += [ "--commonjs" ]
|
|
}
|
|
|
|
in_puts = [
|
|
_test_js_path_,
|
|
_test_expect_path_,
|
|
]
|
|
out_puts = [ _test_abc_path_ ]
|
|
}
|
|
|
|
_extra_modules_ = []
|
|
if (defined(invoker.extra_modules)) {
|
|
foreach(module, invoker.extra_modules) {
|
|
_extra_modules_ += [ "$target_out_dir/${module}.abc" ]
|
|
}
|
|
}
|
|
_script_args_ = rebase_path(_test_abc_path_)
|
|
foreach(extra_module, _extra_modules_) {
|
|
_script_args_ += ":" + rebase_path(extra_module)
|
|
}
|
|
if (defined(invoker.entry_point)) {
|
|
_script_args_ += " " + invoker.entry_point
|
|
}
|
|
|
|
action("${_target_name_}Action") {
|
|
testonly = true
|
|
|
|
_host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
|
|
deps = [
|
|
":gen_${_target_name_}_abc",
|
|
_host_jsvm_target_,
|
|
]
|
|
deps += _deps_
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
js_vm_options = " --asm-interpreter=false"
|
|
if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
|
|
invoker.is_set_maxNonmovableSpaceCapacity) {
|
|
js_vm_options += " --maxNonmovableSpaceCapacity=524288" # 0.5M
|
|
}
|
|
|
|
if (defined(invoker.is_enable_enableArkTools) &&
|
|
invoker.is_enable_enableArkTools) {
|
|
js_vm_options += " --enable-ark-tools=true"
|
|
}
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_js_vm",
|
|
"--script-options",
|
|
js_vm_options,
|
|
"--script-args",
|
|
_script_args_,
|
|
"--expect-file",
|
|
rebase_path(_test_expect_path_),
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
|
"/${_icu_path_}:" + rebase_path(_root_out_dir_) +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
]
|
|
|
|
inputs = [ _test_abc_path_ ]
|
|
inputs += _extra_modules_
|
|
|
|
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
|
}
|
|
|
|
action("${_target_name_}AsmAction") {
|
|
testonly = true
|
|
|
|
_host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
|
|
deps = [
|
|
":gen_${_target_name_}_abc",
|
|
_host_jsvm_target_,
|
|
]
|
|
deps += _deps_
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
_asm_run_options_ = " --asm-interpreter=true"
|
|
if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
|
|
invoker.is_set_maxNonmovableSpaceCapacity) {
|
|
_asm_run_options_ += " --maxNonmovableSpaceCapacity=524288" # 0.5M
|
|
}
|
|
|
|
if (defined(invoker.is_enable_enableArkTools) &&
|
|
invoker.is_enable_enableArkTools) {
|
|
_asm_run_options_ += " --enable-ark-tools=true"
|
|
}
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_js_vm",
|
|
"--script-options",
|
|
_asm_run_options_,
|
|
"--script-args",
|
|
_script_args_,
|
|
"--expect-file",
|
|
rebase_path(_test_expect_path_),
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
|
"/${_icu_path_}:" + rebase_path(_root_out_dir_) +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
]
|
|
|
|
inputs = [ _test_abc_path_ ]
|
|
inputs += _extra_modules_
|
|
|
|
outputs = [ "$target_out_dir/${_target_name_}Asm/" ]
|
|
}
|
|
}
|
|
|
|
template("host_aot_test_action") {
|
|
_target_name_ = "${target_name}"
|
|
_deps_ = invoker.deps
|
|
|
|
_test_ts_path_ = "./${_target_name_}.ts"
|
|
_test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
|
|
_test_m_path_ = "$target_out_dir/${_target_name_}.m"
|
|
_test_snapshot_path_ = "$target_out_dir/snapshot"
|
|
_test_expect_path_ = "./expect_output.txt"
|
|
|
|
ts2abc_gen_abc("gen_${_target_name_}_abc") {
|
|
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
|
extra_dependencies = _deps_
|
|
src_js = rebase_path(_test_ts_path_)
|
|
dst_file = rebase_path(_test_abc_path_)
|
|
extra_args = []
|
|
|
|
in_puts = [
|
|
_test_ts_path_,
|
|
_test_expect_path_,
|
|
]
|
|
out_puts = [ _test_abc_path_ ]
|
|
}
|
|
|
|
_script_args_ = rebase_path(_test_abc_path_)
|
|
|
|
action("${_target_name_}AotCompileAction") {
|
|
testonly = true
|
|
|
|
_host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
|
|
deps = [
|
|
":gen_${_target_name_}_abc",
|
|
_host_aot_target_,
|
|
]
|
|
deps += _deps_
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
_aot_compile_options_ =
|
|
" --aot-file=" + rebase_path(_test_m_path_) +
|
|
" --snapshot-output-file=" + rebase_path(_test_snapshot_path_)
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_aot_compiler",
|
|
"--script-options",
|
|
_aot_compile_options_,
|
|
"--script-args",
|
|
_script_args_,
|
|
"--expect-sub-output",
|
|
"ts aot compile success",
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
|
"/${_icu_path_}:" +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
]
|
|
|
|
inputs = [ _test_abc_path_ ]
|
|
|
|
outputs = [
|
|
_test_m_path_,
|
|
_test_snapshot_path_,
|
|
]
|
|
}
|
|
|
|
action("${_target_name_}AotAction") {
|
|
testonly = true
|
|
|
|
_host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
|
|
|
|
deps = [
|
|
":${_target_name_}AotCompileAction",
|
|
":gen_${_target_name_}_abc",
|
|
_host_jsvm_target_,
|
|
]
|
|
deps += _deps_
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
_aot_run_options_ =
|
|
" --aot-file=" + rebase_path(_test_m_path_) +
|
|
" --snapshot-output-file=" + rebase_path(_test_snapshot_path_) +
|
|
" --asm-interpreter=true"
|
|
|
|
if (defined(invoker.is_enable_enableArkTools) &&
|
|
invoker.is_enable_enableArkTools) {
|
|
_aot_run_options_ += " --enable-ark-tools=true"
|
|
}
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_js_vm",
|
|
"--script-options",
|
|
_aot_run_options_,
|
|
"--script-args",
|
|
_script_args_,
|
|
"--expect-file",
|
|
rebase_path(_test_expect_path_),
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
|
"/${_icu_path_}:" +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
]
|
|
|
|
inputs = [ _test_abc_path_ ]
|
|
|
|
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
|
}
|
|
}
|
|
|
|
template("host_typeinfer_test_action") {
|
|
_target_name_ = "${target_name}"
|
|
_deps_ = invoker.deps
|
|
|
|
_test_ts_path_ = "./${_target_name_}.ts"
|
|
_test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
|
|
|
|
ts2abc_gen_abc("gen_${_target_name_}_abc") {
|
|
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
|
extra_dependencies = _deps_
|
|
src_js = rebase_path(_test_ts_path_)
|
|
dst_file = rebase_path(_test_abc_path_)
|
|
extra_args = [ "--debug" ]
|
|
|
|
in_puts = [ _test_ts_path_ ]
|
|
out_puts = [ _test_abc_path_ ]
|
|
}
|
|
|
|
_script_args_ = rebase_path(_test_abc_path_)
|
|
|
|
action("${_target_name_}AotTypeInferAction") {
|
|
testonly = true
|
|
|
|
_host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
|
|
_root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
|
|
deps = [
|
|
":gen_${_target_name_}_abc",
|
|
_host_aot_target_,
|
|
]
|
|
deps += _deps_
|
|
|
|
script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
|
|
|
|
_aot_compile_options_ = " --typeinfer-verify=true"
|
|
|
|
args = [
|
|
"--script-file",
|
|
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_aot_compiler",
|
|
"--script-options",
|
|
_aot_compile_options_,
|
|
"--script-args",
|
|
_script_args_,
|
|
"--expect-output",
|
|
"0",
|
|
"--env-path",
|
|
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
|
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
|
"/${_icu_path_}:" +
|
|
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
|
]
|
|
|
|
inputs = [ _test_abc_path_ ]
|
|
|
|
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
|
}
|
|
}
|