Update test.py to detect still reachable memory blocks as errors, it will fail if there is some reachable memory blocks reported by valgrind
--- a/test.py Thu Jan 14 11:45:04 2010 +0000
+++ b/test.py Fri Jan 15 17:48:18 2010 +0100
@@ -27,6 +27,7 @@
import signal
import xml.dom.minidom
import shutil
+import re
#
# XXX This should really be part of a waf command to list the configuration
@@ -670,7 +671,7 @@
suppressions_path = os.path.join (base, VALGRIND_SUPPRESSIONS_FILE)
path_cmd = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, shell_command)
if valgrind:
- cmd = "valgrind --suppressions=%s --leak-check=full --error-exitcode=2 %s" % (suppressions_path, path_cmd)
+ cmd = "valgrind --suppressions=%s --leak-check=full --show-reachable=yes --error-exitcode=2 %s" % (suppressions_path, path_cmd)
else:
cmd = path_cmd
@@ -679,14 +680,26 @@
start_time = time.time()
proc = subprocess.Popen(cmd, shell = True, cwd = directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ elapsed_time = time.time() - start_time
+ ##detect errors ignored by valgrind
+ error = False
+ if valgrind:
+ reg = re.compile ('still reachable: ([^ ]+) bytes')
+ for line in proc.stderr:
+ result = reg.search(line)
+ if result is None:
+ continue
+ if result.group(1) != "0":
+ error = True
stdout_results, stderr_results = proc.communicate()
- elapsed_time = time.time() - start_time
-
+ retval = proc.returncode
+ if retval == 0 and error:
+ retval = 1
if options.verbose:
- print "Return code = ", proc.returncode
+ print "Return code = ", retval
print "stderr = ", stderr_results
- return (proc.returncode, stdout_results, stderr_results, elapsed_time)
+ return (retval, stdout_results, stderr_results, elapsed_time)
#
# This class defines a unit of testing work. It will typically refer to