1# Copyright (c) 2021-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 14# target to test compilation issue on arm32 platforms 15# see issue https://gitee.com/openharmony-sig/arkcompiler_ets_frontend/issues/I84VFY 16if (PANDA_TARGET_ARM32) 17 add_custom_target(ets_tests_arm32_punctuator_any_equal 18 COMMAND ${PANDA_ROOT}/tests/tests-u-runner/runner.sh 19 ${PANDA_ROOT} 20 --build-dir ${PANDA_BINARY_ROOT} 21 --arm32-qemu 22 --ets-runtime 23 --test-file PunctuatorAnyEqual.ets 24 ) 25endif() 26 27# ignore ARM32 because some files (not gnueabi or gnueabihf) are incompatible with 32x processors 28# this will be fixed in the future 29if(PANDA_TARGET_ARM32 OR PANDA_ARM64_TESTS_WITH_SANITIZER) 30 return() 31endif() 32 33if(NOT DEFINED ES2PANDA_REGRESSION_TESTS_GROUPS) 34 set(ES2PANDA_REGRESSION_TESTS_GROUPS 32) 35endif() 36 37add_custom_target(es2panda_tests COMMENT "Running es2panda test suites") 38 39if(PANDA_WITH_ETS) 40 set(ETS_RESULT_FOLDER ${CMAKE_BINARY_DIR}/tests/es2panda-regression-tests) 41 set(OPTIONS --parser 42 --processes=1 43 --build-dir ${PANDA_BINARY_ROOT} 44 --groups ${ES2PANDA_REGRESSION_TESTS_GROUPS}) 45 46 if(PANDA_TARGET_ARM64) 47 set(OPTIONS --test-list-arch=arm64 ${OPTIONS}) 48 if(PANDA_QEMU_BUILD) 49 set(OPTIONS --arm64-qemu ${OPTIONS}) 50 endif() 51 endif() 52 53 if(PANDA_TARGET_ARM32) 54 set(OPTIONS --test-list-arch=arm32 ${OPTIONS}) 55 if(PANDA_QEMU_BUILD) 56 set(OPTIONS --arm32-qemu ${OPTIONS}) 57 endif() 58 endif() 59 60 if(NOT PANDA_WITH_ECMASCRIPT) 61 set(OPTIONS --no-js ${OPTIONS}) 62 endif() 63 64 add_custom_target(es2panda-regression-tests COMMENT "Running es2panda-regression-tests test suites") 65 foreach(CURRENT_GROUP RANGE 1 ${ES2PANDA_REGRESSION_TESTS_GROUPS}) 66 add_custom_target(es2panda-regression-tests-${CURRENT_GROUP} 67 DEPENDS ark es2panda verifier 68 WORKING_DIRECTORY ${PANDA_ROOT} 69 COMMAND ${PANDA_ROOT}/tests/tests-u-runner/runner.sh 70 ${PANDA_ROOT} 71 ${OPTIONS} 72 --work-dir=${ETS_RESULT_FOLDER}/group-${CURRENT_GROUP} 73 --group-number ${CURRENT_GROUP} 74 ) 75 add_dependencies(es2panda-regression-tests es2panda-regression-tests-${CURRENT_GROUP}) 76 endforeach() 77 78 panda_add_gtest( 79 NAME es2panda_public_test 80 SOURCES 81 unit/public/es2panda_public_test.cpp 82 LIBRARIES 83 es2panda-public es2panda-lib arkassembler arkbytecodeopt 84 INCLUDE_DIRS 85 ${ES2PANDA_ROOT} 86 SANITIZERS 87 ${PANDA_SANITIZERS_LIST} 88 ) 89 90 panda_add_library(e2p_test_plugin SHARED unit/public/e2p_test_plugin.c) 91 panda_target_include_directories(e2p_test_plugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..") 92 panda_target_link_libraries(e2p_test_plugin es2panda-public) 93 94 add_custom_target(es2panda-plugin-test 95 COMMENT "Test es2panda plugin functionality" 96 COMMAND ${CMAKE_COMMAND} -E env 97 LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> --plugins=e2p_test_plugin 98 "${CMAKE_CURRENT_SOURCE_DIR}/unit/public/t.ets" > "${CMAKE_CURRENT_BINARY_DIR}/plugin_test.out" 99 COMMAND ${CMAKE_COMMAND} -E compare_files 100 "${CMAKE_CURRENT_BINARY_DIR}/plugin_test.out" "${CMAKE_CURRENT_SOURCE_DIR}/unit/public/plugin_test.expected.txt" 101 ) 102 add_dependencies(es2panda-plugin-test es2panda e2p_test_plugin) 103 add_dependencies(es2panda_tests es2panda-plugin-test) 104 105 if(NOT CMAKE_CROSSCOMPILING OR NOT PANDA_TARGET_ARM64 OR PANDA_CI_TESTING_MODE STREQUAL "Nightly") 106 add_dependencies(es2panda_tests es2panda-regression-tests) 107 endif() 108 109 if(TARGET ets_tests) 110 add_dependencies(ets_tests es2panda_tests) 111 endif() 112 113 panda_add_gtest( 114 NAME es2panda_astverifier_tests 115 SOURCES 116 unit/public/ast_verifier_test.cpp 117 LIBRARIES 118 es2panda-public es2panda-lib 119 INCLUDE_DIRS 120 ${ES2PANDA_PATH} 121 ${ES2PANDA_BINARY_ROOT} 122 SANITIZERS 123 ${PANDA_SANITIZERS_LIST} 124 ) 125 126 if(PANDA_WITH_ETS) 127 panda_add_gtest( 128 NAME scopes_initialization_test 129 SOURCES 130 unit/lowerings/scopes_initialization.cpp 131 LIBRARIES 132 es2panda-lib es2panda-public arkassembler arkbytecodeopt 133 INCLUDE_DIRS 134 ${ES2PANDA_PATH} 135 ${OUTPUT_DIR} 136 137 SANITIZERS 138 ${PANDA_SANITIZERS_LIST} 139 ) 140 panda_add_gtest( 141 NAME es2panda_checker_tests 142 SOURCES 143 unit/checker_test.cpp 144 LIBRARIES 145 es2panda-public es2panda-lib 146 INCLUDE_DIRS 147 ${ES2PANDA_ROOT} 148 SANITIZERS 149 ${PANDA_SANITIZERS_LIST} 150 ) 151 152 endif() 153 154 panda_add_gtest( 155 NAME es2panda_astdumper_tests 156 SOURCES 157 unit/ast_dumper_test.cpp 158 LIBRARIES 159 es2panda-public es2panda-lib arkassembler arkbytecodeopt 160 INCLUDE_DIRS 161 ${ES2PANDA_PATH} 162 SANITIZERS 163 ${PANDA_SANITIZERS_LIST} 164 ) 165 166 panda_add_gtest( 167 NAME es2panda_union_normalization_tests 168 SOURCES 169 unit/union_normalization_test.cpp 170 LIBRARIES 171 es2panda-public es2panda-lib arkassembler arkbytecodeopt 172 INCLUDE_DIRS 173 ${ES2PANDA_PATH} 174 ${ES2PANDA_BINARY_ROOT} 175 SANITIZERS 176 ${PANDA_SANITIZERS_LIST} 177 ) 178 179 add_subdirectory(tsconfig) 180endif() 181 182add_subdirectory(options) 183