[ovs-dev] [PATCH v2] tests: Avoid nonportable "sed -i".

Alex Wang alexw at nicira.com
Thu Aug 27 07:48:41 UTC 2015


Since the check_log() only uses $1, this still does not totally fix the
problem,

How about something like this?

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 0dc208e..f0a58a5 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -128,7 +128,12 @@ check_logs () {
         esac
     done

-    sed -n "$1
+    local filters
+    for filter; do
+        filters=$(printf "${filters}\n${filter}")
+    done
+
+    sed -n "${filters}
 /timeval.*Unreasonably long [[0-9]]*ms poll interval/d
 /timeval.*faults: [[0-9]]* minor, [[0-9]]* major/d
 /timeval.*disk: [[0-9]]* reads, [[0-9]]* writes/d

On Wed, Aug 26, 2015 at 3:55 PM, Ben Pfaff <blp at nicira.com> wrote:

> "sed -i" isn't entirely portable, and we can avoid it by using the
> argument to check_logs as intended.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> Acked-by: Alex Wang <alexw at nicira.com>
> ---
> v1->v2: Retain $1 in check_logs call from OVN_CONTROLLER_VTEP_STOP.
>   Also drop other, now-unneeded, call to "sed -i".
>
>  tests/ovn-controller-vtep.at | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/tests/ovn-controller-vtep.at b/tests/ovn-controller-vtep.at
> index 9fc1526..50a7096 100644
> --- a/tests/ovn-controller-vtep.at
> +++ b/tests/ovn-controller-vtep.at
> @@ -89,8 +89,7 @@ m4_define([OVN_CONTROLLER_VTEP_STOP],
>     # sending update back to *ctl command if *ctl has not proceeded to
> exit yet.
>     # and if *ctl command exits before database calling send, the send from
>     # database will fail with 'Broken pipe' error.
> -   AT_CHECK([sed -i '/Broken pipe/d' ovsdb-server.log])
> -   AT_CHECK([check_logs $1])
> +   AT_CHECK([check_logs $1 '/Broken pipe/d'])
>     AT_CHECK([ovs-appctl -t ovs-vtep exit])
>     AT_CHECK([ovs-appctl -t ovn-northd exit])
>     AT_CHECK([ovs-appctl -t ovn-controller-vtep exit])
> @@ -131,10 +130,6 @@ OVS_WAIT_UNTIL([test -n "`grep WARN
> ovn-controller-vtep.log`"])
>  AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log], [0],
> [dnl
>  |WARN|Chassis for VTEP physical switch (br-vtep) disappears, maybe
> deleted by ovn-sbctl, adding it back
>  ])
> -# this removal of chassis could cause 'Broken pipe' warning in the
> ovsdb-server.log,
> -# due to the race between 'ovn-sbctl' exiting and 'ovn-controller-vtep'
> adding
> -# the chassis back.  so just removes the 'Broken pipe' warning from
> ovsdb-server.log.
> -AT_CHECK([sed -i '/Broken pipe/d' ovsdb-server.log])
>
>  # changes the tunnel_ip on physical switch, watches the update of
> chassis's
>  # encap.
> --
> 2.1.3
>
>



More information about the dev mailing list