|
|
| 671 |
suppressions_path = os.path.join (base, VALGRIND_SUPPRESSIONS_FILE) |
671 |
suppressions_path = os.path.join (base, VALGRIND_SUPPRESSIONS_FILE) |
| 672 |
path_cmd = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, shell_command) |
672 |
path_cmd = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, shell_command) |
| 673 |
if valgrind: |
673 |
if valgrind: |
| 674 |
cmd = "valgrind --suppressions=%s --leak-check=full --show-reachable=yes --error-exitcode=2 %s" % (suppressions_path, path_cmd) |
674 |
cmd = "valgrind --suppressions=%s --leak-check=full --show-reachable=yes --error-exitcode=2 %s" % (suppressions_path, |
|
|
675 |
path_cmd) |
| 675 |
else: |
676 |
else: |
| 676 |
cmd = path_cmd |
677 |
cmd = path_cmd |
| 677 |
|
678 |
|
|
|
| 680 |
|
681 |
|
| 681 |
start_time = time.time() |
682 |
start_time = time.time() |
| 682 |
proc = subprocess.Popen(cmd, shell = True, cwd = directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
683 |
proc = subprocess.Popen(cmd, shell = True, cwd = directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
|
684 |
stdout_results, stderr_results = proc.communicate() |
| 683 |
elapsed_time = time.time() - start_time |
685 |
elapsed_time = time.time() - start_time |
| 684 |
##detect errors ignored by valgrind |
686 |
|
| 685 |
error = False |
|
|
| 686 |
if valgrind: |
| 687 |
reg = re.compile ('still reachable: ([^ ]+) bytes') |
| 688 |
for line in proc.stderr: |
| 689 |
result = reg.search(line) |
| 690 |
if result is None: |
| 691 |
continue |
| 692 |
if result.group(1) != "0": |
| 693 |
error = True |
| 694 |
stdout_results, stderr_results = proc.communicate() |
| 695 |
retval = proc.returncode |
687 |
retval = proc.returncode |
| 696 |
if retval == 0 and error: |
688 |
|
| 697 |
retval = 1 |
689 |
# |
|
|
690 |
# valgrind sometimes has its own idea about what kind of memory management |
| 691 |
# errors are important. We want to detect *any* leaks, so the way to do |
| 692 |
# that is to look for the presence of a valgrind leak summary section. |
| 693 |
# |
| 694 |
# If another error has occurred (like a test suite has failed), we don't |
| 695 |
# want to trump that error, so only do the valgrind output scan if the |
| 696 |
# test has otherwise passed (return code was zero). |
| 697 |
# |
| 698 |
if valgrind and retval == 0 and "== LEAK SUMMARY:" in stderr_results: |
| 699 |
retval = 2 |
| 700 |
|
| 698 |
if options.verbose: |
701 |
if options.verbose: |
| 699 |
print "Return code = ", retval |
702 |
print "Return code = ", retval |
| 700 |
print "stderr = ", stderr_results |
703 |
print "stderr = ", stderr_results |