Skip to content

Commit

Permalink
ovs-vswitchd.at: Port tests to run successfully on Windows.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Alex Wang <[email protected]>
  • Loading branch information
shettyg committed Oct 6, 2014
1 parent b3fca24 commit 1786535
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions tests/ovs-vswitchd.at
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1786535

Please sign in to comment.