Fix bugs of handling multiple test groups.
Added "create template" for easy test group creation.
TODO: need to support "PATH" searching
Signed-off-by: MyungJoo Ham <myungjoo.ham@gmail.com>
if [[ "$SSATAPILOADED" != "1" ]]
then
- echo "Not Loaded"
SILENT=0
+ INDEPENDENT=1
search="ssat-api.sh"
source $search
count=$((count+1))
if (( ${count} > 5 ))
then
- break
+ echo "Cannot find ssat-api.sh"
+ exit 1
fi
search="../${search}"
source $search
retcode=$?
done
+ printf "${Blue}Independent Mode${NC}\n"
fi
-testInit
+testInit $1
testResult 1 T1 "Dummy Test 1"
testResult 1 T2 "Dummy Test 2"
--- /dev/null
+#!/usr/bin/env bash
+
+if [[ "$SSATAPILOADED" != "1" ]]
+then
+ SILENT=0
+ INDEPENDENT=1
+ search="ssat-api.sh"
+ source $search
+
+ retcode=$?
+ count=0
+ while (( ${retcode} != 0 ))
+ do
+ count=$((count+1))
+ if (( ${count} > 5 ))
+ then
+ echo "Cannot find ssat-api.sh"
+ exit 1
+ fi
+
+ search="../${search}"
+ source $search
+ retcode=$?
+ done
+ printf "${Blue}Independent Mode${NC}\n"
+fi
+
+testInit $1
+
+testResult 1 TA "Dummy Test A"
+testResult 1 TB "Dummy Test B"
+
+report
if (( ${_fail} == 0 ))
then
writef "${Green}==================================================${NC}"
- writef "${LightGreen}[PASSED]${NC} Test Group ${Green}Passed${NC}"
+ writef "${LightGreen}[PASSED]${NC} Test Group $_group ${Green}Passed${NC}"
else
if (( ${_criticalFail} > 0 ))
then
writef "${Green}==================================================${NC}"
- writef "${Red}[FAILED]${NC} Test Group has ${Red}failed cases ($_fail)${NC}"
+ writef "${Red}[FAILED]${NC} Test Group $_group has ${Red}failed cases ($_fail)${NC}"
else
writef "${Green}==================================================${NC}"
- writef "${LightGreen}[PASSED]${NC} Test Group has ${Red}failed cases ($_fail), but they are not critical.${NC}"
+ writef "${LightGreen}[PASSED]${NC} Test Group $_group has ${Red}failed cases ($_fail), but they are not critical.${NC}"
fi
fi
- writef "${_cases}/${_pass}/${_fail}"
-
- echo "${ResultLog}" > $_filename
- printf "$_filename\n"
+ if [[ "$INDEPENDENT" -eq "1" ]]
+ then
+ # do nothing
+ echo ""
+ else
+ writef "${_cases},${_pass},${_fail}"
+ echo "${ResultLog}" > $_filename
+ printf "$_filename\n"
+ fi
if (( ${_criticalFail} > 0 ))
then
_criticalFail=0
_cases=0
_filename=$(mktemp)
+ _group=`basename "$1"`
+ if [[ "${#_group}" -eq "0" ]]
+ then
+ _group="(Unspecified)"
+ fi
+
+ writef "${Green}==================================================${NC}"
+ writef " Test Group ${Green}$_group${NC} Starts."
}
##
#
SILENT=1
+function createTemplate {
+ if [[ -f "runTest.sh" ]]
+ then
+ printf "Cannot create runTest.sh here. The file already exists at $(pwd).\n\n"
+ exit 1
+ fi
+
+ echo -e "#!/usr/bin/env bash\n\
+if [[ \"\$SSATAPILOADED\" != \"1\" ]]\n\
+then\n\
+ SILENT=0\n\
+ INDEPENDENT=1\n\
+ search=\"ssat-api.sh\"\n\
+ source \$search\n\
+ printf \"\${Blue}Independent Mode\${NC}\\n\"\n\
+fi\n\
+testInit \$1 # You may replace this with Test Group Name\n\
+\n\
+#testResult 1 T1 \"Dummy Test1\"\n\
+#callTestSuccess gst-launch-1.0 \"-q videotestsrc ! videoconvert ! autovideosink\" T2 \"This may run indefinitely\"\n\
+#callCompareTest golden.log executeResult.log T3 \"The two files must be same\" 0\n\
+\n\
+report\n" > runTest.sh
+chmod a+x runTest.sh
+
+ exit 0
+}
+
# Handle arguments
POSITIONAL=()
while [[ $# -gt 0 ]]
key="$1"
case $key in
-h|--help)
- printf "usage: ${BASENAME} [--help] [<path>] [--testcase <filename>] [--nocolor] [--showstdout]\n\n"
+ printf "usage: ${BASENAME} [--help] [<path>] [--testcase <filename>] [--nocolor] [--showstdout] [--createtemplate]\n\n"
printf "These are common ${Red}ssat${NC} commands used:\n\n"
printf "Test all test-groups in the current ($(pwd)) directory, recursively\n"
printf " (no options specified)\n"
printf "Show stdout of test cases\n"
printf " --showstdout or -s\n"
printf "\n"
+ printf "Create a template 'runTest.sh' test group at your current directory\n"
+ printf " --createtemplate or -c\n"
+ printf "\n"
printf "Shows this message\n"
printf " --help or -h\n"
printf " $ ${BASENAME} --help \n"
SILENT=0
shift
;;
+ -c|--createtemplate)
+ createTemplate
+ shift
+ ;;
*) # Unknown, which is probably target (the path to root-dir of test groups).
TARGET="$1"
esac
tmpfile=$(mktemp)
pushd $CASEBASEPATH > /dev/null
- output=$(. $file)
+ output=$(. $file $CASEBASEPATH)
retcode=$?
popd > /dev/null
logfile="${output##*$'\n'}"
-
resultlog=$(<$logfile)
effectiveOutput=`printf "$resultlog" | sed '$d'`
log="$log$effectiveOutput\n"
lastline=`printf "${resultlog}" | sed '$!d'`
- IFS=/
+ IFS=,
set $lastline
Ntc=$1
Npass=$2