Author: coreyfarrell Date: Thu Oct 30 22:20:32 2014 New Revision: 5825 URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5825 Log: Process REF_DEBUG logs, fail any test that leaks
* Fail any test that shows leaks in REF_DEBUG logs. * Add script to view summary of objects leaked per instance * Allow $MENUSELECT_OPTIONS environmental variable to be used with './run-local setup' to pass additional parameters to menuselect ASTERISK-24379 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4038/ Added: asterisk/trunk/contrib/scripts/refleaks-summary (with props) Modified: asterisk/trunk/run-local asterisk/trunk/runtests.py Added: asterisk/trunk/contrib/scripts/refleaks-summary URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/contrib/scripts/refleaks-summary?view=auto&rev=5825 ============================================================================== --- asterisk/trunk/contrib/scripts/refleaks-summary (added) +++ asterisk/trunk/contrib/scripts/refleaks-summary Thu Oct 30 22:20:32 2014 @@ -1,0 +1,55 @@ +#!/bin/sh + +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/" + exit $1 +} + +SORTPARAMS="-k2" +REVERSEPARAMS="" +STRIPFILE= +BASEPATH=logs/ +while getopts ":snrhb:" opt; do + case $opt in + s) + STRIPFILE=/var/log/asterisk/refs.txt + ;; + r) + REVERSEPARAMS="-r" + ;; + n) + SORTPARAMS="-n" + ;; + b) + BASEPATH="$OPTARG" + ;; + :) + echo "Option -$OPTARG requires an argument." + exit 1 + ;; + h) + print_usage 0 + ;; + \?) + print_usage 1 1>&2 + ;; + esac +done + +if test $OPTIND -le $#; then + print_usage 1 1>&2 +fi + +REFS_FILES=$(find "${BASEPATH}" -name refs.txt 2>/dev/null) +if test -z "$REFS_FILES"; then + echo "No refs.txt logs found in ${BASEPATH}" + 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 Propchange: asterisk/trunk/contrib/scripts/refleaks-summary ------------------------------------------------------------------------------ svn:eol-style = native Propchange: asterisk/trunk/contrib/scripts/refleaks-summary ------------------------------------------------------------------------------ svn:executable = * Propchange: asterisk/trunk/contrib/scripts/refleaks-summary ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: asterisk/trunk/contrib/scripts/refleaks-summary ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: asterisk/trunk/run-local URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/run-local?view=diff&rev=5825&r1=5824&r2=5825 ============================================================================== --- asterisk/trunk/run-local (original) +++ asterisk/trunk/run-local Thu Oct 30 22:20:32 2014 @@ -25,7 +25,7 @@ if [ ! -f config.status ]; then ./configure --enable-dev-mode make menuselect.makeopts - menuselect/menuselect --enable DONT_OPTIMIZE --enable TEST_FRAMEWORK + menuselect/menuselect --enable DONT_OPTIMIZE --enable TEST_FRAMEWORK $MENUSELECT_OPTIONS fi make make install samples DESTDIR="$HERE/astroot" Modified: asterisk/trunk/runtests.py URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=5825&r1=5824&r2=5825 ============================================================================== --- asterisk/trunk/runtests.py (original) +++ asterisk/trunk/runtests.py Thu Oct 30 22:20:32 2014 @@ -90,6 +90,8 @@ print "Core dumps detected; failing test" self.passed = False self._archive_core_dumps(core_dumps) + + self._process_ref_debug() if not self.passed: self._archive_logs() @@ -137,7 +139,7 @@ except OSError, e: print "Error removing core file: %s: Beware of the stale core file in CWD!" % (e,) - def _archive_logs(self): + def _find_run_dirs(self): test_run_dir = os.path.join(Asterisk.test_suite_root, self.test_relpath) @@ -150,6 +152,53 @@ archive_dir = os.path.join('./logs', self.test_relpath, 'run_%d' % run_num) + return (run_num, run_dir, archive_dir) + + def _process_ref_debug(self): + (run_num, run_dir, archive_dir) = self._find_run_dirs() + if (run_num == 0): + return + + refcounter_py = os.path.join(run_dir, "ast1/var/lib/asterisk/scripts/refcounter.py") + if not os.path.exists(refcounter_py): + return + + i = 1 + while os.path.isdir(os.path.join(run_dir, 'ast%d/var/log/asterisk' % i)): + ast_dir = "%s/ast%d/var/log/asterisk" % (run_dir, i) + refs_in = os.path.join(ast_dir, "refs") + if os.path.exists(refs_in): + refs_txt = os.path.join(ast_dir, "refs.txt") + dest_file = open(refs_txt, "w") + refcounter = [ + refcounter_py, + "-f", refs_in, + "-sn" + ] + res = -1 + try: + res = subprocess.call(refcounter, + stdout=dest_file, + stderr=subprocess.STDOUT) + except Exception, e: + print "Exception occurred while processing REF_DEBUG" + finally: + dest_file.close() + if res != 0: + dest_dir = os.path.join(archive_dir, + 'ast%d/var/log/asterisk' % i) + if not os.path.exists(dest_dir): + os.makedirs(dest_dir) + hardlink_or_copy(refs_txt, + os.path.join(dest_dir, "refs.txt")) + hardlink_or_copy(refs_in, + os.path.join(dest_dir, "refs")) + print "REF_DEBUG identified leaks, mark test as failure" + self.passed = False + i += 1 + + def _archive_logs(self): + (run_num, run_dir, archive_dir) = self._find_run_dirs() self._archive_ast_logs(run_num, run_dir, archive_dir) self._archive_pcap_dump(run_dir, archive_dir) if os.path.exists(os.path.join(run_dir, 'messages.txt')): -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
