[ovs-dev] [PATCH 07/10] tests: Fix race in "ofproto-dpif - ofproto-dpif-monitor 1" test.

Ben Pfaff blp at ovn.org
Wed Jan 27 17:51:26 UTC 2016


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 at ovn.org>
---
 tests/ofproto-dpif.at | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index e7b0839..195e68e 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -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])
 
 # 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])
 
 # enable both bfd and cfm on p0.
 AT_CHECK([ovs-vsctl set interface p0 bfd:enable=true cfm_mpid=10])
-- 
2.1.3




More information about the dev mailing list