ovs-vswitchd.at: Port tests to run successfully on Windows.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 6 Oct 2014 17:04:26 +0000 (10:04 -0700)
committerAlex Wang <alexw@nicira.com>
Thu, 9 Oct 2014 16:48:24 +0000 (09:48 -0700)
It is a little tricky to implement "$!" with unit tests on Windows.
This commit changes the tests so that it works both on Windows
and Linux.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
tests/ovs-vswitchd.at

index ed6a087..d3120f7 100644 (file)
@@ -72,27 +72,19 @@ AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process])
 OVS_VSWITCHD_START
 
 # start another ovs-vswitchd process.
-ovs-vswitchd --log-file=fakelog &
-pid=`echo $!`
+ovs-vswitchd --log-file=fakelog --unixctl="`pwd`"/unixctl &
 
 # sleep for a while
 sleep 5
 
 # stop the process.
-kill $pid
+ovs-appctl -t `pwd`/unixctl exit
 
 # check the fakelog, should only see one ERR for reporting
-# the existing ovs-vswitchd process and one WARN for killing
-# the process.
+# the existing ovs-vswitchd process.
 AT_CHECK([test `grep ERR fakelog | wc -l` -eq 1])
-AT_CHECK([test `grep WARN fakelog | wc -l` -eq 1])
-
-AT_CHECK([grep ERR fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
-another ovs-vswitchd process is running, disabling this process () until it goes away
-])
 
-# check the fakelog, the ERR log should be the last line.
-AT_CHECK([tail -n 2 fakelog | head -n 1 | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
+AT_CHECK([tail -n1 fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl
 another ovs-vswitchd process is running, disabling this process () until it goes away
 ])
 
@@ -104,8 +96,7 @@ AT_SETUP([ovs-vswitchd -- switch over to another ovs-vswitchd process])
 OVS_VSWITCHD_START
 
 # start a new ovs-vswitchd process.
-ovs-vswitchd --log-file=fakelog --enable-dummy &
-pid=`echo $!`
+ovs-vswitchd --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
 
 # sleep for a while.
 sleep 5
@@ -123,14 +114,13 @@ bridge br0: using datapath ID
 ])
 
 # stop the process.
-kill $pid
+ovs-appctl -t `pwd`/unixctl exit
 
 # check the fakelog, should not see WARN/ERR/EMER log other than the one
 # for reporting the existing ovs-vswitchd process and the one for killing
 # the process.
 AT_CHECK([sed -n "
 /|ERR|another ovs-vswitchd process is running/d
-/|WARN|terminating with signal/d
 /|WARN|/p
 /|ERR|/p
 /|EMER|/p" fakelog