1425bb815Sopenharmony_ci#!/bin/bash 2425bb815Sopenharmony_ci 3425bb815Sopenharmony_ci# Copyright JS Foundation and other contributors, http://js.foundation 4425bb815Sopenharmony_ci# 5425bb815Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 6425bb815Sopenharmony_ci# you may not use this file except in compliance with the License. 7425bb815Sopenharmony_ci# You may obtain a copy of the License at 8425bb815Sopenharmony_ci# 9425bb815Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10425bb815Sopenharmony_ci# 11425bb815Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12425bb815Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS 13425bb815Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14425bb815Sopenharmony_ci# See the License for the specific language governing permissions and 15425bb815Sopenharmony_ci# limitations under the License. 16425bb815Sopenharmony_ci 17425bb815Sopenharmony_ciJERRY=$1 18425bb815Sopenharmony_ciCHANNEL=$2 19425bb815Sopenharmony_ciDEBUGGER_CLIENT=$3 20425bb815Sopenharmony_ciTEST_CASE=$4 21425bb815Sopenharmony_ciCLIENT_ARGS="" 22425bb815Sopenharmony_ci 23425bb815Sopenharmony_ciTERM_NORMAL='\033[0m' 24425bb815Sopenharmony_ciTERM_RED='\033[1;31m' 25425bb815Sopenharmony_ciTERM_GREEN='\033[1;32m' 26425bb815Sopenharmony_ci 27425bb815Sopenharmony_ciif [[ $TEST_CASE == *"client_source"* ]]; then 28425bb815Sopenharmony_ci START_DEBUG_SERVER="${JERRY} --start-debug-server --debug-channel ${CHANNEL} --debugger-wait-source &" 29425bb815Sopenharmony_ci if [[ $TEST_CASE == *"client_source_multiple"* ]]; then 30425bb815Sopenharmony_ci CLIENT_ARGS="--client-source ${TEST_CASE}_2.js ${TEST_CASE}_1.js" 31425bb815Sopenharmony_ci else 32425bb815Sopenharmony_ci CLIENT_ARGS="--client-source ${TEST_CASE}.js" 33425bb815Sopenharmony_ci fi 34425bb815Sopenharmony_cielse 35425bb815Sopenharmony_ci START_DEBUG_SERVER="${JERRY} ${TEST_CASE}.js --start-debug-server --debug-channel ${CHANNEL} &" 36425bb815Sopenharmony_cifi 37425bb815Sopenharmony_ci 38425bb815Sopenharmony_ciecho "$START_DEBUG_SERVER" 39425bb815Sopenharmony_cieval "$START_DEBUG_SERVER" 40425bb815Sopenharmony_cisleep 1s 41425bb815Sopenharmony_ci 42425bb815Sopenharmony_ciRESULT_TEMP=`mktemp ${TEST_CASE}.out.XXXXXXXXXX` 43425bb815Sopenharmony_ci 44425bb815Sopenharmony_ci(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --channel ${CHANNEL} --non-interactive ${CLIENT_ARGS}) >${RESULT_TEMP} 2>&1 45425bb815Sopenharmony_ci 46425bb815Sopenharmony_ciif [[ $TEST_CASE == *"restart"* ]]; then 47425bb815Sopenharmony_ci CONTINUE_CASE=$(sed "s/restart/continue/g" <<< "$TEST_CASE") 48425bb815Sopenharmony_ci (cat "${CONTINUE_CASE}.cmd" | ${DEBUGGER_CLIENT} --channel ${CHANNEL} --non-interactive ${CLIENT_ARGS}) >>${RESULT_TEMP} 2>&1 49425bb815Sopenharmony_cifi 50425bb815Sopenharmony_ci 51425bb815Sopenharmony_cidiff -U0 ${TEST_CASE}.expected ${RESULT_TEMP} 52425bb815Sopenharmony_ciSTATUS_CODE=$? 53425bb815Sopenharmony_ci 54425bb815Sopenharmony_cirm -f ${RESULT_TEMP} 55425bb815Sopenharmony_ci 56425bb815Sopenharmony_ciif [ ${STATUS_CODE} -ne 0 ] 57425bb815Sopenharmony_cithen 58425bb815Sopenharmony_ci echo -e "${TERM_RED}FAIL: ${TEST_CASE}${TERM_NORMAL}\n" 59425bb815Sopenharmony_cielse 60425bb815Sopenharmony_ci echo -e "${TERM_GREEN}PASS: ${TEST_CASE}${TERM_NORMAL}\n" 61425bb815Sopenharmony_cifi 62425bb815Sopenharmony_ci 63425bb815Sopenharmony_ciexit ${STATUS_CODE} 64