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_runtime/js_runtime_config.gni") 15import("//arkcompiler/ets_runtime/test/test_helper.gni") 16 17module_output_path = "ets_runtime" 18 19test_js_path = 20 "//arkcompiler/ets_runtime/ecmascript/pgo_profiler/tests/pgo_test_case/" 21 22test_js_files = [ 23 "op_type_test", 24 "class_test", 25 "call_test", 26 "builtins_test", 27 "array_test", 28 "object_literal", 29 "sample_test", 30 "string_equal", 31 "array_size_test", 32 "truck", 33 "vehicle", 34 "typedarray_length", 35 "merge_file_1", 36 "merge_file_2", 37 "merge_file_3", 38] 39 40foreach(file, test_js_files) { 41 es2abc_gen_abc("gen_${file}_abc") { 42 test_js = "${test_js_path}${file}.js" 43 test_abc = "$target_out_dir/${file}.abc" 44 45 # Only targets in this file can depend on this. 46 extra_visibility = [ ":*" ] 47 src_js = rebase_path(test_js) 48 dst_file = rebase_path(test_abc) 49 extra_args = [] 50 extra_args += [ "--module" ] 51 extra_args += [ "--merge-abc" ] 52 in_puts = [ test_js ] 53 out_puts = [ test_abc ] 54 } 55} 56 57host_unittest_action("PGOProfilerTest") { 58 module_out_path = module_output_path 59 60 sources = [ 61 # test file 62 "pgo_profiler_test.cpp", 63 ] 64 65 configs = [ 66 "//arkcompiler/ets_runtime:asm_interp_enable_config", 67 "//arkcompiler/ets_runtime:ecma_test_config", 68 ] 69 70 deps = [ "$js_root:libark_jsruntime_test" ] 71 72 external_deps = [ 73 "icu:shared_icui18n", 74 "icu:shared_icuuc", 75 "runtime_core:libarkassembler_static", 76 ] 77 78 foreach(file, test_js_files) { 79 deps += [ ":gen_${file}_abc" ] 80 } 81 82 if (is_ohos && is_standard_system) { 83 test_abc_dir = "/data/test" 84 } else { 85 test_abc_dir = rebase_path(target_out_dir) 86 } 87 defines = [ "TARGET_ABC_PATH=\"${test_abc_dir}/\"" ] 88 89 # hiviewdfx libraries 90 external_deps += hiviewdfx_ext_deps 91 deps += hiviewdfx_deps 92} 93 94host_unittest_action("PGOProfilerTestOne") { 95 module_out_path = module_output_path 96 97 sources = [ 98 # test file 99 "pgo_profiler_test_one.cpp", 100 ] 101 102 configs = [ 103 "../../../:asm_interp_enable_config", 104 "../../../:ecma_test_config", 105 ] 106 107 deps = [ "$js_root:libark_jsruntime_test" ] 108 109 external_deps = [ 110 "icu:shared_icui18n", 111 "icu:shared_icuuc", 112 "runtime_core:libarkassembler_static", 113 ] 114 115 foreach(file, test_js_files) { 116 deps += [ ":gen_${file}_abc" ] 117 } 118 119 if (is_ohos && is_standard_system) { 120 test_abc_dir = "/data/test" 121 } else { 122 test_abc_dir = rebase_path(target_out_dir) 123 } 124 defines = [ "TARGET_ABC_PATH=\"${test_abc_dir}/\"" ] 125 126 # hiviewdfx libraries 127 external_deps += hiviewdfx_ext_deps 128 deps += hiviewdfx_deps 129} 130 131host_unittest_action("PGOProfilerEncoderTest") { 132 module_out_path = module_output_path 133 134 sources = [ 135 # test file 136 "pgo_profiler_encoder_test.cpp", 137 ] 138 139 configs = [ 140 "../../../:asm_interp_enable_config", 141 "../../../:ecma_test_config", 142 ] 143 144 deps = [ "$js_root:libark_jsruntime_test" ] 145 146 external_deps = [ 147 "icu:shared_icui18n", 148 "icu:shared_icuuc", 149 "runtime_core:libarkassembler_static", 150 ] 151 152 foreach(file, test_js_files) { 153 deps += [ ":gen_${file}_abc" ] 154 } 155 156 if (is_ohos && is_standard_system) { 157 test_abc_dir = "/data/test" 158 } else { 159 test_abc_dir = rebase_path(target_out_dir) 160 } 161 defines = [ "TARGET_ABC_PATH=\"${test_abc_dir}/\"" ] 162 163 # hiviewdfx libraries 164 external_deps += hiviewdfx_ext_deps 165 deps += hiviewdfx_deps 166} 167 168tests = [ 169 "PGOProfilerTest", 170 "PGOProfilerTestOne", 171 "PGOProfilerEncoderTest", 172] 173 174group("unittest") { 175 testonly = true 176 deps = [] 177 foreach(test, tests) { 178 deps += [ ":${test}" ] 179 } 180} 181 182group("host_unittest") { 183 testonly = true 184 deps = [] 185 foreach(test, tests) { 186 deps += [ ":${test}Action" ] 187 } 188 189 if (is_mac) { 190 foreach(test, tests) { 191 deps -= [ ":${test}Action" ] 192 } 193 } 194} 195