Use valgrind in more cases if VALGRIND is set
authorKen Raeburn <raeburn@mit.edu>
Fri, 16 Jan 2009 00:33:00 +0000 (00:33 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 16 Jan 2009 00:33:00 +0000 (00:33 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21754 dc483132-0cff-0310-8789-dd5450dbe970

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

index 969ee8207ebd754a12760d830c50a796d1510767..37dfaca33facb7eafd562a3f487c7fd6a08be7df 100644 (file)
@@ -16,10 +16,10 @@ unit-test-body::
        $(ENV_SETUP) $(RUNTEST) --tool kpasswd KPASSWD=../kpasswd \
                KINIT=$(BUILDTOP)/clients/kinit/kinit \
                KDESTROY=$(BUILDTOP)/clients/kdestroy/kdestroy \
-               PRIOCNTL_HACK=@PRIOCNTL_HACK@
+               PRIOCNTL_HACK=@PRIOCNTL_HACK@ VALGRIND="$(VALGRIND)"
 
 unit-test-setup::
-       $(ENV_SETUP) $(START_SERVERS)
+       $(ENV_SETUP) $(VALGRIND) $(START_SERVERS)
 
 unit-test-cleanup::
        $(ENV_SETUP) $(STOP_SERVERS)
index bd8382e19e222289b667a112460e8f033cd8dc3b..479d77243755b8736ed0520e7cf3e14b125a0751 100644 (file)
@@ -1,3 +1,44 @@
+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]
+               }
+           }
+           lappend newargs $arg
+       }
+       set pid [eval valgrind_aux_spawn $newargs]
+       return $pid
+    }
+}
+
 # Hack around Solaris 9 kernel race condition that causes last output
 # from a pty to get dropped.
 if { $PRIOCNTL_HACK } {
index 8a3cad51ccab5e0f5a4115a92986f05013c2831a..f7f7fd85fee113d2a7bdf42124cab5a3013128f2 100644 (file)
@@ -87,28 +87,28 @@ unit-test-server: unit-test-server-setup unit-test-server-body \
        unit-test-server-cleanup
 
 test-randkey:: randkey-test
-       $(ENV_SETUP) ./randkey-test
+       $(ENV_SETUP) $(VALGRIND) ./randkey-test
 
 test-handle-server:: server-handle-test
-       $(ENV_SETUP) ./server-handle-test
+       $(ENV_SETUP) $(VALGRIND) ./server-handle-test
 
 test-handle-client:: client-handle-test
-       $(ENV_SETUP) ./client-handle-test
+       $(ENV_SETUP) $(VALGRIND) ./client-handle-test
 
 test-noauth: init-test
-       $(ENV_SETUP) ./init-test
+       $(ENV_SETUP) $(VALGRIND) ./init-test
 
 test-destroy: destroy-test
-       $(ENV_SETUP) ./destroy-test
+       $(ENV_SETUP) $(VALGRIND) ./destroy-test
 
 unit-test-client-setup::
-       $(ENV_SETUP) $(START_SERVERS)
+       $(ENV_SETUP) $(VALGRIND) $(START_SERVERS)
 
 unit-test-client-cleanup::
        $(ENV_SETUP) $(STOP_SERVERS)
 
 unit-test-server-setup::
-       $(ENV_SETUP) $(START_SERVERS_LOCAL)
+       $(ENV_SETUP) $(VALGRIND) $(START_SERVERS_LOCAL)
 
 unit-test-server-cleanup::
        $(ENV_SETUP) $(STOP_SERVERS_LOCAL)
@@ -118,7 +118,8 @@ unit-test-client-body: site.exp test-noauth test-destroy test-handle-client
                KINIT=$(BUILDTOP)/clients/kinit/kinit \
                KDESTROY=$(BUILDTOP)/clients/kdestroy/kdestroy \
                KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local \
-               PRIOCNTL_HACK=@PRIOCNTL_HACK@ $(RUNTESTFLAGS)
+               PRIOCNTL_HACK=@PRIOCNTL_HACK@ VALGRIND="$(VALGRIND)" \
+               $(RUNTESTFLAGS)
        -mv api.log capi.log
        -mv api.sum capi.sum
 
@@ -126,7 +127,8 @@ unit-test-server-body: site.exp test-handle-server lock-test
        $(ENV_SETUP) $(RUNTEST) --tool api RPC=0 API=$(SRVTCL) \
                LOCKTEST=./lock-test \
                KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local \
-               PRIOCNTL_HACK=@PRIOCNTL_HACK@ $(RUNTESTFLAGS)
+               PRIOCNTL_HACK=@PRIOCNTL_HACK@ VALGRIND="$(VALGRIND)" \
+               $(RUNTESTFLAGS)
        -mv api.log sapi.log
        -mv api.sum sapi.sum
 
index a78515f915bc8e0b8a87cdb407f76e54b9558473..3f366554701ca743c77bafeaedb1e8c96bb9c517 100644 (file)
@@ -14,6 +14,47 @@ if {[info exists exp_version_4]} {
        set wait_status_index 3
 }
 
+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]
+               }
+           }
+           lappend newargs $arg
+       }
+       set pid [eval valgrind_aux_spawn $newargs]
+       return $pid
+    }
+}
+
 # Hack around Solaris 9 kernel race condition that causes last output
 # from a pty to get dropped.
 if { $PRIOCNTL_HACK } {
index ee6f66e6038808d0eff03c6444d14a4ed3a9f70a..2b98dbba66bc5a81aa750701909af9469d0e775a 100644 (file)
@@ -49,7 +49,7 @@ unit-test-ok:: unit-test-body
 PASS=@PASS@
 unit-test-body:
        $(RM) krb5cc_rpc_test_*
-       $(ENV_SETUP) $(START_SERVERS)
+       $(ENV_SETUP) $(VALGRIND) $(START_SERVERS)
        RPC_TEST_SRVTAB=/tmp/rpc_test_v5srvtab.$$$$ ; export RPC_TEST_SRVTAB ; \
        trap "echo Failed, cleaning up... ; rm -f $$RPC_TEST_SRVTAB ; $(ENV_SETUP) $(STOP_SERVERS) ; trap '' 0 ; exit 1" 0 1 2 3 14 15 ; \
        if $(ENV_SETUP) \