1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
From: Richard Hansen <rhansen@rhansen.org>
Date: Wed, 23 Nov 2022 02:11:16 -0500
Subject: Fix flawed default interface IP address tests
`ddclient::get_default_interface()` doesn't appear to return anything
on the salsa.debian.org CI runners, and subtests can't have 0
checks.
Also, some systems don't have IPv4 or IPv6 addresses on the default
interface.
Forwarded: https://github.com/ddclient/ddclient/pull/698
---
t/get_ip_from_if.pl | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/t/get_ip_from_if.pl b/t/get_ip_from_if.pl
index 6f08e5d..15c66a1 100644
--- a/t/get_ip_from_if.pl
+++ b/t/get_ip_from_if.pl
@@ -39,23 +39,30 @@ subtest "get_ip_from_interface tests" => sub {
}
};
-subtest "Get default interface and IP for test system" => sub {
+subtest "Get default interface and IP for test system (IPv4)" => sub {
my $interface = ddclient::get_default_interface(4);
- if ($interface) {
- isnt($interface, "lo", "Check for loopback 'lo'");
- isnt($interface, "lo0", "Check for loopback 'lo0'");
- my $ip1 = ddclient::get_ip_from_interface("default", 4);
- my $ip2 = ddclient::get_ip_from_interface($interface, 4);
- is($ip1, $ip2, "Check IPv4 from default interface");
+ plan(skip_all => 'no IPv4 interface') if !$interface;
+ isnt($interface, "lo", "Check for loopback 'lo'");
+ isnt($interface, "lo0", "Check for loopback 'lo0'");
+ my $ip1 = ddclient::get_ip_from_interface("default", 4);
+ my $ip2 = ddclient::get_ip_from_interface($interface, 4);
+ is($ip1, $ip2, "Check IPv4 from default interface");
+ SKIP: {
+ skip('default interface does not have an appropriate IPv4 addresses') if !$ip1;
ok(ddclient::is_ipv4($ip1), "Valid IPv4 from get_ip_from_interface($interface)");
}
- $interface = ddclient::get_default_interface(6);
- if ($interface) {
- isnt($interface, "lo", "Check for loopback 'lo'");
- isnt($interface, "lo0", "Check for loopback 'lo0'");
- my $ip1 = ddclient::get_ip_from_interface("default", 6);
- my $ip2 = ddclient::get_ip_from_interface($interface, 6);
- is($ip1, $ip2, "Check IPv6 from default interface");
+};
+
+subtest "Get default interface and IP for test system (IPv6)" => sub {
+ my $interface = ddclient::get_default_interface(6);
+ plan(skip_all => 'no IPv6 interface') if !$interface;
+ isnt($interface, "lo", "Check for loopback 'lo'");
+ isnt($interface, "lo0", "Check for loopback 'lo0'");
+ my $ip1 = ddclient::get_ip_from_interface("default", 6);
+ my $ip2 = ddclient::get_ip_from_interface($interface, 6);
+ is($ip1, $ip2, "Check IPv6 from default interface");
+ SKIP: {
+ skip('default interface does not have an appropriate IPv6 addresses') if !$ip1;
ok(ddclient::is_ipv6($ip1), "Valid IPv6 from get_ip_from_interface($interface)");
}
};
|