ResultLog=""
+# Platform dependent variables
+KernelName=$(uname -s)
+if [[ "${KernelName}" == "Darwin" ]]; then
+ StatCmd_GetSize="stat -f %z"
+ SO_EXT="dylib"
+else
+ StatCmd_GetSize="stat --printf=%s"
+ SO_EXT="so"
+fi
+
## @fn writef()
## @private
## @param $1 the string to be printed.
## @fn report()
## @brief Report results of a test group (a "runTest.sh" in a testee directory)
function report() {
- if (( ${_fail} == 0 ))
+ if (( ${_fail} == 0 && ${_criticalFail} == 0 ))
then
writef "${Green}==================================================${NC}"
writef "${LightGreen}[PASSED]${NC} Test Group $_group ${Green}Passed${NC}"
writef "${Red}[FAILED]${NC} Test Group $_group has ${Red}failed cases ($_fail)${NC}"
else
writef "${Green}==================================================${NC}"
- writef "${LightGreen}[PASSED]${NC} Test Group $_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 ignorable cases and not critical.${NC}"
fi
fi
# do nothing
echo ""
else
- writef "${_cases},${_pass},${_fail}"
+ _ignore=$((_fail-_criticalFail))
+ _fail=${_criticalFail}
+ if [[ "${COUNTNEGATIVE}" -eq "1" ]]
+ then
+ writef "${_cases},${_pass},${_fail},${_ignore},${_neg}"
+ else
+ writef "${_cases},${_pass},${_fail},${_ignore}"
+ fi
echo "${ResultLog}" > ${_filename}
- printf "${_filename}\n"
+ printf "\n${_filename}\n"
fi
if (( ${_criticalFail} > 0 ))
_fail=0
_criticalFail=0
_cases=0
+ _neg=0
_filename=$(mktemp)
_group=`basename "$1"`
if [[ "${#_group}" -eq "0" ]]
## @param $4 set 1 if this is not critical (don't care if it's pass or fail)_
## @param $5 set 1 if $1==0 is success and $1!=0 is fail.
function testResult() {
- if [[ "${PROGRESS}" -eq "1" ]]
+ if [[ ${PROGRESSLOGLEVEL} -gt 1 ]]
then
- echo "Case ${2}(${3}) report ${1}" > /dev/stderr
+ echo "Case ${2}(${3}) report ${1}" >&2
fi
_cases=$((_cases+1))
fi
fi
+ if [[ "${COUNTNEGATIVE}" -eq "1" ]]
+ then
+ if [[ "${2}\n" =~ "${COUNTNEGATIVEPOSTFIX}\n" ]]
+ then
+ _neg=$((_neg+1))
+ fi
+ fi
+
if [[ "${_good}" -eq "1" ]]
then
writef "${LightGreen}[PASSED]${NC} ${Green}$2${NC}:$3${NC}"
_fail=$((_fail+1))
if [[ "${4}" == "1" ]]
then
- writef "${Purple}[FAILED][Ignorable] $2${NC}:${Purple}$3${NC}"
+ writef "${Purple}[IGNORED] $2${NC}:${Purple}$3${NC}"
else
writef "${Red}[FAILED][Critical] $2${NC}:${Purple}$3${NC}"
_criticalFail=$((_criticalFail+1))
function callCompareTest() {
# Try cmp.
output=0
+ if [[ ! -f "$1" || ! -f "$2" ]]; then
+ testResult $output "$3" "$4" $6
+ return
+ fi
command -v cmp
- if (( $? == 0 ))
+ # If cmp is symlink, then it could be from busybox and it does not support "-n" option
+ if [[ $? == 0 && ! -L $(which cmp) ]]
then
# use cmp
if (( $5 == 0 )); then
output=$?
elif (( $5 == 1 )); then
# Compare up to the size of golden
- cmp -n `stat --printf="%s" $1` $1 $2
+ cmp -n `${StatCmd_GetSize} $1` $1 $2
output=$?
elif (( $5 == 2 )); then
# Compare up to the size of test-run
- cmp -n `stat --printf="%s" $2` $1 $2
+ cmp -n `${StatCmd_GetSize} $2` $1 $2
output=$?
else
# Compare up to $5 bytes.
- cmp -n `stat --printf="%s" $5` $1 $2
+ cmp -n `${StatCmd_GetSize} $5` $1 $2
output=$?
fi
if (( ${output} == 0 )); then
fi
testResult $output "$3" "$4" $6
else
- # use internal logic (slower!)
- echo NYI
- testResult 0 "$3" "Cannot test. cmp not found." $6
+ # use internal logic (slower!)
+ bufsize=`${StatCmd_GetSize} $1`
+ if (( $5 == 2 )); then
+ bufsize=`${StatCmd_GetSize} $2`
+ else
+ bufsize=$5
+ fi
+ diff <(dd bs=1 count=$bufsize if=$1 &>/dev/null) <(dd bs=1 count=$bufsize if=$2 &>/dev/null)
+ output=$?
+ if (( ${output} == 0 )); then
+ output=1
+ else
+ output=0
+ fi
+ testResult $output "$3" "$4" $6
fi
}
## @param $3 set 1 if this is not critical (don't care if it's pass or fail)
## @param $4 set 1 if this passes if gstLaunch fails.
## @param $5 set 1 to enable PERFORMANCE test.
+## @param $6 set a positive value (seconds) to enable timeout mode.
function gstTest() {
- calloutput=$(gst-launch-1.0 -q $1)
+ if [[ "$VALGRIND" -eq "1" ]]; then
+ calloutputprefix='valgrind --track-origins=yes'
+ fi
+
+ TIMEOUT_AVAIL=1
+ if [[ "${6}" -gt "0" ]]; then
+ if ! command -v timeout &> /dev/null
+ then
+ if command -v perl &> /dev/null
+ then
+ timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
+ else
+ TIMEOUT_AVAIL=0
+ fi
+ fi
+ fi
+
+ if [[ "${6}" -gt "0" && $TIMEOUT_AVAIL -eq 1 ]]; then
+ if [[ "${SILENT}" -eq "1" ]]; then
+ calloutput=$(eval timeout ${6} $calloutputprefix gst-launch-1.0 -f -q $1 &> /dev/null)
+ else
+ calloutput=$(eval timeout ${6} $calloutputprefix gst-launch-1.0 -f -q $1)
+ fi
+ else
+ if [[ "${SILENT}" -eq "1" ]]; then
+ calloutput=$(eval $calloutputprefix gst-launch-1.0 -f -q $1 &> /dev/null)
+ else
+ calloutput=$(eval $calloutputprefix gst-launch-1.0 -f -q $1)
+ fi
+ fi
+
retcode=$?
desired=0
if [[ "${4}" -eq "1" ]]; then
fi
}
+
+## @fn gstTestBackground()
+## @brief Execute gst-launch in background with given arguments.
+## @param $1 gst-launch-1.0 Arguments, with pipeline description at the end. The pipeline should have async=false for sink elements (skip preroll!).
+## @param $2 test case ID
+## @param $3 set 1 if this is not critical (don't care if it's pass or fail)
+## @param $4 set 1 if this passes if launching the pipeline fails. (pass if timeout expires)
+## @param $5 set timeout for launching the pipeline in seconds (not the pipeline EOS). default = 10.
+## @return $pid The PID of the background gstreamer pipeline.
+function gstTestBackground() {
+ local marker=$(mktemp)
+ local timeout=10
+ local launchSuccess
+ local launchFail
+ local pipeline
+
+ if [ "$4" == "1" ]; then
+ launchSuccess=0
+ launchFail=1
+ else
+ launchSuccess=1
+ launchFail=0
+ fi
+ if [ "$5" == "" ]; then
+ # no changes in timeout. do nothing
+ sleep 0
+ else
+ if [ $5 -gt 0 ]; then
+ timeout=$5
+ else
+ # ignore if it's < 1. do nothing
+ sleep 0
+ fi
+ fi
+
+ pipeline="$1 videotestsrc num-buffers=1 ! video/x-raw,width=4,height=4,format=RGB ! filesink location=${marker}"
+ gst-launch-1.0 $pipeline &
+ pid=$!
+
+ for i in $(seq 1 ${timeout})
+ do
+ if [ -f "$marker" ]; then
+ markersize=$(stat -c%s ${marker})
+ if [ $markersize -ge 48 ]; then
+ testResult ${launchSuccess} $2 "gst-launch in background of case $2" $3
+ rm ${marker}
+ return $pid
+ fi
+ fi
+ sleep 1
+ done
+ rm ${marker}
+ testResult ${launchFail} $2 "gst-launch in background of case $2" $3
+ return ${pid}
+}
+
## @fn convertBMP2PNG()
## @brief Convert all *.bmp to *.png in the current directory
## @todo macronice "bmp2png" searching.