From: Tim Beale Date: Mon, 18 Mar 2019 04:55:39 +0000 (+1300) Subject: selftest: Restore IPs 12-16 for selftest client X-Git-Tag: tdb-1.4.1~617 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4d433aede8e08c1fec91ddb9ee7754275a13437;p=thirdparty%2Fsamba.git selftest: Restore IPs 12-16 for selftest client The assumption that tests only used the .11 IP was wrong. The winsreplication test tries to use multiple different IPs - CI doesn't fail when we remove the additional IPs, but it starts to skip test cases. + Update get_interfaces_config() and get_ipv4_addr() so we can add multiple different IPs for the same host. + Update selftest.pl so the client gets 6 IP addresses. + Update comments to better reflect this dependency. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 52109e99b6f..228bb29ecfe 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -514,7 +514,10 @@ foreach (@opt_include) { push (@includes, read_test_regexes($_)); } -my $interfaces = Samba::get_interfaces_config("client"); +# We give the selftest client 6 different IPv4 addresses to use. Most tests +# only use the first (.11) IP. Note that winsreplication.c is one test that +# uses the other IPs (search for iface_list_count()). +my $interfaces = Samba::get_interfaces_config("client", 6); my $clientdir = "$prefix_abs/client"; diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index f7332da893e..6f28a017b17 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -437,12 +437,11 @@ sub get_interface($) localnt4dc9 => 9, # 10 is spare - # 11 is used by selftest.pl for the client interface + # 11-16 are used by selftest.pl for the client.conf. Most tests only + # use the first .11 IP. However, some tests (like winsreplication) rely + # on the client having multiple IPs. client => 11, - # 12-16 have been historically reserved for the client, although - # aren't actually used - addc_no_nss => 17, addc_no_ntlm => 18, idmapadmember => 19, @@ -491,9 +490,15 @@ sub get_interface($) sub get_ipv4_addr { - (my $hostname) = @_; + my ($hostname, $iface_num) = @_; my $swiface = Samba::get_interface($hostname); + # Handle testenvs with multiple different addresses, i.e. IP multihoming. + # Currently only the selftest client has multiple IPv4 addresses. + if (defined($iface_num)) { + $swiface += $iface_num; + } + return "127.0.0.$swiface"; } @@ -509,11 +514,23 @@ sub get_ipv6_addr # addresses for testenv sub get_interfaces_config { - (my $hostname) = @_; - my $ipv4_addr = Samba::get_ipv4_addr($hostname); + my ($hostname, $num_ips) = @_; + my $interfaces = ""; + + # We give the client.conf multiple different IPv4 addresses. + # All other testenvs generally just have one IPv4 address. + if (! defined($num_ips)) { + $num_ips = 1; + } + for (my $i = 0; $i < $num_ips; $i++) { + my $ipv4_addr = Samba::get_ipv4_addr($hostname, $i); + $interfaces .= "$ipv4_addr/8 "; + } + my $ipv6_addr = Samba::get_ipv6_addr($hostname); + $interfaces .= "$ipv6_addr/64"; - return "$ipv4_addr/8 $ipv6_addr/64"; + return $interfaces; } sub cleanup_child($$)