[pve-devel] [PATCH common] replace the smartmatch operator

Wolfgang Bumiller w.bumiller at proxmox.com
Wed May 11 14:50:21 CEST 2016


---
 test/etc_network_interfaces/runtest.pl           | 10 ++++++++++
 test/etc_network_interfaces/t.list-interfaces.pl |  4 +---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/etc_network_interfaces/runtest.pl b/test/etc_network_interfaces/runtest.pl
index 92cd7f8..3e0fc35 100755
--- a/test/etc_network_interfaces/runtest.pl
+++ b/test/etc_network_interfaces/runtest.pl
@@ -182,6 +182,16 @@ sub expect($) {
     diff($expected, $got);
 }
 
+# Compare two arrays of strings
+sub strarray_equals($$) {
+    my ($left, $right) = @_;
+    return ref($left) && ref($right) &&
+	   ref($left) eq 'ARRAY' &&
+	   ref($right) eq 'ARRAY' &&
+	   scalar(@$left) == scalar(@$right) &&
+	   !grep { $left->[$_] ne $right->[$_] } (0..(@$left-1));
+}
+
 ##
 ## Main test execution:
 ##
diff --git a/test/etc_network_interfaces/t.list-interfaces.pl b/test/etc_network_interfaces/t.list-interfaces.pl
index caffe88..a106377 100644
--- a/test/etc_network_interfaces/t.list-interfaces.pl
+++ b/test/etc_network_interfaces/t.list-interfaces.pl
@@ -1,5 +1,3 @@
-no warnings 'experimental::smartmatch';
-
 # Assuming eth0..3 and eth100
 # eth0 is part of vmbr0, eth100 is part of the OVS bridge vmbr1
 # vmbr0 has ipv4 and ipv6, OVS only ipv4
@@ -100,7 +98,7 @@ $ck->('eth100', ovs_type => 'OVSPort');
 $ck->('eth100', ovs_bridge => 'vmbr1');
 
 my $f100 = $ifaces->{vmbr0}->{families};
-die "invalid families defined for vmbr0: @$f100\n" unless [sort(@$f100)] ~~ ['inet', 'inet6'];
+die "invalid families defined for vmbr0: @$f100\n" if !strarray_equals($f100, ['inet', 'inet6']);
 
 # idempotency
 r(w());
-- 
2.1.4





More information about the pve-devel mailing list