tests: Fix race in "ofproto-dpif - ofproto-dpif-monitor 1" test.
authorBen Pfaff <blp@ovn.org>
Thu, 28 Jan 2016 21:25:50 +0000 (13:25 -0800)
committerBen Pfaff <blp@ovn.org>
Thu, 28 Jan 2016 21:52:18 +0000 (13:52 -0800)
This test contained two commands that both read and overwrote
ovs-vswitchd.log, and then expected the running ovs-vswitchd to carry on
appending to it.   Depending on the shell implementation and the speed of
execution, and the libc implementation, this might not have the desired
effect.  This commit replaces this by a multi-step process that avoids
in-place replacement.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
tests/ofproto-dpif.at

index e7b0839..c29166e 100644 (file)
@@ -6697,7 +6697,7 @@ OVS_WAIT_UNTIL([grep "monitor thread created" ovs-vswitchd.log])
 AT_CHECK([ovs-vsctl set interface p0 bfd:enable=false])
 # check log.
 OVS_WAIT_UNTIL([grep "monitor thread terminated" ovs-vswitchd.log])
-AT_CHECK([cat ovs-vswitchd.log | sed -e '/^.*ofproto_dpif_monitor.*$/d' > ovs-vswitchd.log])
+AT_CHECK([sed -e '/^.*ofproto_dpif_monitor.*$/d' < ovs-vswitchd.log > tmp && mv tmp ovs-vswitchd.log && ovs-appctl vlog/reopen])
 
 # enable cfm on p0.
 AT_CHECK([ovs-vsctl set interface p0 cfm_mpid=10])
@@ -6707,7 +6707,7 @@ OVS_WAIT_UNTIL([grep "monitor thread created" ovs-vswitchd.log])
 AT_CHECK([ovs-vsctl remove interface p0 cfm_mpid 10])
 # check log.
 OVS_WAIT_UNTIL([grep "monitor thread terminated" ovs-vswitchd.log])
-AT_CHECK([cat ovs-vswitchd.log | sed -e '/^.*ofproto_dpif_monitor.*$/d' > ovs-vswitchd.log])
+AT_CHECK([sed -e '/^.*ofproto_dpif_monitor.*$/d' < ovs-vswitchd.log > tmp && mv tmp ovs-vswitchd.log && ovs-appctl vlog/reopen])
 
 # enable both bfd and cfm on p0.
 AT_CHECK([ovs-vsctl set interface p0 bfd:enable=true cfm_mpid=10])