File run-tests.sh of Package udisks2-testsuite

#!/bin/sh

function summary {
    ws='[   ]'
    results=$(echo logs/*.trs)
    [[ -n "$results" ]] || results=/dev/null
    all=`grep "^$ws*:test-result:" $results | wc -l`
    pass=`grep "^$ws*:test-result:$ws*PASS" $results | wc -l`
    fail=`grep "^$ws*:test-result:$ws*FAIL" $results | wc -l`
    skip=`grep "^$ws*:test-result:$ws*SKIP" $results | wc -l`
    xfail=`grep "^$ws*:test-result:$ws*XFAIL" $results | wc -l`
    xpass=`grep "^$ws*:test-result:$ws*XPASS" $results | wc -l`
    error=`grep "^$ws*:test-result:$ws*ERROR" $results | wc -l`
    if [ $(expr $fail + $xpass + $error) -eq 0 ]; then
      success=0;
    else
      success=1;\
    fi
   
    echo
    echo "============================================================================"
    echo "Testsuite summary for udisks2"
    echo "============================================================================"
    echo -e "# TOTAL: $all" 
    echo -e '\033[0;32m'"# PASS:  $pass" 
    echo -e '\033[1;34m'"# SKIP:  $skip" 
    #echo -e '\033[m'"# XFAIL: $xfail" 
    echo -e '\033[0;31m'"# FAIL:  $fail" 
    #echo -e '\033[m'"# XPASS: $xpass"
    echo -e '\033[m'"# ERROR: $error"
    echo "============================================================================"
    echo -e "See logs/\$testname.log\n"
}


if [ "$1" == "--help" ]; then
	echo "Usage: ./run-tests.sh [--skip=\$tests]"
        echo "       \$tests is a space separated list of test names" 
	exit 0
fi

[ -d logs ] || mkdir logs
rm -f logs/*

#for integration-test
modprobe -r scsi_debug

testfiles="udisks-test integration-test dbus-tests/run_tests.py "
#testfiles+=""

exclude=$(echo *.o ) 

skiptests="$exclude"

for toskip in ${@##--skip=}; do
	[[ "$testfiles" =~ "$toskip" ]] && skiptests+=" $toskip"
done

cd tests
for test in $testfiles; do
        for skip in $skiptests; do
                [[ $skip == $test ]] && continue 2; 
                [[ scripts/$skip == $test ]] && continue 2; 
        done

        [[ "$test" == "dbus-tests/run_tests.py" ]] && \
	{ systemctl start targetcli;
          targetcli clearconfig confirm=True &>/dev/null; 
          ./test-driver --test-name $test --test-opts --system --log-file ../logs/${test/\//_}.log --trs-file ../logs/${test/\//_}.trs --color-tests yes;
	  continue; }

	./test-driver --test-name $test --log-file ../logs/${test/\//_}.log --trs-file ../logs/${test/\//_}.trs --color-tests yes
done

cd ..
summary

exit $success
openSUSE Build Service is sponsored by