It has been observed that sometimes Windows unit tests hang.
This happens when a daemon is started but does not get terminated
when the test ends.

In one particular case, OVS_VSWITCHD_STOP is called which inturn
calls 'ovs-appctl exit'. This causes ovs-vswitchd's atexit handler
to cleanup the pidfiles. After this, the pthread destructurs get
called and a deadlock happens in there. This results in the
daemons not getting force killed resulting in the tests hanging.

This commit stores the contents of pidfiles in different files.
This way, even if the pidfiles get deleted for any reason, we
can still kill the daemons.

This commit also changes the way daemons are force killed in
Windows. It was observed that 'taskkill //F ' failed to kill
a deadlocked daemon running its pthread destructor. But
tskill succeeds.

Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
 tests/ofproto-macros.at |    5 ++++-
 tests/ovs-macros.at     |    8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 93d8a77..d4dbd3f 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -49,7 +49,6 @@ m4_define([_OVS_VSWITCHD_START],
    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
    OVS_DBDIR=`pwd`; export OVS_DBDIR
    OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
-   ON_EXIT([kill `cat ovsdb-server.pid ovs-vswitchd.pid`])
 
    dnl Create database.
    touch .conf.db.~lock~
@@ -57,6 +56,8 @@ m4_define([_OVS_VSWITCHD_START],
 
    dnl Start ovsdb-server.
    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file 
--remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
+    cat ovsdb-server.pid > ovsdb_server_pid
+    ON_EXIT([kill `cat ovsdb_server_pid`])
    AT_CHECK([[sed < stderr '
 /vlog|INFO|opened log file/d
 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
@@ -68,6 +69,8 @@ m4_define([_OVS_VSWITCHD_START],
    dnl Start ovs-vswitchd.
    AT_CHECK([ovs-vswitchd $1 --detach --no-chdir --pidfile --log-file -vvconn 
-vofproto_dpif], [0], [], [stderr])
    AT_CAPTURE_FILE([ovs-vswitchd.log])
+   cat ovs-vswitchd.pid > ovs_vswitchd_pid
+   ON_EXIT([kill `cat ovs_vswitchd_pid`])
    AT_CHECK([[sed < stderr '
 /ovs_numa|INFO|Discovered /d
 /vlog|INFO|opened log file/d
diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 14edba3..eeb1491 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -55,12 +55,16 @@ if test "$IS_WIN32" = "yes"; then
             -[1-9]*)
                 shift
                 for i in $*; do
-                    taskkill //F //PID $i >/dev/null
+                    if tasklist //fi "PID eq $i" | grep $i >/dev/null; then
+                        tskill $i
+                    fi
                 done
                 ;;
             [1-9][0-9]*)
                 for i in $*; do
-                    taskkill //F //PID $i >/dev/null
+                    if tasklist //fi "PID eq $i" | grep $i >/dev/null; then
+                        tskill $i
+                    fi
                 done
                 ;;
         esac
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to