Re: [ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-05-02 Thread Ben Pfaff
On Tue, May 02, 2017 at 02:48:00PM +0900, Takashi YAMAMOTO wrote:
> On Tue, May 2, 2017 at 5:21 AM, Ben Pfaff  wrote:
> 
> > On Fri, Apr 21, 2017 at 10:32:57AM +0900, YAMAMOTO Takashi wrote:
> > > NetBSD implementation of wc command outputs extra whitespaces
> > > like the following.  Tweak the test to success on such environments.
> > >
> > > % echo hoge|wc -l|hexdump -C
> > >   20 20 20 20 20 20 20 31  0a   |
> >  1.|
> > > 0009
> > > %
> > >
> > > The failing test was introduced by
> > > commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
> > > (ovn: Introduce distributed gateway port and "chassisredirect" port
> > binding)
> > >
> > > Signed-off-by: YAMAMOTO Takashi 
> >
> > Thanks a lot for this fix.
> >
> > This is not the first time we've had trouble with wc, and not the first
> > project where I've had trouble with wc.  POSIX standardizes the output
> > format for wc, but neither GNU or BSD honors the standard, and so it's
> > not even that a particular OS is at fault.
> >
> > Anyway, how about the following?  I believe that it will fix the problem
> > you're seeing, and it ought to avoid new problems of the same kind in
> > the future.  What do you think?
> >
> > Thanks,
> >
> > Ben.
> >
> > --8<--cut here-->8--
> >
> > From: Ben Pfaff 
> > Date: Mon, 1 May 2017 13:19:43 -0700
> > Subject: [PATCH] ovs-macros: Add helper to make 'wc' use POSIX compliant
> >  output format.
> >
> > Several times, we've had to fix tests that used 'wc' and expected a
> > particular output format.  POSIX is specific about the output format, but
> > neither GNU or BSD wc honors it.  This commit makes whatever 'wc' is on
> > the system use the POSIX output format.
> >
> > Signed-off-by: Ben Pfaff 
> >
> 
> good idea.  tested it on netbsd.
> Acked-by: YAMAMOTO Takashi 

Thanks for the review!  I applied this to master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-05-01 Thread Takashi YAMAMOTO
On Tue, May 2, 2017 at 5:21 AM, Ben Pfaff  wrote:

> On Fri, Apr 21, 2017 at 10:32:57AM +0900, YAMAMOTO Takashi wrote:
> > NetBSD implementation of wc command outputs extra whitespaces
> > like the following.  Tweak the test to success on such environments.
> >
> > % echo hoge|wc -l|hexdump -C
> >   20 20 20 20 20 20 20 31  0a   |
>  1.|
> > 0009
> > %
> >
> > The failing test was introduced by
> > commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
> > (ovn: Introduce distributed gateway port and "chassisredirect" port
> binding)
> >
> > Signed-off-by: YAMAMOTO Takashi 
>
> Thanks a lot for this fix.
>
> This is not the first time we've had trouble with wc, and not the first
> project where I've had trouble with wc.  POSIX standardizes the output
> format for wc, but neither GNU or BSD honors the standard, and so it's
> not even that a particular OS is at fault.
>
> Anyway, how about the following?  I believe that it will fix the problem
> you're seeing, and it ought to avoid new problems of the same kind in
> the future.  What do you think?
>
> Thanks,
>
> Ben.
>
> --8<--cut here-->8--
>
> From: Ben Pfaff 
> Date: Mon, 1 May 2017 13:19:43 -0700
> Subject: [PATCH] ovs-macros: Add helper to make 'wc' use POSIX compliant
>  output format.
>
> Several times, we've had to fix tests that used 'wc' and expected a
> particular output format.  POSIX is specific about the output format, but
> neither GNU or BSD wc honors it.  This commit makes whatever 'wc' is on
> the system use the POSIX output format.
>
> Signed-off-by: Ben Pfaff 
>

good idea.  tested it on netbsd.
Acked-by: YAMAMOTO Takashi 


> ---
>  tests/ovs-macros.at | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
> index 123c713395e4..37e72d992555 100644
> --- a/tests/ovs-macros.at
> +++ b/tests/ovs-macros.at
> @@ -114,6 +114,16 @@ parent_pid () {
>  ps -o ppid= -p $1
>  fi
>  }
> +
> +# Normalize the output of 'wc' to match POSIX.
> +# POSIX says 'wc' should print "%d %d %d", but GNU prints "%7d %7d %7d".
> +# POSIX says 'wc -l' should print "%d %s", but BSD prints "%8d".
> +#
> +# This fixes all of those (it will screw up filenames that contain
> +# multiple sequential spaces, but that doesn't really matter).
> +wc () {
> +   command wc "$@" | tr -s ' ' ' ' | sed 's/^ *//'
> +}
>  ]
>  m4_divert_pop([PREPARE_TESTS])
>
> --
> 2.10.2
>
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-05-01 Thread Ben Pfaff
On Fri, Apr 21, 2017 at 10:32:57AM +0900, YAMAMOTO Takashi wrote:
> NetBSD implementation of wc command outputs extra whitespaces
> like the following.  Tweak the test to success on such environments.
> 
> % echo hoge|wc -l|hexdump -C
>   20 20 20 20 20 20 20 31  0a   |   1.|
> 0009
> %
> 
> The failing test was introduced by
> commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
> (ovn: Introduce distributed gateway port and "chassisredirect" port binding)
> 
> Signed-off-by: YAMAMOTO Takashi 

Thanks a lot for this fix.

This is not the first time we've had trouble with wc, and not the first
project where I've had trouble with wc.  POSIX standardizes the output
format for wc, but neither GNU or BSD honors the standard, and so it's
not even that a particular OS is at fault.

Anyway, how about the following?  I believe that it will fix the problem
you're seeing, and it ought to avoid new problems of the same kind in
the future.  What do you think?

Thanks,

Ben.

--8<--cut here-->8--

From: Ben Pfaff 
Date: Mon, 1 May 2017 13:19:43 -0700
Subject: [PATCH] ovs-macros: Add helper to make 'wc' use POSIX compliant
 output format.

Several times, we've had to fix tests that used 'wc' and expected a
particular output format.  POSIX is specific about the output format, but
neither GNU or BSD wc honors it.  This commit makes whatever 'wc' is on
the system use the POSIX output format.

Signed-off-by: Ben Pfaff 
---
 tests/ovs-macros.at | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 123c713395e4..37e72d992555 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -114,6 +114,16 @@ parent_pid () {
 ps -o ppid= -p $1
 fi
 }
+
+# Normalize the output of 'wc' to match POSIX.
+# POSIX says 'wc' should print "%d %d %d", but GNU prints "%7d %7d %7d".
+# POSIX says 'wc -l' should print "%d %s", but BSD prints "%8d".
+#
+# This fixes all of those (it will screw up filenames that contain
+# multiple sequential spaces, but that doesn't really matter).
+wc () {
+   command wc "$@" | tr -s ' ' ' ' | sed 's/^ *//'
+}
 ]
 m4_divert_pop([PREPARE_TESTS])
 
-- 
2.10.2

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-04-23 Thread Takashi YAMAMOTO
On Mon, Apr 24, 2017 at 9:48 AM, Mickey Spiegel 
wrote:

>
> On Thu, Apr 20, 2017 at 6:32 PM, YAMAMOTO Takashi 
> wrote:
>
>> NetBSD implementation of wc command outputs extra whitespaces
>> like the following.  Tweak the test to success on such environments.
>>
>> % echo hoge|wc -l|hexdump -C
>>   20 20 20 20 20 20 20 31  0a   |
>>  1.|
>> 0009
>> %
>>
>> The failing test was introduced by
>> commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
>> (ovn: Introduce distributed gateway port and "chassisredirect" port
>> binding)
>>
>> Signed-off-by: YAMAMOTO Takashi 
>>
>
> There are three more in one of the tests in system-ovn.at, affecting make
> check-kernel.
>

sure.
but those tests seem heavily linux-centric anyway for other reasons.


>
> Acked-by: Mickey Spiegel 
>
>
>
>> ---
>>  tests/ovn.at | 18 ++
>>  1 file changed, 6 insertions(+), 12 deletions(-)
>>
>> diff --git a/tests/ovn.at b/tests/ovn.at
>> index af77c19..1bffc4c 100644
>> --- a/tests/ovn.at
>> +++ b/tests/ovn.at
>> @@ -6567,20 +6567,14 @@ as hv3 ovs-ofctl dump-flows br-int
>>  echo "--"
>>
>>  # Check that redirect mapping is programmed only on hv2
>> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep
>> =0x3,metadata=0x1 | wc -l], [0], [0
>> -])
>> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep
>> =0x3,metadata=0x1 | grep load:0x2- | wc -l], [0], [1
>> -])
>> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=33 | grep
>> =0x3,metadata=0x1 | wc -l` -eq 0])
>> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=33 | grep
>> =0x3,metadata=0x1 | grep load:0x2- | wc -l` -eq 1])
>>  # Check that hv1 sends chassisredirect port traffic to hv2
>> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep
>> =0x3,metadata=0x1 | grep output | wc -l], [0], [1
>> -])
>> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep
>> =0x3,metadata=0x1 | wc -l], [0], [0
>> -])
>> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=32 | grep
>> =0x3,metadata=0x1 | grep output | wc -l` -eq 1])
>> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=32 | grep
>> =0x3,metadata=0x1 | wc -l` -eq 0])
>>  # Check that arp reply on distributed gateway port is only programmed on
>> hv2
>> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep
>> =0x2,metadata=0x1 | wc -l], [0], [0
>> -])
>> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep
>> =0x2,metadata=0x1 | wc -l], [0], [1
>> -])
>> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int | grep arp | grep
>> =0x2,metadata=0x1 | wc -l` -eq 0])
>> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int | grep arp | grep
>> =0x2,metadata=0x1 | wc -l` -eq 1])
>>
>>
>>  ip_to_hex() {
>> --
>> 2.5.4 (Apple Git-61)
>>
>> ___
>> dev mailing list
>> d...@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>>
>
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-04-23 Thread Mickey Spiegel
On Thu, Apr 20, 2017 at 6:32 PM, YAMAMOTO Takashi  wrote:

> NetBSD implementation of wc command outputs extra whitespaces
> like the following.  Tweak the test to success on such environments.
>
> % echo hoge|wc -l|hexdump -C
>   20 20 20 20 20 20 20 31  0a   |   1.|
> 0009
> %
>
> The failing test was introduced by
> commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
> (ovn: Introduce distributed gateway port and "chassisredirect" port
> binding)
>
> Signed-off-by: YAMAMOTO Takashi 
>

There are three more in one of the tests in system-ovn.at, affecting make
check-kernel.

Acked-by: Mickey Spiegel 



> ---
>  tests/ovn.at | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/tests/ovn.at b/tests/ovn.at
> index af77c19..1bffc4c 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -6567,20 +6567,14 @@ as hv3 ovs-ofctl dump-flows br-int
>  echo "--"
>
>  # Check that redirect mapping is programmed only on hv2
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep
> =0x3,metadata=0x1 | wc -l], [0], [0
> -])
> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep
> =0x3,metadata=0x1 | grep load:0x2- | wc -l], [0], [1
> -])
> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=33 | grep
> =0x3,metadata=0x1 | wc -l` -eq 0])
> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=33 | grep
> =0x3,metadata=0x1 | grep load:0x2- | wc -l` -eq 1])
>  # Check that hv1 sends chassisredirect port traffic to hv2
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep
> =0x3,metadata=0x1 | grep output | wc -l], [0], [1
> -])
> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep
> =0x3,metadata=0x1 | wc -l], [0], [0
> -])
> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=32 | grep
> =0x3,metadata=0x1 | grep output | wc -l` -eq 1])
> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=32 | grep
> =0x3,metadata=0x1 | wc -l` -eq 0])
>  # Check that arp reply on distributed gateway port is only programmed on
> hv2
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep
> =0x2,metadata=0x1 | wc -l], [0], [0
> -])
> -AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep
> =0x2,metadata=0x1 | wc -l], [0], [1
> -])
> +AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int | grep arp | grep
> =0x2,metadata=0x1 | wc -l` -eq 0])
> +AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int | grep arp | grep
> =0x2,metadata=0x1 | wc -l` -eq 1])
>
>
>  ip_to_hex() {
> --
> 2.5.4 (Apple Git-61)
>
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ovn.at: Fix "ovn -- 1 LR with distributed router gateway port" test

2017-04-20 Thread YAMAMOTO Takashi
NetBSD implementation of wc command outputs extra whitespaces
like the following.  Tweak the test to success on such environments.

% echo hoge|wc -l|hexdump -C
  20 20 20 20 20 20 20 31  0a   |   1.|
0009
%

The failing test was introduced by
commit 41a15b71ed1ef35aa612a1128082219fbfc3f327
(ovn: Introduce distributed gateway port and "chassisredirect" port binding)

Signed-off-by: YAMAMOTO Takashi 
---
 tests/ovn.at | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/tests/ovn.at b/tests/ovn.at
index af77c19..1bffc4c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -6567,20 +6567,14 @@ as hv3 ovs-ofctl dump-flows br-int
 echo "--"
 
 # Check that redirect mapping is programmed only on hv2
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 
| wc -l], [0], [0
-])
-AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 
| grep load:0x2- | wc -l], [0], [1
-])
+AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=33 | grep 
=0x3,metadata=0x1 | wc -l` -eq 0])
+AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=33 | grep 
=0x3,metadata=0x1 | grep load:0x2- | wc -l` -eq 1])
 # Check that hv1 sends chassisredirect port traffic to hv2
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 
| grep output | wc -l], [0], [1
-])
-AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 
| wc -l], [0], [0
-])
+AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int table=32 | grep 
=0x3,metadata=0x1 | grep output | wc -l` -eq 1])
+AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int table=32 | grep 
=0x3,metadata=0x1 | wc -l` -eq 0])
 # Check that arp reply on distributed gateway port is only programmed on hv2
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep 
=0x2,metadata=0x1 | wc -l], [0], [0
-])
-AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep 
=0x2,metadata=0x1 | wc -l], [0], [1
-])
+AT_CHECK([test `as hv1 ovs-ofctl dump-flows br-int | grep arp | grep 
=0x2,metadata=0x1 | wc -l` -eq 0])
+AT_CHECK([test `as hv2 ovs-ofctl dump-flows br-int | grep arp | grep 
=0x2,metadata=0x1 | wc -l` -eq 1])
 
 
 ip_to_hex() {
-- 
2.5.4 (Apple Git-61)

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev