4 # @author MyungJoo Ham <myungjoo.ham@gmail.com>
7 # @brief This is API set for SSAT (Shell Script Automated Tester)
10 if [[ "$nocolor" != "1" ]]
17 LightGreen='\033[1;32m'
21 LightBlue='\033[1;34m'
23 LightPurple='\033[1;35m'
25 LightCyan='\033[1;36m'
26 LightGray='\033[0;37m'
53 ResultLog="$ResultLog$1\n"
57 # @brief Report results of a test group (a "runTest.sh" in a testee directory)
60 if (( ${_fail} == 0 ))
62 writef "${Green}==================================================${NC}"
63 writef "${LightGreen}[PASSED]${NC} Test Group ${Green}Passed${NC}"
65 if (( ${_criticalFail} > 0 ))
67 writef "${Green}==================================================${NC}"
68 writef "${Red}[FAILED]${NC} Test Group has ${Red}failed cases ($_fail)${NC}"
70 writef "${Green}==================================================${NC}"
71 writef "${LightGreen}[PASSED]${NC} Test Group has ${Red}failed cases ($_fail), but they are not critical.${NC}"
75 writef "${_cases}/${_pass}/${_fail}"
77 echo "${ResultLog}" > $_filename
80 if (( ${_criticalFail} > 0 ))
97 # @brief Write Test Log
98 # @param $1 1 = success / 0 = fail
99 # @param $2 test case ID (short string)
100 # @param $3 test case description
101 # @param $4 set 1 if this is not critical (don't care if it's pass or fail)_
102 function testResult {
104 if [[ "${1}" == "1" ]]
106 writef "${LightGreen}[PASSED]${NC} ${Green}$2${NC}:$3${NC}"
110 if [[ "${4}" == "1" ]]
112 writef "${Purple}[FAILED][Ignorable] $2${NC}:${Purple}$3${NC}"
114 writef "${Red}[FAILED][Critical] $2${NC}:${Purple}$3${NC}"
115 _criticalFail=$((_criticalFail+1))
121 # @brief Call Test Case (a shell script), expected exit = 0
122 # @param $1 Full path to the executable (e.g., ~/script/a1.sh)
123 # @param $2 Full string of the arguments to $1 (e.g., "-q -n --dryrun")
124 # @param $3 test case ID
125 # @param $4 test case description
126 # @param $5 set 1 if this is not critical (don't care if it's pass or fail)_
127 function callTestSuccess {
132 # @brief Call Test Case (a shell script), expected exit != 0
133 # @param $1 Full path to the executable (e.g., ~/script/a1.sh)
134 # @param $2 Full string of the arguments to $1 (e.g., "-q -n --dryrun")
135 # @param $3 test case ID
136 # @param $4 test case description
137 # @param $5 set 1 if this is not critical (don't care if it's pass or fail)_
138 function callTestFail {
143 # @brief Call Test Case (a shell script), expected exit == $5
144 # @param $1 Full path to the executable (e.g., ~/script/a1.sh)
145 # @param $2 Full string of the arguments to $1 (e.g., "-q -n --dryrun")
146 # @param $3 test case ID
147 # @param $4 test case description
148 # @param $5 Expected exit code.
149 # @param $6 set 1 if this is not critical (don't care if it's pass or fail)_
150 function callTestExitEq {
155 # @brief Compare two result files expected to be equal
156 # @param $1 Path to result 1 (golden)
157 # @param $2 Path to result 2 (test run)
158 # @param $3 test case ID
159 # @param $4 test case description
160 # @param $5 0 if the size is expected to be equal as well. 1 if golden (result 1) might be smaller (will ignore rest of result 2). 2 if the opposite of 1. If $5 > 2, it denotes the max size of compared bytes. (compare the first $5 bytes only)
161 # @param $6 set 1 if this is not critical (don't care if it's pass or fail)_
162 function callCompareTest {