View | Details | Raw Unified | Return to bug 792
Collapse All | Expand All

(-)a/test.py (-14 / +17 lines)
 Lines 671-677    Link Here 
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
 Lines 680-700    Link Here 
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
(-)a/wutils.py (-6 / +2 lines)
 Lines 121-136    Link Here 
121
            raise Utils.WafError("Options --command-template and --valgrind are conflicting")
121
            raise Utils.WafError("Options --command-template and --valgrind are conflicting")
122
        if not env['VALGRIND']:
122
        if not env['VALGRIND']:
123
            raise Utils.WafError("valgrind is not installed")
123
            raise Utils.WafError("valgrind is not installed")
124
        argv = [env['VALGRIND'], "--leak-check=full", "--error-exitcode=1"] + argv
124
        argv = [env['VALGRIND'], "--leak-check=full", "--show-reachable=yes", "--error-exitcode=1"] + argv
125
        proc = subprocess.Popen(argv, env=proc_env, cwd=cwd, stderr=subprocess.PIPE)
125
        proc = subprocess.Popen(argv, env=proc_env, cwd=cwd, stderr=subprocess.PIPE)
126
        reg = re.compile ('definitely lost: ([^ ]+) bytes')
127
        error = False
126
        error = False
128
        for line in proc.stderr:
127
        for line in proc.stderr:
129
            sys.stderr.write(line)
128
            sys.stderr.write(line)
130
            result = reg.search(line)
129
            if "== LEAK SUMMARY" in line:
131
            if result is None:
132
                continue
133
            if result.group(1) != "0":
134
                error = True
130
                error = True
135
        retval = proc.wait()
131
        retval = proc.wait()
136
        if retval == 0 and error:
132
        if retval == 0 and error:

Return to bug 792