3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
19 # Script containing all functions needed for auto testing of test suites
21 echo "Test suite started as: ${BASH_SOURCE[$i+1]} "$1 $2
28 if [ $1 == "local" ] || [ $1 == "remote" ] || [ $1 == "remote-remove" ] ; then
33 if [ $2 == "auto-clean" ]; then
37 if [ $paramError -ne 0 ]; then
38 echo "Expected arg: local|remote|remote-remove [ auto-clean ]"
42 # Set a description string for the test suite
43 if [ -z "$TS_ONELINE_DESCR" ]; then
44 TS_ONELINE_DESCR="<no-description>"
45 echo "No test suite description found, TC_ONELINE_DESCR should be set on in the test script , using "$TS_ONELINE_DESCR
51 ATS=$(basename "${BASH_SOURCE[$i+1]}" .sh)
53 echo "#################################################################################################"
54 echo "################################### Test suite: "$ATS
55 echo "################################### Started: "$(date)
56 echo "#################################################################################################"
57 echo "## Description: " $TS_ONELINE_DESCR
58 echo "#################################################################################################"
60 echo 0 > .tmp_tcsuite_ctr
61 echo 0 > .tmp_tcsuite_pass_ctr
62 echo 0 > .tmp_tcsuite_fail_ctr
63 rm .tmp_tcsuite_pass &> /dev/null
64 touch .tmp_tcsuite_pass
65 rm .tmp_tcsuite_fail &> /dev/null
66 touch .tmp_tcsuite_fail
70 echo ${FUNCNAME[1]} " "$1" " ${BASH_SOURCE[$i+2]} " line" ${BASH_LINENO[$i+1]}
76 elif [ $# -eq 3 ]; then
79 echo -e "Test case \033[31m\033[1m./"$1 $2 $3 "could not be executed.\033[0m"
86 echo "#################################################################################################"
87 echo "################################### Test suite: "$ATS
88 echo "################################### Ended: "$(date)
89 echo "#################################################################################################"
90 echo "## Description: " $TS_ONELINE_DESCR
91 echo "## Execution time: " $((TSTEST_END-TSTEST_START)) " seconds"
92 echo "#################################################################################################"
93 echo "################################### RESULTS"
96 TCSUITE_CTR=$(< .tmp_tcsuite_ctr)
97 TCSUITE_PASS_CTR=$(< .tmp_tcsuite_pass_ctr)
98 TCSUITE_FAIL_CTR=$(< .tmp_tcsuite_fail_ctr)
100 total=$((TCSUITE_PASS_CTR+TCSUITE_FAIL_CTR))
101 if [ $TCSUITE_CTR -eq 0 ]; then
102 echo -e "\033[1mNo test cases seem to have executed. Check the script....\033[0m"
103 elif [ $total != $TCSUITE_CTR ]; then
104 echo -e "\033[1mTotal number of test cases does not match the sum of passed and failed test cases. Check the script....\033[0m"
106 echo "Number of test cases : " $TCSUITE_CTR
107 echo -e "Number of \033[31m\033[1mFAIL\033[0m: " $TCSUITE_FAIL_CTR
108 echo -e "Number of \033[32m\033[1mPASS\033[0m: " $TCSUITE_PASS_CTR
110 echo "PASS test cases"
111 cat .tmp_tcsuite_pass
113 echo "FAIL test cases"
114 cat .tmp_tcsuite_fail
117 echo "################################### Test suite completed ##############################"
118 echo "#################################################################################################"