• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright JS Foundation and other contributors, http://js.foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17JERRY=$1
18CHANNEL=$2
19DEBUGGER_CLIENT=$3
20TEST_CASE=$4
21CLIENT_ARGS=""
22
23TERM_NORMAL='\033[0m'
24TERM_RED='\033[1;31m'
25TERM_GREEN='\033[1;32m'
26
27if [[ $TEST_CASE == *"client_source"* ]]; then
28  START_DEBUG_SERVER="${JERRY} --start-debug-server --debug-channel ${CHANNEL} --debugger-wait-source &"
29  if [[ $TEST_CASE == *"client_source_multiple"* ]]; then
30    CLIENT_ARGS="--client-source ${TEST_CASE}_2.js ${TEST_CASE}_1.js"
31  else
32    CLIENT_ARGS="--client-source ${TEST_CASE}.js"
33  fi
34else
35  START_DEBUG_SERVER="${JERRY} ${TEST_CASE}.js --start-debug-server --debug-channel ${CHANNEL} &"
36fi
37
38echo "$START_DEBUG_SERVER"
39eval "$START_DEBUG_SERVER"
40sleep 1s
41
42RESULT_TEMP=`mktemp ${TEST_CASE}.out.XXXXXXXXXX`
43
44(cat "${TEST_CASE}.cmd" | ${DEBUGGER_CLIENT} --channel ${CHANNEL} --non-interactive ${CLIENT_ARGS}) >${RESULT_TEMP} 2>&1
45
46if [[ $TEST_CASE == *"restart"* ]]; then
47  CONTINUE_CASE=$(sed "s/restart/continue/g" <<< "$TEST_CASE")
48  (cat "${CONTINUE_CASE}.cmd" | ${DEBUGGER_CLIENT} --channel ${CHANNEL} --non-interactive ${CLIENT_ARGS}) >>${RESULT_TEMP} 2>&1
49fi
50
51diff -U0 ${TEST_CASE}.expected ${RESULT_TEMP}
52STATUS_CODE=$?
53
54rm -f ${RESULT_TEMP}
55
56if [ ${STATUS_CODE} -ne 0 ]
57then
58  echo -e "${TERM_RED}FAIL: ${TEST_CASE}${TERM_NORMAL}\n"
59else
60  echo -e "${TERM_GREEN}PASS: ${TEST_CASE}${TERM_NORMAL}\n"
61fi
62
63exit ${STATUS_CODE}
64