Feature: count negative test cases submit/tizen/20200316.090011
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 16 Mar 2020 08:43:26 +0000 (17:43 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 16 Mar 2020 09:01:02 +0000 (18:01 +0900)
The new option "-cn"/"--countnegative" allows to count
test cases with a specified postfix.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
ssat-api.sh
ssat.sh

index ee83e3c..2b11b08 100644 (file)
@@ -95,7 +95,12 @@ function report() {
        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
@@ -115,6 +120,7 @@ function testInit() {
        _fail=0
        _criticalFail=0
        _cases=0
+       _neg=0
        _filename=$(mktemp)
        _group=`basename "$1"`
        if [[ "${#_group}" -eq "0" ]]
@@ -151,6 +157,14 @@ function testResult() {
                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}"
diff --git a/ssat.sh b/ssat.sh
index d01f59f..a305cb2 100755 (executable)
--- a/ssat.sh
+++ b/ssat.sh
@@ -42,6 +42,8 @@ SUMMARYFILENAME=""
 #
 SILENT=1
 PROGRESS=0
+COUNTNEGATIVE=0
+COUNTNEGATIVEPOSTFIX=""
 VALGRIND=0
 date=`date +"%b %d %Y"`
 
@@ -92,7 +94,7 @@ do
        key="$1"
        case $key in
        -h|--help)
-               printf "usage: ${BASENAME} [--help] [<path>] [--testcase <filename>] [--nocolor] [--showstdout] [--createtemplate]\n\n"
+               printf "usage: ${BASENAME} [--help] [<path>] [--testcase <filename>] [--nocolor] [--showstdout] [--createtemplate] [--countnegative <postfix>] \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"
@@ -127,6 +129,11 @@ do
                printf "    --help or -h\n"
                printf "    $ ${BASENAME} --help \n"
                printf "\n"
+               printf "Count negative test cases with the given postfix\n"
+               printf "    --countnegative or -cn\n"
+               printf "    $ ${BASENAME} --countnegative _n\n"
+               printf "    $ ${BASENAME} -cn _n\n"
+               printf "\n"
                printf "Write result summary as a file\n"
                printf "    --summary <filename>\n"
                printf "\n\n"
@@ -141,6 +148,17 @@ do
        shift
        shift
        ;;
+       -cn|--countnegative)
+       COUNTNEGATIVE=1
+       COUNTNEGATIVEPOSTFIX="$2"
+       if [[ "${COUNTNEGATIVEPOSTFIX}" == "" ]]
+       then
+               printf "${BASENAME} -cn or --countnegative requires postfix.\n\n"
+               exit -2
+       fi
+       shift
+       shift
+       ;;
        -s|--showstdout)
        SILENT=0
        shift
@@ -179,6 +197,7 @@ TNtc=0
 TNtcpass=0
 TNtcfail=0
 TNtcignore=0
+TNtcneg=0
 TNgroup=0
 TNgrouppass=0
 TNgroupfail=0
@@ -192,6 +211,7 @@ do
        Ntc=0
        Npass=0
        Nfail=0
+       Nneg=0
        tmpfile=$(mktemp)
 
        if [[ "$PROGRESS" -eq "1" ]]; then
@@ -214,12 +234,14 @@ do
        Npass=$2
        Nfail=$3
        Nignore=$4
+       Nneg=$5
        unset IFS
 
        TNtc=$((TNtc+Ntc))
        TNtcpass=$((TNtcpass+Npass))
        TNtcfail=$((TNtcfail+Nfail))
        TNtcignore=$((TNtcignore+Nignore))
+       TNtcneg=$((TNtcneg+Nneg))
 
        TNgroup=$((TNgroup+1))
        if [[ "$retcode" -eq "0" ]]
@@ -245,14 +267,21 @@ if [ "${SUMMARYFILENAME}" != "" ]
 then
        echo "passed=${TNtcpass}, failed=${TNtcfail}, ignored=${TNtcignore}" > "${SUMMARYFILENAME}"
 fi
+ADDITIONALSTRING=""
+if (( ${COUNTNEGATIVE} == 1 ))
+then
+       total=$((TNtcpass+TNtcfail+TNtcignore))
+       pos=$((total-TNtcneg))
+       ADDITIONALSTRING="${ADDITIONALSTRING} | Positive: ${pos} / Negative: ${TNtcneg}"
+fi
 if (( ${TNgroupfail} == 0 ))
 then
        printf "${LightGreen}[PASSED] ${Blue}All Test Groups (${TNgroup}) Passed!${NC}\n"
-       printf "         TC Passed: ${TNtcpass} / Failed: ${TNtcfail} / Ignored: ${TNtcignore}\n\n";
+       printf "         TC Passed: ${TNtcpass} / Failed: ${TNtcfail} / Ignored: ${TNtcignore} ${ADDITIONALSTRING}\n\n";
        exit 0
 else
        printf "${Red}[FAILED] ${Purple}There are failed test groups! (${TNgroupfail})${NC}\n"
-       printf "         TC Passed: ${TNtcpass} / Failed: ${TNtcfail} / Ignored: ${TNtcignore}\n\n";
+       printf "         TC Passed: ${TNtcpass} / Failed: ${TNtcfail} / Ignored: ${TNtcignore} ${ADDITIONALSTRING}\n\n";
        exit 1
 fi
 # gather reports & publish them.