1# Copyright (c) 2021 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 17test_js_path = "//arkcompiler/ets_runtime/ecmascript/napi/test/js/" 18 19test_js_files = [ 20 "termination_1", 21 "termination_2", 22 "termination_3", 23 "termination", 24] 25 26foreach(file, test_js_files) { 27 es2abc_gen_abc("gen_${file}_abc") { 28 test_js = "${test_js_path}${file}.js" 29 test_abc = "$target_out_dir/${file}.abc" 30 31 # Only targets in this file can depend on this. 32 extra_visibility = [ ":*" ] 33 src_js = rebase_path(test_js) 34 dst_file = rebase_path(test_abc) 35 extra_args = [] 36 extra_args += [ "--module" ] 37 extra_args += [ "--merge-abc" ] 38 in_puts = [ test_js ] 39 out_puts = [ test_abc ] 40 } 41} 42 43module_output_path = "ets_runtime" 44 45host_unittest_action("Jsnapi_001_Test") { 46 module_out_path = module_output_path 47 48 sources = [ 49 # test file 50 "dfx_jsnapi_tests.cpp", 51 ] 52 53 configs = [ "../../../:ecma_test_config" ] 54 55 deps = [ 56 "$ark_third_party_root/icu/icu4c:shared_icui18n", 57 "$ark_third_party_root/icu/icu4c:shared_icuuc", 58 "$js_root:libark_jsruntime_test", 59 ] 60 61 foreach(file, test_js_files) { 62 deps += [ ":gen_${file}_abc" ] 63 } 64 65 # hiviewdfx libraries 66 external_deps = hiviewdfx_ext_deps 67 deps += hiviewdfx_deps 68 external_deps += [ "zlib:libz" ] 69} 70 71host_unittest_action("Jsnapi_002_Test") { 72 module_out_path = module_output_path 73 74 sources = [ 75 # test file 76 "jsnapi_first_tests.cpp", 77 ] 78 79 configs = [ "../../../:ecma_test_config" ] 80 81 deps = [ 82 "$ark_third_party_root/icu/icu4c:shared_icui18n", 83 "$ark_third_party_root/icu/icu4c:shared_icuuc", 84 "$js_root:libark_jsruntime_test", 85 ] 86 87 foreach(file, test_js_files) { 88 deps += [ ":gen_${file}_abc" ] 89 } 90 91 # hiviewdfx libraries 92 external_deps = hiviewdfx_ext_deps 93 external_deps += [ "zlib:libz" ] 94 deps += hiviewdfx_deps 95} 96 97host_unittest_action("Jsnapi_003_Test") { 98 module_out_path = module_output_path 99 100 sources = [ 101 # test file 102 "jsnapi_second_tests.cpp", 103 ] 104 105 configs = [ "../../../:ecma_test_config" ] 106 107 deps = [ 108 "$ark_third_party_root/icu/icu4c:shared_icui18n", 109 "$ark_third_party_root/icu/icu4c:shared_icuuc", 110 "$js_root:libark_jsruntime_test", 111 ] 112 113 foreach(file, test_js_files) { 114 deps += [ ":gen_${file}_abc" ] 115 } 116 117 # hiviewdfx libraries 118 external_deps = hiviewdfx_ext_deps 119 external_deps += [ "zlib:libz" ] 120 deps += hiviewdfx_deps 121} 122 123host_unittest_action("Jsnapi_004_Test") { 124 module_out_path = module_output_path 125 126 sources = [ 127 # test file 128 "jsnapi_third_tests.cpp", 129 ] 130 131 configs = [ "../../../:ecma_test_config" ] 132 133 deps = [ 134 "$ark_third_party_root/icu/icu4c:shared_icui18n", 135 "$ark_third_party_root/icu/icu4c:shared_icuuc", 136 "$js_root:libark_jsruntime_test", 137 ] 138 139 foreach(file, test_js_files) { 140 deps += [ ":gen_${file}_abc" ] 141 } 142 143 # hiviewdfx libraries 144 external_deps = hiviewdfx_ext_deps 145 external_deps += [ "zlib:libz" ] 146 deps += hiviewdfx_deps 147} 148 149host_unittest_action("Jsnapi_Sendable_Test") { 150 module_out_path = module_output_path 151 152 sources = [ "jsnapi_sendable_tests.cpp" ] 153 154 configs = [ "../../../:ecma_test_config" ] 155 156 deps = [ 157 "$ark_third_party_root/icu/icu4c:shared_icui18n", 158 "$ark_third_party_root/icu/icu4c:shared_icuuc", 159 "$js_root:libark_jsruntime_test", 160 ] 161 162 foreach(file, test_js_files) { 163 deps += [ ":gen_${file}_abc" ] 164 } 165 166 external_deps = hiviewdfx_ext_deps 167 deps += hiviewdfx_deps 168} 169 170host_unittest_action("FFIWorkLoadTest") { 171 module_out_path = module_output_path 172 173 sources = [ 174 # test file 175 "ffi_workload.cpp", 176 ] 177 178 configs = [ "$js_root:ecma_test_config" ] 179 180 deps = [ 181 "$ark_third_party_root/icu/icu4c:shared_icui18n", 182 "$ark_third_party_root/icu/icu4c:shared_icuuc", 183 "$js_root:libark_jsruntime_test", 184 ] 185 186 # hiviewdfx libraries 187 external_deps = hiviewdfx_ext_deps 188 deps += hiviewdfx_deps 189} 190 191host_unittest_action("JsnapiSample") { 192 module_out_path = module_output_path 193 194 sources = [ "jsnapi_sample.cpp" ] 195 196 configs = [ 197 "$js_root:ecma_test_config", 198 "$ark_root/assembler:arkassembler_public_config", 199 ] 200 201 deps = [ 202 "$ark_root/assembler:libarkassembler_static", 203 "$ark_third_party_root/icu/icu4c:shared_icui18n", 204 "$ark_third_party_root/icu/icu4c:shared_icuuc", 205 "$js_root:libark_jsruntime_test", 206 ] 207 208 # hiviewdfx libraries 209 external_deps = hiviewdfx_ext_deps 210 deps += hiviewdfx_deps 211} 212 213group("unittest") { 214 testonly = true 215 deps = [ 216 ":JsnapiSample", 217 ":Jsnapi_001_Test", 218 ":Jsnapi_002_Test", 219 ":Jsnapi_003_Test", 220 ":Jsnapi_004_Test", 221 ":Jsnapi_Sendable_Test", 222 ] 223} 224 225group("host_unittest") { 226 testonly = true 227 deps = [ 228 ":Jsnapi_001_TestAction", 229 ":Jsnapi_002_TestAction", 230 ":Jsnapi_003_TestAction", 231 ":Jsnapi_004_TestAction", 232 ":Jsnapi_Sendable_TestAction", 233 ] 234 235 if (is_mac) { 236 deps -= [ 237 ":Jsnapi_001_TestAction", 238 ":Jsnapi_002_TestAction", 239 ":Jsnapi_003_TestAction", 240 ":Jsnapi_004_TestAction", 241 ":Jsnapi_Sendable_TestAction", 242 ] 243 } 244} 245 246group("workload_test") { 247 testonly = true 248 deps = [ ":FFIWorkLoadTest" ] 249} 250