Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,56 @@
#!/bin/bash
# Copyright 2014-2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ENGINE=$1
function run ()
{
echo "Running test: $1.js"
./tools/perf.sh 5 $ENGINE ./tests/benchmarks/$1.js
./tools/rss-measure.sh $ENGINE ./tests/benchmarks/$1.js
}
echo "Running Sunspider:"
#run jerry/sunspider/3d-morph // too fast
run jerry/sunspider/bitops-3bit-bits-in-byte
run jerry/sunspider/bitops-bits-in-byte
run jerry/sunspider/bitops-bitwise-and
run jerry/sunspider/controlflow-recursive
run jerry/sunspider/math-cordic
run jerry/sunspider/math-partial-sums
run jerry/sunspider/math-spectral-norm
echo "Running Jerry:"
run jerry/cse
run jerry/cse_loop
run jerry/cse_ready_loop
run jerry/empty_loop
run jerry/function_loop
run jerry/loop_arithmetics_10kk
run jerry/loop_arithmetics_1kk
echo "Running UBench:"
run ubench/function-closure
run ubench/function-empty
run ubench/function-correct-args
run ubench/function-excess-args
run ubench/function-missing-args
run ubench/function-sum
run ubench/loop-empty-resolve
run ubench/loop-empty
run ubench/loop-sum

View file

@ -0,0 +1,41 @@
#!/bin/bash
# Copyright 2014-2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
NUM_COMMITS=$1
BENCH=./tests/benchmarks/jerry/loop_arithmetics_1kk.js
TARGET=release.linux
trap ctrl_c INT
function ctrl_c() {
git checkout master >&/dev/null
exit 1
}
commits_to_push=`git log -$NUM_COMMITS | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'`
for commit_hash in $commits_to_push
do
git checkout $commit_hash >&/dev/null
echo -e -n " > Testing...\n > "
echo `git log --format=%B -n 1 $commit_hash`
make -s $TARGET
./tools/rss-measure.sh $TARGET $BENCH
echo
done
git checkout master >&/dev/null

View file

@ -0,0 +1,118 @@
#!/bin/bash
# Copyright 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ENGINE="$1"
PATH_TO_TEST262="$2"
REPORT_PREFIX="report"
RUN_PIDS=""
RESULT_OK=1
TIMEOUT="5s"
if [ $# -lt 2 ]
then
echo "This script performs parallel test262 compliance testing of the specified engine."
echo ""
echo "Usage:"
echo " 1st parameter: JavaScript engine to be tested."
echo " 2nd parameter: path to the directory with official test262 testsuite."
echo " 3rd parameter: (optional) call this script with the '--sub-chapters' flag to print the detailed report."
echo ""
echo "Example:"
echo " ./run-test-suite-test262.sh <engine> <test262_dir> --sub-chapters"
exit 1
fi
rm "${REPORT_PREFIX}".* &> /dev/null
declare -a CHAPTER07_TO_TEST=("7.1" "7.2" "7.3" "7.4" "7.5" "7.6" "7.6.1" "7.7" \
"7.8" "7.8.1" "7.8.2" "7.8.3" "7.8.4" "7.8.5" "7.9" "7.9.2")
declare -a CHAPTER08_TO_TEST=("8.1" "8.2" "8.3" "8.4" "8.5" "8.6" "8.6.1" "8.6.2" "8.7" "8.7.1" "8.7.2" "8.8" "8.12" \
"8.12.1" "8.12.3" "8.12.4" "8.12.5" "8.12.6" "8.12.7" "8.12.8" "8.12.9")
declare -a CHAPTER09_TO_TEST=("9.1" "9.2" "9.3" "9.3.1" "9.4" "9.5" "9.6" "9.7" "9.8" "9.8.1" "9.9")
declare -a CHAPTER10_TO_TEST=("10.1" "10.1.1" "10.2" "10.2.1" "10.2.2" "10.2.3" "10.3" "10.3.1" "10.4" "10.4.1" \
"10.4.2" "10.4.3" "10.5" "10.6")
declare -a CHAPTER11_TO_TEST=("11.1" "11.1.1" "11.1.2" "11.1.3" "11.1.4" "11.1.5" "11.1.6" "11.2" "11.2.1" "11.2.2" \
"11.2.3" "11.2.4" "11.3" "11.3.1" "11.3.2" "11.4" "11.4.1" "11.4.2" "11.4.3" \
"11.4.4" "11.4.5" "11.4.6" "11.4.7" "11.4.8" "11.4.9" "11.5" "11.5.1" "11.5.2" "11.5.3" \
"11.6" "11.6.1" "11.6.2" "11.7" "11.7.1" "11.7.2" "11.7.3" "11.8" "11.8.1" "11.8.2" \
"11.8.3" "11.8.4" "11.8.6" "11.8.7" "11.9" "11.9.1" "11.9.2" "11.9.4" "11.9.5" "11.10" \
"11.11" "11.12" "11.13" "11.13.1" "11.13.2" "11.14")
declare -a CHAPTER12_TO_TEST=("12.1" "12.2" "12.2.1" "12.3" "12.4" "12.5" "12.6" "12.6.1" "12.6.2" "12.6.3" "12.6.4" \
"12.7" "12.8" "12.9" "12.10" "12.10.1" "12.11" "12.12" "12.13" "12.14" "12.14.1")
declare -a CHAPTER13_TO_TEST=("13.1" "13.2" "13.2.1" "13.2.2" "13.2.3")
declare -a CHAPTER14_TO_TEST=("14.1")
declare -a CHAPTER14_TO_TEST=("12.6.4")
declare -a CHAPTER15_TO_TEST=("15.1" "15.1.1" "15.1.2" "15.1.3" "15.1.4" "15.1.5" "15.2" "15.2.1" "15.2.2" "15.2.3" \
"15.2.4" "15.2.5" "15.3" "15.3.1" "15.3.2" "15.3.3" "15.3.4" "15.3.5" "15.4" "15.4.1" \
"15.4.2" "15.4.3" "15.4.4" "15.4.5" "15.5" "15.5.1" "15.5.2" "15.5.3" "15.5.4" "15.5.5" \
"15.6" "15.6.1" "15.6.2" "15.6.3" "15.6.4" "15.6.5" "15.7" "15.7.1" "15.7.2" "15.7.3" \
"15.7.4" "15.7.5" "15.8" "15.8.1" "15.8.2" "15.9" "15.9.1" "15.9.2" "15.9.3" "15.9.4" \
"15.9.5" "15.9.6" "15.10" "15.10.1" "15.10.2" "15.10.3" "15.10.4" "15.10.5" "15.10.6" \
"15.10.7" "15.11" "15.11.1" "15.11.2" "15.11.3" "15.11.4" "15.11.5" "15.11.6" "15.11.7" \
"15.12" "15.12.1" "15.12.2" "15.12.3")
declare -a FULL_CHAPTERS_TO_TEST=("ch06" "ch07" "ch08" "ch09" "ch10" "ch11" "ch12" "ch13" "ch14" "ch15")
declare -a SUB_CHAPTERS_TO_TEST=("${CHAPTER07_TO_TEST[@]}" "${CHAPTER08_TO_TEST[@]}" "${CHAPTER09_TO_TEST[@]}" \
"${CHAPTER10_TO_TEST[@]}" "${CHAPTER11_TO_TEST[@]}" "${CHAPTER12_TO_TEST[@]}" \
"${CHAPTER13_TO_TEST[@]}" "${CHAPTER14_TO_TEST[@]}" "${CHAPTER15_TO_TEST[@]}")
declare -a CHAPTERS_TO_TEST=("${FULL_CHAPTERS_TO_TEST[@]}")
if [[ $* == *--sub-chapters* ]]
then
declare -a CHAPTERS_TO_TEST=("${SUB_CHAPTERS_TO_TEST[@]}")
fi
function run_test262 () {
ARG_ENGINE="$1"
ARG_TEST262_PATH="$2"
ARG_CHAPTER="$3"
"${ARG_TEST262_PATH}"/tools/packaging/test262.py --command "timeout ${TIMEOUT} ${ARG_ENGINE}" \
--tests="${ARG_TEST262_PATH}" --full-summary "${ARG_CHAPTER}" \
> "${REPORT_PREFIX}"."${ARG_CHAPTER}"
}
function show_report_results () {
ARG_CHAPTER="$1"
echo ""
echo "Chapter ${ARG_CHAPTER}:"
grep -A3 "=== Summary ===" "${REPORT_PREFIX}"."${ARG_CHAPTER}"
echo "==============="
}
echo "Starting test262 testing for ${ENGINE}."
for TEST_NAME in "${CHAPTERS_TO_TEST[@]}"
do
run_test262 "${ENGINE}" "${PATH_TO_TEST262}" "$TEST_NAME" &
RUN_PIDS="$RUN_PIDS $!";
done
for RUN_PIDS in $RUN_PIDS
do
wait "$RUN_PIDS" || RESULT_OK=0
done;
#[ $RESULT_OK -eq 1 ] || exit 1
echo "Testing is completed."
for TEST_NAME in "${CHAPTERS_TO_TEST[@]}"
do
echo "$TEST_NAME"
show_report_results "$TEST_NAME"
done

View file

@ -0,0 +1,181 @@
#!/bin/bash
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
# Copyright 2016 University of Szeged
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Usage:
# ./tools/runners/run-test-suite.sh ENGINE TESTS [--snapshot] ENGINE_ARGS....
TIMEOUT=${TIMEOUT:=5}
ENGINE="$1"
shift
TESTS="$1"
shift
OUTPUT_DIR=`dirname $ENGINE`
TESTS_BASENAME=`basename $TESTS`
TEST_FILES=$OUTPUT_DIR/$TESTS_BASENAME.files
TEST_FAILED=$OUTPUT_DIR/$TESTS_BASENAME.failed
TEST_PASSED=$OUTPUT_DIR/$TESTS_BASENAME.passed
if [ "$1" == "--snapshot" ]
then
TEST_FILES="$TEST_FILES.snapshot"
TEST_FAILED="$TEST_FAILED.snapshot"
TEST_PASSED="$TEST_PASSED.snapshot"
IS_SNAPSHOT=true;
shift
fi
ENGINE_ARGS="$@"
if [ ! -x $ENGINE ]
then
echo "$0: $ENGINE: not an executable"
exit 1
fi
if [ -d $TESTS ]
then
TESTS_DIR=$TESTS
( cd $TESTS; find . -name "[^N]*.js" ) | sort > $TEST_FILES
elif [ -f $TESTS ]
then
TESTS_DIR=`dirname $TESTS`
grep -e '.js\s*$' $TESTS | sort > $TEST_FILES
else
echo "$0: $TESTS: not a test suite"
exit 1
fi
total=$(cat $TEST_FILES | wc -l)
if [ "$total" -eq 0 ]
then
echo "$0: $TESTS: no test in test suite"
exit 1
fi
rm -f $TEST_FAILED $TEST_PASSED
ROOT_DIR=""
CURRENT_DIR=`pwd`
PATH_STEP=2
while true
do
TMP_ROOT_DIR=`(echo "$CURRENT_DIR"; echo "$0"; echo "$ENGINE"; echo "$TESTS") | cut -f1-$PATH_STEP -d/ | uniq -d`
if [ -z "$TMP_ROOT_DIR" ]
then
break
else
ROOT_DIR="$TMP_ROOT_DIR"
fi
PATH_STEP=$((PATH_STEP+1))
done
if [ -n "$ROOT_DIR" ]
then
ROOT_DIR="$ROOT_DIR/"
fi
tested=1
failed=0
passed=0
ENGINE_TEMP=`mktemp engine-out.XXXXXXXXXX`
for test in `cat $TEST_FILES`
do
error_code=`echo $test | grep -e "^.\/fail\/[0-9]*\/" -o | cut -d / -f 3`
if [ "$error_code" = "" ]
then
PASS="PASS"
error_code=0
else
PASS="PASS (XFAIL)"
fi
full_test=$TESTS_DIR/${test#./}
if [ "$IS_SNAPSHOT" == true ]
then
# Testing snapshot
SNAPSHOT_TEMP=`mktemp $(basename -s .js $test).snapshot.XXXXXXXXXX`
cmd_line="${ENGINE#$ROOT_DIR} $ENGINE_ARGS --save-snapshot-for-global $SNAPSHOT_TEMP ${full_test#$ROOT_DIR}"
( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS --save-snapshot-for-global $SNAPSHOT_TEMP $full_test &> $ENGINE_TEMP )
status_code=$?
if [ $status_code -eq 0 ]
then
echo "[$tested/$total] $cmd_line: PASS"
cmd_line="${ENGINE#$ROOT_DIR} $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP"
( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP &> $ENGINE_TEMP )
status_code=$?
fi
rm -f $SNAPSHOT_TEMP
else
cmd_line="${ENGINE#$ROOT_DIR} $ENGINE_ARGS ${full_test#$ROOT_DIR}"
( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS $full_test &> $ENGINE_TEMP )
status_code=$?
fi
if [ $status_code -ne $error_code ]
then
echo "[$tested/$total] $cmd_line: FAIL ($status_code)"
cat $ENGINE_TEMP
echo "$status_code: $test" >> $TEST_FAILED
echo "============================================" >> $TEST_FAILED
cat $ENGINE_TEMP >> $TEST_FAILED
echo "============================================" >> $TEST_FAILED
echo >> $TEST_FAILED
echo >> $TEST_FAILED
failed=$((failed+1))
else
echo "[$tested/$total] $cmd_line: $PASS"
echo "$test" >> $TEST_PASSED
passed=$((passed+1))
fi
tested=$((tested+1))
done
rm -f $ENGINE_TEMP
ratio=$(echo $passed*100/$total | bc)
if [ "$IS_SNAPSHOT" == true ]
then
ENGINE_ARGS="--snapshot $ENGINE_ARGS"
fi
echo "[summary] ${ENGINE#$ROOT_DIR} $ENGINE_ARGS ${TESTS#$ROOT_DIR}: $passed PASS, $failed FAIL, $total total, $ratio% success"
if [ $failed -ne 0 ]
then
echo "$0: see $TEST_FAILED for details about failures"
exit 1
fi
exit 0

View file

@ -0,0 +1,80 @@
#!/bin/bash
# Copyright 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TARGET="$1" #debug.linux release.linux
TARGET_IP="$2" # ip address of target board
TARGET_USER="$3" # login
TARGET_PASS="$4" # password
if [ $# -lt 4 ]
then
echo "This script runs ./jerry/* and ./jerry-test-suite/* tests on the remote board."
echo ""
echo "Usage:"
echo " 1st parameter: target to be tested: {debug.linux, release.linux}"
echo " 2nd parameter: ip address of target board: {110.110.110.110}"
echo " 3rd parameter: ssh login to target board: {login}"
echo " 4th parameter: ssh password to target board: {password}"
echo ""
echo "Example:"
echo " ./tools/runners/run-tests-remote.sh debug.linux 110.110.110.110 login password"
exit 1
fi
BASE_DIR=$(dirname "$(readlink -f "$0")" )
OUT_DIR="${BASE_DIR}"/../.././build/bin
LOGS_PATH_FULL="${OUT_DIR}"/"${TARGET}"/check
export SSHPASS="${TARGET_PASS}"
rm -rf "${LOGS_PATH_FULL}"
mkdir -p "${LOGS_PATH_FULL}"
REMOTE_TMP_DIR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp -d')
REMOTE_TMP_TAR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp')
LOCAL_TMP_TAR=$(mktemp)
tar -zcf "${LOCAL_TMP_TAR}" \
"${BASE_DIR}"/../.././build/bin/"${TARGET}" \
"${BASE_DIR}"/../.././tests/benchmarks \
"${BASE_DIR}"/../.././tests/jerry \
"${BASE_DIR}"/../.././tests/jerry-test-suite \
"${BASE_DIR}"/../.././tools/runners \
"${BASE_DIR}"/../.././tools/precommit-full-testing.sh > /dev/null 2>&1
sshpass -e scp "${LOCAL_TMP_TAR}" "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_TAR}"
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" \
"tar -zxf \"${REMOTE_TMP_TAR}\" -C \"${REMOTE_TMP_DIR}\"; rm \"${REMOTE_TMP_TAR}\";\
cd \"${REMOTE_TMP_DIR}\"; \
./tools/precommit-full-testing.sh ./build/bin \"$TARGET\" > ./build/bin/\"${TARGET}\"/check/run.log 2>&1; \
echo \$? > ./build/bin/\"${TARGET}\"/check/IS_TEST_OK"
sshpass -e scp -r "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"/build/bin/"${TARGET}"/check/* "${LOGS_PATH_FULL}"
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "rm -rf \"${REMOTE_TMP_DIR}\""
STATUS=$(cat "${LOGS_PATH_FULL}"/IS_TEST_OK)
if [ "${STATUS}" == 0 ] ; then
echo "${TARGET} testing passed."
exit 0
else
echo "${TARGET} testing failed."
echo "See logs in ${LOGS_PATH_FULL} directory for details."
exit 1
fi

View file

@ -0,0 +1,65 @@
#!/bin/bash
# Copyright 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TARGET_IP="$1"
TARGET_USER="$2"
TARGET_PASS="$3"
if [ $# -lt 3 ]
then
echo "This script runs unittests on the remote board."
echo ""
echo "Usage:"
echo " 1st parameter: ip address of target board: {110.110.110.110}"
echo " 2nd parameter: ssh login to target board: {login}"
echo " 3rd parameter: ssh password to target board: {password}"
echo ""
echo "Example:"
echo " ./tools/runners/run-unittests-remote.sh 110.110.110.110 login password"
exit 1
fi
BASE_DIR=$(dirname "$(readlink -f "$0")" )
OUT_DIR="${BASE_DIR}"/../.././build/bin
rm -rf "${OUT_DIR}"/unittests/check
mkdir -p "${OUT_DIR}"/unittests/check
export SSHPASS="${TARGET_PASS}"
REMOTE_TMP_DIR=$(sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" 'mktemp -d')
sshpass -e scp "${BASE_DIR}"/../../tools/runners/run-unittests.sh "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"
sshpass -e scp -r "${OUT_DIR}"/unittests/* "${TARGET_USER}"@"${TARGET_IP}":"${REMOTE_TMP_DIR}"
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "mkdir -p \"${REMOTE_TMP_DIR}\"/check; \
\"${REMOTE_TMP_DIR}\"/run-unittests.sh \"${REMOTE_TMP_DIR}\"; \
echo \$? > \"${REMOTE_TMP_DIR}\"/check/IS_REMOTE_TEST_OK"
sshpass -e scp -r "${TARGET_USER}"@$"{TARGET_IP}":"${REMOTE_TMP_DIR}"/check "${OUT_DIR}"/unittests
sshpass -e ssh "${TARGET_USER}"@"${TARGET_IP}" "rm -rf \"${REMOTE_TMP_DIR}\""
STATUS=$(cat "${OUT_DIR}"/unittests/check/IS_REMOTE_TEST_OK)
if [ "${STATUS}" == 0 ] ; then
echo "Unit tests run passed."
exit 0
else
echo "Unit tests run failed. See ${OUT_DIR}/unittests/unit_tests_run.log for details."
exit 1
fi

View file

@ -0,0 +1,102 @@
#!/bin/bash
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
# Copyright 2016 University of Szeged
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DIR="$1"
shift
UNITTEST_ERROR=$DIR/unittests.failed
UNITTEST_OK=$DIR/unittests.passed
rm -f $UNITTEST_ERROR $UNITTEST_OK
UNITTESTS=$(ls $DIR/unit-*)
total=$(ls $DIR/unit-* | wc -l)
if [ "$total" -eq 0 ]
then
echo "$0: $DIR: no unit-* test to execute"
exit 1
fi
ROOT_DIR=""
CURRENT_DIR=`pwd`
PATH_STEP=2
while true
do
TMP_ROOT_DIR=`(echo "$CURRENT_DIR"; echo "$0"; echo "$DIR") | cut -f1-$PATH_STEP -d/ | uniq -d`
if [ -z "$TMP_ROOT_DIR" ]
then
break
else
ROOT_DIR="$TMP_ROOT_DIR"
fi
PATH_STEP=$((PATH_STEP+1))
done
if [ -n "$ROOT_DIR" ]
then
ROOT_DIR="$ROOT_DIR/"
fi
tested=1
failed=0
passed=0
UNITTEST_TEMP=`mktemp unittest-out.XXXXXXXXXX`
for unit_test in $UNITTESTS
do
cmd_line="${unit_test#$ROOT_DIR}"
$unit_test &>$UNITTEST_TEMP
status_code=$?
if [ $status_code -ne 0 ]
then
echo "[$tested/$total] $cmd_line: FAIL ($status_code)"
cat $UNITTEST_TEMP
echo "$status_code: $unit_test" >> $UNITTEST_ERROR
echo "============================================" >> $UNITTEST_ERROR
cat $UNITTEST_TEMP >> $UNITTEST_ERROR
echo "============================================" >> $UNITTEST_ERROR
echo >> $UNITTEST_ERROR
echo >> $UNITTEST_ERROR
failed=$((failed+1))
else
echo "[$tested/$total] $cmd_line: PASS"
echo "$unit_test" >> $UNITTEST_OK
passed=$((passed+1))
fi
tested=$((tested+1))
done
rm -f $UNITTEST_TEMP
ratio=$(echo $passed*100/$total | bc)
echo "[summary] ${DIR#$ROOT_DIR}/unit-*: $passed PASS, $failed FAIL, $total total, $ratio% success"
if [ $failed -ne 0 ]
then
echo "$0: see $UNITTEST_ERROR for details about failures"
exit 1
fi
exit 0