Support using valgrind on test programs
authorKen Raeburn <raeburn@mit.edu>
Tue, 4 Sep 2007 22:59:44 +0000 (22:59 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 4 Sep 2007 22:59:44 +0000 (22:59 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19916 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/rpc/unit-test/Makefile.in
src/lib/rpc/unit-test/config/unix.exp

index fb527fd6a10ec73aa3d13cda4fdfae37cba76fe8..d2f80e67068ff43c9435e2b13693d436a4520559 100644 (file)
@@ -56,7 +56,7 @@ unit-test-body:
                $(RUNTEST) SERVER=./server CLIENT=./client \
                KINIT=$(BUILDTOP)/clients/kinit/kinit \
                KDESTROY=$(BUILDTOP)/clients/kdestroy/kdestroy \
-               PRIOCNTL_HACK=@PRIOCNTL_HACK@ \
+               PRIOCNTL_HACK=@PRIOCNTL_HACK@ VALGRIND="$(VALGRIND)" \
                PASS="$(PASS)" --tool rpc_test $(RUNTESTFLAGS) ; \
        then \
                echo Cleaning up... ; \
index 495472e672a0a048954187beca4211d15135cdb9..824d4634177cd44311473861dae4e9104162cbb6 100644 (file)
@@ -47,6 +47,49 @@ if { $PRIOCNTL_HACK } {
     }
 }
 
+if { [string length $VALGRIND] } {
+    rename spawn valgrind_aux_spawn
+    proc spawn { args } {
+       global VALGRIND
+       upvar 1 spawn_id spawn_id
+       set newargs {}
+       set inflags 1
+       set eatnext 0
+       foreach arg $args {
+           if { $arg == "-ignore" \
+                    || $arg == "-open" \
+                    || $arg == "-leaveopen" } {
+               lappend newargs $arg
+               set eatnext 1
+               continue
+           }
+           if [string match "-*" $arg] {
+               lappend newargs $arg
+               continue
+           }
+           if { $eatnext } {
+               set eatnext 0
+               lappend newargs $arg
+               continue
+           }
+           if { $inflags } {
+               set inflags 0
+               # Only run valgrind for local programs, not
+               # system ones.
+#&&![string match "/bin/sh" $arg] sh is used to start kadmind!
+               if [string match "/" [string index $arg 0]]&&![string match "/bin/ls" $arg]&&![regexp {/kshd$} $arg] {
+                   set newargs [concat $newargs $VALGRIND]
+               } elseif [string match "." [string index $arg 0]] {
+                   set newargs [concat $newargs $VALGRIND]
+               }
+           }
+           lappend newargs $arg
+       }
+       set pid [eval valgrind_aux_spawn $newargs]
+       return $pid
+    }
+}
+
 # this will initialize the database and keytab
 load_lib "helpers.exp"