tests: Always make ovsdb-server exit cleanly, to better find memory leaks.
authorBen Pfaff <blp@nicira.com>
Tue, 2 Feb 2010 22:16:06 +0000 (14:16 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 2 Feb 2010 23:21:09 +0000 (15:21 -0800)
"ovs-appctl exit" causes a cleaner shutdown than "kill" and in particular
lets ovsdb-server clean up better, which makes it easier to find real
memory leaks.

tests/ovs-vsctl.at
tests/ovsdb-idl.at
tests/ovsdb-server.at

index 2abc077..0d35d17 100644 (file)
@@ -9,7 +9,7 @@ m4_define([OVS_VSCTL_SETUP],
 dnl OVS_VSCTL_CLEANUP
 dnl
 dnl Kills off the database server.
-m4_define([OVS_VSCTL_CLEANUP], [test ! -e pid || kill `cat pid`])
+m4_define([OVS_VSCTL_CLEANUP], [OVSDB_SERVER_SHUTDOWN])
 
 dnl RUN_OVS_VSCTL(COMMAND, ...)
 dnl
index 1f55f5e..dcf3efc 100644 (file)
@@ -19,14 +19,14 @@ m4_define([OVSDB_CHECK_IDL],
    AT_KEYWORDS([ovsdb server idl positive $5])
    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
                   [0], [stdout], [ignore])
-   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/server-pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
+   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
    m4_if([$2], [], [],
-     [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat server-pid`])])
+     [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3], 
-            [0], [stdout], [ignore], [kill `cat server-pid`])
+            [0], [stdout], [ignore], [kill `cat pid`])
    AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl], [0], [$4], [],
-            [kill `cat server-pid`])
-   kill `cat server-pid`
+            [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
index 0d87524..0b02189 100644 (file)
@@ -1,5 +1,10 @@
 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
 
+m4_define([OVSDB_SERVER_SHUTDOWN], 
+  [cp pid savepid
+   AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
+   OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])])
+
 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
 #
 # Creates a database with the given SCHEMA, starts an ovsdb-server on
@@ -28,7 +33,7 @@ cat stdout >> output
 ])
    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
             [test ! -e pid || kill `cat pid`])
-   test ! -e pid || kill `cat pid`
+   OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
 EXECUTION_EXAMPLES
@@ -63,7 +68,7 @@ AT_CHECK(
 ]], 
   [ignore], 
   [test ! -e pid || kill `cat pid`])
-test ! -e pid || kill `cat pid`
+OVSDB_SERVER_SHUTDOWN
 AT_CLEANUP
 \f
 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
@@ -100,7 +105,7 @@ cat stdout >> output
 ])
    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
             [test ! -e pid || kill `cat pid`])
-   test ! -e pid || kill `cat pid`
+   OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
 EXECUTION_EXAMPLES