else
_ignore=$((_fail-_criticalFail))
_fail=${_criticalFail}
- writef "${_cases},${_pass},${_fail},${_ignore}"
+ if [[ "${COUNTNEGATIVE}" -eq "1" ]]
+ then
+ writef "${_cases},${_pass},${_fail},${_ignore},${_neg}"
+ else
+ writef "${_cases},${_pass},${_fail},${_ignore}"
+ fi
echo "${ResultLog}" > ${_filename}
printf "\n${_filename}\n"
fi
_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}"
function callCompareTest() {
# Try cmp.
output=0
+ if [[ ! -f "$1" || ! -f "$2" ]]; then
+ testResult $output "$3" "$4" $6
+ return
+ fi
command -v cmp
# If cmp is symlink, then it could be from busybox and it does not support "-n" option
if [[ $? == 0 && ! -L $(which cmp) ]]
## @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() {
if [[ "$VALGRIND" -eq "1" ]]; then
- calloutputprefix='valgrind --track-origins=yes'
+ calloutputprefix="valgrind --track-origins=yes ${VALGRIND_SUPPRESSION}"
fi
- if [[ "${SILENT}" -eq "1" ]]; then
- calloutput=$(eval $calloutputprefix gst-launch-1.0 -f -q $1 &> /dev/null)
+
+ 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
- calloutput=$(eval $calloutputprefix gst-launch-1.0 -f -q $1)
+ 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=$?
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.