[asterisk-commits] Add option to strip prefix from paths in refleaks-summary. (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 8 10:19:02 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: Add option to strip prefix from paths in refleaks-summary.
......................................................................


Add option to strip prefix from paths in refleaks-summary.

This adds a '-p' option to specify the prefix that should be stripped
from the paths of all refs.txt files listed in the summary.  This is
used by runtests.py to remove 'logs/', this way the paths listed in
refleaks-summary.txt are relative to that file instead of the testsuite
root.

Change-Id: I6e59325d1e3447a7b3e8fe670f9c262091b62e8e
---
M contrib/scripts/refleaks-summary
M runtests.py
2 files changed, 13 insertions(+), 9 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/contrib/scripts/refleaks-summary b/contrib/scripts/refleaks-summary
index f165866..31e517c 100755
--- a/contrib/scripts/refleaks-summary
+++ b/contrib/scripts/refleaks-summary
@@ -2,11 +2,12 @@
 
 print_usage() {
 	echo "Usage:"
-	echo "$0 [-s] [-n] [-b logs/]"
-	echo "\t-s            Strip /var/log/asterisk/refs.txt from output"
-	echo "\t-n            Sort output by number of objects leaked"
-	echo "\t-r            Reverse sort output"
-	echo "\t-b BASEDIR    Search for logs from BASEDIR instead of logs/"
+	echo "$0 [-s] [-n] [-b logs/] [-p logs/] > logs/refleaks.txt"
+	echo -e "\t-s            Strip /var/log/asterisk/refs.txt from output"
+	echo -e "\t-p PREFIX     Strip PREFIX from output"
+	echo -e "\t-n            Sort output by number of objects leaked"
+	echo -e "\t-r            Reverse sort output"
+	echo -e "\t-b BASEDIR    Search for logs from BASEDIR instead of logs/"
 	exit $1
 }
 
@@ -14,7 +15,7 @@
 REVERSEPARAMS=""
 STRIPFILE=
 BASEPATH=logs/
-while getopts ":snrhb:" opt; do
+while getopts ":snrhp:b:" opt; do
 	case $opt in
 		s)
 			STRIPFILE=/var/log/asterisk/refs.txt
@@ -24,6 +25,9 @@
 			;;
 		n)
 			SORTPARAMS="-n"
+			;;
+		p)
+			STRIPPREFIX="$OPTARG"
 			;;
 		b)
 			BASEPATH="$OPTARG"
@@ -47,9 +51,9 @@
 
 REFS_FILES=$(find "${BASEPATH}" -name refs.txt 2>/dev/null)
 if test -z "$REFS_FILES"; then
-	echo "No refs.txt logs found in ${BASEPATH}"
+	echo "No refs.txt logs found."
 	exit
 fi
 
 echo "Leaked objects per instance of Asterisk:"
-grep -H $REFS_FILES -e '==== Leaked Object '|sed -e "s,$STRIPFILE:.*,,"|uniq -c|sort $SORTPARAMS $REVERSEPARAMS
+grep -H $REFS_FILES -e '==== Leaked Object '|sed -e "s,$STRIPFILE:.*,," -e "s,^$STRIPPREFIX,,"|uniq -c|sort $SORTPARAMS $REVERSEPARAMS
diff --git a/runtests.py b/runtests.py
index 6c79476..9e0feb5 100755
--- a/runtests.py
+++ b/runtests.py
@@ -658,7 +658,7 @@
     def generate_refleaks_summary(self):
         dest_file = open("./logs/refleaks-summary.txt", "w")
         try:
-            subprocess.call("./contrib/scripts/refleaks-summary",
+            subprocess.call(["./contrib/scripts/refleaks-summary", "-p", "logs/"],
                                   stdout=dest_file,
                                   stderr=subprocess.STDOUT)
         finally:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6e59325d1e3447a7b3e8fe670f9c262091b62e8e
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list