diff mbox series

[ovs-dev,v5,3/8] tests: Use portable "test a = b", not "test a == b".

Message ID 20201112014559.1494128-4-blp@ovn.org
State Accepted
Headers show
Series Add DDlog implementation of ovn-northd | expand

Commit Message

Ben Pfaff Nov. 12, 2020, 1:45 a.m. UTC
"==" is a GNU extension to "test".  A pox upon it.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 tests/ovn.at        | 26 +++++++++++++-------------
 tests/system-ovn.at |  2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

Comments

Dumitru Ceara Nov. 12, 2020, 8:58 a.m. UTC | #1
On 11/12/20 2:45 AM, Ben Pfaff wrote:
> "==" is a GNU extension to "test".  A pox upon it.

:)

Interesting, I didn't know this and had to dig quite a bit because it's
not explicitly mentioned:

https://www.gnu.org/software/coreutils/manual/coreutils.html#String-tests

Whereas in the posix spec "==" doesn't show up:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---

In any case:

Acked-by: Dumitru Ceara <dceara@redhat.com>

Thanks,
Dumitru
Ben Pfaff Nov. 12, 2020, 5:06 p.m. UTC | #2
On Thu, Nov 12, 2020 at 09:58:22AM +0100, Dumitru Ceara wrote:
> On 11/12/20 2:45 AM, Ben Pfaff wrote:
> > "==" is a GNU extension to "test".  A pox upon it.
> 
> :)
> 
> Interesting, I didn't know this and had to dig quite a bit because it's
> not explicitly mentioned:
> 
> https://www.gnu.org/software/coreutils/manual/coreutils.html#String-tests

I didn't know it wasn't documented.  Maybe I will submit a documentation
patch.

> Whereas in the posix spec "==" doesn't show up:
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> 
> > 
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> 
> In any case:
> 
> Acked-by: Dumitru Ceara <dceara@redhat.com>

Thanks!  I noticed one more place to fix:

diff --git a/utilities/ovn-sim.in b/utilities/ovn-sim.in
index a05e4cd8a425..c87e075e52d1 100755
--- a/utilities/ovn-sim.in
+++ b/utilities/ovn-sim.in
@@ -241,7 +241,7 @@ EOF
 export -f ovn_start
 
 ovn_attach() {
-    if test "$1" == --help; then
+    if test "$1" = --help; then
         cat <<EOF
 $FUNCNAME: attach default sandbox to an interconnection network for OVN
 usage: $FUNCNAME NETWORK BRIDGE IP [MASKLEN]

I folded that one in and applied this to OVN master.
Ben Pfaff Nov. 12, 2020, 5:24 p.m. UTC | #3
On Thu, Nov 12, 2020 at 09:06:06AM -0800, Ben Pfaff wrote:
> On Thu, Nov 12, 2020 at 09:58:22AM +0100, Dumitru Ceara wrote:
> > On 11/12/20 2:45 AM, Ben Pfaff wrote:
> > > "==" is a GNU extension to "test".  A pox upon it.
> > 
> > :)
> > 
> > Interesting, I didn't know this and had to dig quite a bit because it's
> > not explicitly mentioned:
> > 
> > https://www.gnu.org/software/coreutils/manual/coreutils.html#String-tests
> 
> I didn't know it wasn't documented.  Maybe I will submit a documentation
> patch.

Done.  I guess it'll show up in the coreutils mailing list archive in a
bit.
Ben Pfaff Nov. 12, 2020, 5:52 p.m. UTC | #4
On Thu, Nov 12, 2020 at 09:24:42AM -0800, Ben Pfaff wrote:
> On Thu, Nov 12, 2020 at 09:06:06AM -0800, Ben Pfaff wrote:
> > On Thu, Nov 12, 2020 at 09:58:22AM +0100, Dumitru Ceara wrote:
> > > On 11/12/20 2:45 AM, Ben Pfaff wrote:
> > > > "==" is a GNU extension to "test".  A pox upon it.
> > > 
> > > :)
> > > 
> > > Interesting, I didn't know this and had to dig quite a bit because it's
> > > not explicitly mentioned:
> > > 
> > > https://www.gnu.org/software/coreutils/manual/coreutils.html#String-tests
> > 
> > I didn't know it wasn't documented.  Maybe I will submit a documentation
> > patch.
> 
> Done.  I guess it'll show up in the coreutils mailing list archive in a
> bit.

Yeah, here:
https://lists.gnu.org/archive/html/coreutils/2020-11/msg00014.html
diff mbox series

Patch

diff --git a/tests/ovn.at b/tests/ovn.at
index e95220a16514..d38bbebe0ad3 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -5506,7 +5506,7 @@  test_dhcp() {
         reply_dst_ip=${offer_ip}
     fi
 
-    if test "$dhcp_type" == "04"; then
+    if test "$dhcp_type" = "04"; then
         ciaddr=$offer_ip
     fi
 
@@ -12953,11 +12953,11 @@  for i in 1 2 3; do
                 -- lsp-set-addresses lp$i$j$k \
                    "f0:00:00:00:0$i:$j$k 192.168.$i$j.$k"
             # logical ports lp[12]?1 belongs to port group pg1
-            if test $i != 3 && test $k == 1; then
+            if test $i != 3 && test $k = 1; then
                 pg1_ports="$pg1_ports `get_lsp_uuid $i$j$k`"
             fi
             # logical ports lp[23]?2 belongs to port group pg2
-            if test $i != 1 && test $k == 2; then
+            if test $i != 1 && test $k = 2; then
                 pg2_ports="$pg2_ports `get_lsp_uuid $i$j$k`"
             fi
         done
@@ -13108,8 +13108,8 @@  for is in 1 2 3; do
                 if test $d != $s; then unicast=$d; else unicast=; fi
 
                 # packets matches ACL should be dropped
-                if test $id != 3 && test $kd == 1; then
-                    if test $is != 1 && test $ks == 2; then
+                if test $id != 3 && test $kd = 1; then
+                    if test $is != 1 && test $ks = 2; then
                         unicast=
                     fi
                 fi
@@ -13177,11 +13177,11 @@  for i in 1 2 3; do
                 -- lsp-set-addresses lp$i$j$k \
                    "f0:00:00:00:0$i:$j$k 192.168.$i$j.$k"
             # logical ports lp[12]?1 belongs to port group pg1
-            if test $i != 3 && test $k == 1; then
+            if test $i != 3 && test $k = 1; then
                 pg1_ports="$pg1_ports `get_lsp_uuid $i$j$k`"
             fi
             # logical ports lp[23]?2 belongs to port group pg2
-            if test $i != 1 && test $k == 2; then
+            if test $i != 1 && test $k = 2; then
                 pg2_ports="$pg2_ports `get_lsp_uuid $i$j$k`"
             fi
         done
@@ -13350,8 +13350,8 @@  for is in 1 2 3; do
                 if test $d != $s; then unicast=$d; else unicast=; fi
 
                 # packets matches ACL1 but not ACL2 should be dropped
-                if test $id != 3 && test $kd == 1; then
-                    if test $is == 1 || test $ks != 2; then
+                if test $id != 3 && test $kd = 1; then
+                    if test $is = 1 || test $ks != 2; then
                         unicast=
                     fi
                 fi
@@ -14578,7 +14578,7 @@  hv3_uuid=$(ovn-sbctl list chassis hv3 | grep uuid | awk '{print $3}')
 chassis=`ovn-sbctl --bare --columns chassis find port_binding \
 logical_port=ls1-lp_ext1`
 
-AT_CHECK([test x$chassis == x], [0], [])
+AT_CHECK([test x$chassis = x], [0], [])
 
 # Associate hagrp1 ha-chassis-group to ls1-lp_ext1
 ovn-nbctl --wait=hv set Logical_Switch_Port ls1-lp_ext1 \
@@ -22283,8 +22283,8 @@  echo hv3_ts=$hv3_ts
 hv_cfg_ts=$(ovn-nbctl get nb_global . hv_cfg_timestamp)
 check test "$hv3_ts" = "$hvt4"
 
-AT_CHECK([test x$(ovn-nbctl --print-wait-time --wait=sb sync | grep ms | wc -l) == x2])
-AT_CHECK([test x$(ovn-nbctl --print-wait-time --wait=hv sync | grep ms | wc -l) == x3])
+AT_CHECK([test x$(ovn-nbctl --print-wait-time --wait=sb sync | grep ms | wc -l) = x2])
+AT_CHECK([test x$(ovn-nbctl --print-wait-time --wait=hv sync | grep ms | wc -l) = x3])
 
 for i in $(seq 2 $n); do
     OVN_CLEANUP_SBOX([hv$i])
@@ -22911,7 +22911,7 @@  sleep 2
 # Check if the encap_rec changed (it should not have)
 encap_rec_mvtep1=$(ovn-sbctl --data=bare --no-heading --column encaps list chassis hv1)
 
-AT_CHECK([test "$encap_rec_mvtep" == "$encap_rec_mvtep1"], [0], [])
+AT_CHECK([test "$encap_rec_mvtep" = "$encap_rec_mvtep1"], [0], [])
 
 OVN_CLEANUP([hv1])
 AT_CLEANUP
diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 8bb8c439f4d6..ee9ce332c4a7 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -5555,7 +5555,7 @@  AT_CHECK([ovs-vsctl set interface ovs-public external-ids:ovn-egress-iface=true]
 OVS_WAIT_UNTIL([tc qdisc show | grep -q 'htb 1: dev ovs-public'])
 
 AT_CHECK([ovn-nbctl remove Logical_Switch_Port public options qos_burst=1000])
-OVS_WAIT_UNTIL([test "$(tc qdisc show | grep 'htb 1: dev ovs-public')" == ""])
+OVS_WAIT_UNTIL([test "$(tc qdisc show | grep 'htb 1: dev ovs-public')" = ""])
 
 kill $(pidof ovn-controller)