[petsc-dev] using valgrind with new test harness

Satish Balay balay at mcs.anl.gov
Tue Feb 7 17:34:19 CST 2017


We cannot override stuff via env variables in the new test harness. For nightlybuilds
I added support to check if PETSC_ARCH has 'valgrind' string in it - and if so - use
valgrind.

26646c0bcc29652ef239540b066d00d1c8fc99c7

Perhaps we can force this to use valgrind with:

./config/gmakegentest.py --valgrind=1

Ok - perhaps the attached patch. But then - sometimes gmakefile runs ./config/gmakegentest.py directly [without valgrind]

Satish

-------


On Tue, 7 Feb 2017, Barry Smith wrote:

> 
> Both 
> 
> make -f gmakefile test MPIEXEC="/sandbox/bsmith/petsc/bin/petscmpiexec -valgrind " 
> 
> and
> 
> MPIEXEC="/sandbox/bsmith/petsc/bin/petscmpiexec -valgrind " make -f gmakefile test 
> 
> do not appear to use valgrind in the test harness (the old system did).
> 
> How do I run all tests under valgrind automatically?
> 
> 
> 
> 
> not ok dm_impls_plex_tests-ex18_1
> #       [0]PETSC ERROR: PetscTrFreeDefault() called from VecDestroy_MPI() line 18 in /sandbox/bsmith/petsc/src/vec\
> /vec/impls/mpi/pdvec.c
> #       [0]PETSC ERROR: Block [id=0(32)] at address 0xb54240 is corrupted (probably write past end of array)
> #       [0]PETSC ERROR: Block allocated in VecCreate_MPI_Private() line 497 in /sandbox/bsmith/petsc/src/vec/vec/i\
> mpls/mpi/pbvec.c
> #       [0]PETSC ERROR: --------------------- Error Message ------------------------------------------------------\
> --------
> #       [0]PETSC ERROR: Memory corruption: http://www.mcs.anl.gov/petsc/documentation/installation.html#valgrind
> #       [0]PETSC ERROR: Corrupted memory
> #       [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> #       [0]PETSC ERROR: Petsc Development GIT revision: v3.7.5-3057-g2d11e0f  GIT Date: 2017-02-07 15:39:04 -0600
> #       [0]PETSC ERROR: ../ex18 on a arch-single named es by bsmith Tue Feb  7 15:46:25 2017
> #       [0]PETSC ERROR: Configure options --download-ctetgen --download-exodusii --download-hdf5 --download-mpich \
> --download-netcdf PETSC_ARCH=arch-single --with-precision=single
> #       [0]PETSC ERROR: #1 PetscTrFreeDefault() line 287 in /sandbox/bsmith/petsc/src/sys/memory/mtr.c
> #       [0]PETSC ERROR: #2 VecDestroy_MPI() line 18 in /sandbox/bsmith/petsc/src/vec/vec/impls/mpi/pdvec.c
> #       [0]PETSC ERROR: #3 VecDestroy() line 406 in /sandbox/bsmith/petsc/src/vec/vec/interface/vector.c
> #       [0]PETSC ERROR: #4 DMDestroy() line 681 in /sandbox/bsmith/petsc/src/dm/interface/dm.c
> #       [0]PETSC ERROR: #5 main() line 473 in /sandbox/bsmith/petsc/src/dm/impls/plex/examples/tests/ex18.c
> #       [0]PETSC ERROR: PETSc Option Table entries:
> #       [0]PETSC ERROR: -dm_view ascii::ascii_info_detail
> #       [0]PETSC ERROR: -interpolate
> 
> 
> 
-------------- next part --------------
diff --git a/config/gmakegentest.py b/config/gmakegentest.py
index cf7eb04..c4e814b 100755
--- a/config/gmakegentest.py
+++ b/config/gmakegentest.py
@@ -21,9 +21,10 @@ class generateExamples(Petsc):
     gmakegen.py has basic structure for finding the files, writing out
       the dependencies, etc.
   """
-  def __init__(self,petsc_dir=None, petsc_arch=None, verbose=False, single_ex=False):
+  def __init__(self,petsc_dir=None, petsc_arch=None, verbose=False, enable_valgrind=False, single_ex=False):
     super(generateExamples, self).__init__(petsc_dir=None, petsc_arch=None, verbose=False)
 
+    self.enable_valgrind=enable_valgrind
     self.single_ex=single_ex
     self.arch_dir=os.path.join(self.petsc_dir,self.petsc_arch)
     self.ptNaming=True
@@ -238,7 +239,7 @@ class generateExamples(Petsc):
     if testDict.has_key('args'):  subst['args']=testDict['args']
 
     #Conf vars
-    if self.petsc_arch.find('valgrind')>=0:
+    if self.enable_valgrind or self.petsc_arch.find('valgrind')>=0:
       subst['mpiexec']='petsc_mpiexec_valgrind ' + self.conf['MPIEXEC']
     else:
       subst['mpiexec']=self.conf['MPIEXEC']
@@ -713,12 +714,12 @@ class generateExamples(Petsc):
     eval("self.write_"+output+"(dataDict)")
     return
 
-def main(petsc_dir=None, petsc_arch=None, output=None, verbose=False, single_ex=False):
+def main(petsc_dir=None, petsc_arch=None, output=None, verbose=False, enable_valgrind=False, single_ex=False):
     if output is None:
         output = 'gnumake'
 
 
-    pEx=generateExamples(petsc_dir=petsc_dir, petsc_arch=petsc_arch, verbose=verbose, single_ex=single_ex)
+    pEx=generateExamples(petsc_dir=petsc_dir, petsc_arch=petsc_arch, verbose=verbose, enable_valgrind=enable_valgrind, single_ex=single_ex)
     dataDict=pEx.walktree(os.path.join(pEx.petsc_dir,'src'),action="genPetscTests")
     pEx.writeHarness(output,dataDict)
 
@@ -727,6 +728,7 @@ if __name__ == '__main__':
     parser = optparse.OptionParser()
     parser.add_option('--verbose', help='Show mismatches between makefiles and the filesystem', action='store_true', default=False)
     parser.add_option('--petsc-arch', help='Set PETSC_ARCH different from environment', default=os.environ.get('PETSC_ARCH'))
+    parser.add_option('--valgrind', help='use valgrind to run the testsuite', default=False)
     parser.add_option('--output', help='Location to write output file', default=None)
     parser.add_option('-s', '--single_executable', dest='single_executable', action="store_false", help='Whether there should be single executable per src subdir.  Default is false')
     opts, extra_args = parser.parse_args()
@@ -734,4 +736,4 @@ if __name__ == '__main__':
         import sys
         sys.stderr.write('Unknown arguments: %s\n' % ' '.join(extra_args))
         exit(1)
-    main(petsc_arch=opts.petsc_arch, output=opts.output, verbose=opts.verbose, single_ex=opts.single_executable)
+    main(petsc_arch=opts.petsc_arch, output=opts.output, verbose=opts.verbose, enable_valgrind=opts.valgrind, single_ex=opts.single_executable)


More information about the petsc-dev mailing list