[asterisk-commits] pretty print: Adjust for usage of the runtests --number= op... (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 5 09:56:05 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5577 )

Change subject: pretty_print:  Adjust for usage of the runtests --number= option
......................................................................


pretty_print:  Adjust for usage of the runtests --number= option

Tweaked runtests.py a bit so it spits out the number of test
iterations (--number) at the beginning so pretty_print knows
how many total tests to expect.

Change-Id: Ib604888c9c2175135faf1b8f3eb42736aeba53ad
---
M contrib/scripts/pretty_print
M runtests.py
2 files changed, 49 insertions(+), 38 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Jenkins2: Approved for Submit
  Joshua Colp: Looks good to me, approved



diff --git a/contrib/scripts/pretty_print b/contrib/scripts/pretty_print
index 7dc5686..051f6ea 100755
--- a/contrib/scripts/pretty_print
+++ b/contrib/scripts/pretty_print
@@ -19,7 +19,7 @@
 RED='\033[01;31m'
 NORM='\033[m'
 
-col=$(( $(tput cols) - 36 ))
+status_string="[nnnn of nnnn][Status][Pass][Fail]"
 
 counter() {
 	status=Running
@@ -35,40 +35,50 @@
 		else
 			printf "[%12s %3ss ]" "Running for" $et
 		fi
-		tput cub 20
+		tput cub 19
 	done
 }
 
 echo -e -n "Calculating...\r"
+declare -i run=0
+declare -i runs=0
+declare -ix runnable=0
+declare -ix total=0
+declare -ix passed=0
+declare -ix failed=0
+declare -ix timedout=0
+declare -ix tests=0
+declare -ix maxelapsed=0
+declare -a failures
+declare -a timeouts
+declare testname=""
+starttime=$SECONDS
 
 trap 'kill $countpid &>/dev/null' INT ERR
 while read line ; do
-	if [[ $line =~ ^Running.tests.for.(Asterisk.*) ]] ; then
-		declare -ix runnable=0
-		declare -ix total=0
-		declare -ix passed=0
-		declare -ix failed=0
-		declare -ix timedout=0
-		declare -ix tests=0
-		declare -ix maxelapsed=0
-		declare -a failures
-		declare -a timeouts
-
+	if [[ $line =~ ^Running.tests.for.(Asterisk[^\s]+)[\ ]+\(run[\ ]+([0-9]+)[\ ]+of[\ ]+([0-9]+)\)\.\.\. ]] ; then
+		run=${BASH_REMATCH[2]}
+		runs=${BASH_REMATCH[3]}
 		version=${BASH_REMATCH[1]}
-		starttime=$SECONDS
 	fi
 
-	if [[ $line =~ ^Tests.to.run:.([0-9]+),[\ ]+Maximum.test.inactivity.time:.([0-9-]+) ]] ; then
-		runnable=${BASH_REMATCH[1]}
-		export test_timeout=${BASH_REMATCH[2]}
-		echo =============================================================
-		echo ${line/-1/unlimited}
-		printf "[%-*.*s ][%-11s][%s][${GREEN}%4s${NORM}][${RED}%4s${NORM}]\n" $col $col "Test" "   Test" "Status" "Pass" "Fail"
+	if [[ $run -eq 1 && $line =~ ^Tests.to.run:[\ ]+([0-9]+)[\ ]+.[\ ]+([0-9]+)[\ ]+time\(s\)[\ ]+=[\ ]+([0-9]+)[\ ]+Maximum.test.inactivity.time:.([0-9-]+) ]] ; then
+		runnable=$(( ${BASH_REMATCH[1]} * $runs ))
+		export test_timeout=${BASH_REMATCH[4]}
+		echo ===========================================================================================
+		echo "${line/-1/unlimited}"
+		col=$(( $(tput cols) - ${#status_string} ))
+		printf "%-*.*s[%-12s][%s][${GREEN}%4s${NORM}][${RED}%4s${NORM}]\n" $col $col "Test" "  Test" "Status" "Pass" "Fail"
 	fi
 
 	if [[ $line =~ ^--\>.Running.test.\'(.+)\'.\.\.\. ]] ; then
 		(( tests++ ))
-		printf "[%-*.*s ][%4d of %3d]" $col $col ${BASH_REMATCH[1]#*/} $tests $runnable
+		col=$(( $(tput cols) - ${#status_string} -1 ))
+		testname=${BASH_REMATCH[1]#*/}
+		tnl=$(( ${#testname} - $col ))
+		[ $tnl -le 0 ] && tnl=0
+		testname=${testname:$tnl}
+		printf "%-*.*s [%4d of %4d]" $col $col ${testname} $tests $runnable
 		st=$SECONDS
 		counter &
 		disown $!
@@ -78,7 +88,7 @@
 	if [[ $line =~ ^Test.*tests/([^\']+)\',.*(passed|failed|timed\ out)$ ]] ; then
 		test=${BASH_REMATCH[1]}
 		status=${BASH_REMATCH[2]}
-		col=$(( $(tput cols) - 36 ))
+		col=$(( $(tput cols) - ${#status_string} ))
 		et=$(( $SECONDS - $st ))
 		kill $countpid
 
@@ -105,20 +115,21 @@
 		printf "[${COLOR}%s${NORM}][${GREEN}%4d${NORM}][${RED}%4d${NORM}]\n" $label $passed $failed
 	fi
 
-	if [[ $line =~ (TEST\ RESULTS) ]] ; then
-		for fail in "${failures[@]}" ; do
-			echo -e "${RED}$fail${NORM}"
-		done
-		for to in "${timeouts[@]}" ; do
-			echo -e "${YELLOW}$to${NORM}"
-		done
-
-		elapsed=$(( $SECONDS - $starttime ))
-		time="$(( $elapsed / 60 ))m $(( $elapsed % 60 ))s"
-		echo -e "Tests: $runnable   ${GREEN}Passed: $passed   ${RED}Failed: $failed   TimedOut: $timedout${NORM}   Time: $time\tLongest test: ${maxelapsed}s"
-	fi
 done
 
+for fail in "${failures[@]}" ; do
+	echo -e "${RED}$fail${NORM}"
+done
+for to in "${timeouts[@]}" ; do
+	echo -e "${YELLOW}$to${NORM}"
+done
+
+elapsed=$(( $SECONDS - $starttime ))
+time="$(( $elapsed / 60 ))m $(( $elapsed % 60 ))s"
+echo -------------------------------------------------------------------------------------------
+echo -e "Tests: $runnable   ${GREEN}Passed: $passed   ${RED}Failed: $failed   TimedOut: $timedout${NORM}   Time: $time\tLongest test: ${maxelapsed}s"
+echo ===========================================================================================
+
 trap - INT ERR
 
 kill $countpid &>/dev/null
diff --git a/runtests.py b/runtests.py
index c6f5b3a..c8c225e 100755
--- a/runtests.py
+++ b/runtests.py
@@ -557,8 +557,8 @@
                     if excluded in t.test_name:
                         continue
             i += 1
-        print "Tests to run: %d,  Maximum test inactivity time: %d sec." % \
-            (i, (self.options.timeout / 1000))
+        print "Tests to run: %d * %d time(s) = %d  Maximum test inactivity time: %d sec." % \
+            (i, self.options.number, i * self.options.number, (self.options.timeout / 1000))
 
         for t in self.tests:
             if abandon_test_suite:
@@ -843,8 +843,8 @@
 
         test_suite = TestSuite(ast_version, options)
 
-        running_str = "Running tests for Asterisk {0} (run {1})...\n".format(
-            str(ast_version).strip('\n'), iteration + 1)
+        running_str = "Running tests for Asterisk {0} (run {1} of {2})...\n".format(
+            str(ast_version).strip('\n'), iteration + 1, options.number)
         print running_str
         if options.syslog:
             syslog.syslog(running_str)

-- 
To view, visit https://gerrit.asterisk.org/5577
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib604888c9c2175135faf1b8f3eb42736aeba53ad
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list