1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
8 # This run_test.pl does not use the standard harness as used by other
9 # run_test.pl. Since it is testing a behavior of TAO which is
10 # affected by environmental influences, it uses perl features as well
11 # as separate executables to obtain information about the environment
12 # so that it can inspect the information inside IORs and decide if
13 # that information is "correct" given the environment.
15 # At the end, it prints out a matrix of each permutation of the test
16 # and indicates whether or not that permutation FAILed.
19 use lib
"$ENV{ACE_ROOT}/bin";
20 use PerlACE
::TestTarget
;
32 my $server = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
34 $server->AddLibPath ($server->ExeSubDir ());
36 my $iorbase = "server.ior";
37 my $server_iorfile = $server->LocalFile ($iorbase);
38 my $database = "intf_run.data";
39 my $server_datafile = $server->LocalFile ($database);
40 $server->DeleteFile($iorbase);
41 $server->DeleteFile($database);
43 $LI = $server->CreateProcess ("list_interfaces");
44 $GI = $server->CreateProcess ("generate_ior");
45 $CI = $server->CreateProcess ("$ENV{TAO_ROOT}/utils/catior/tao_catior",
46 "-f $server_iorfile");
48 open (OLDOUT
, ">&STDOUT");
49 open (STDOUT
, ">$server_datafile") or die "can't redirect stdout: $!";
50 open (OLDERR
, ">&STDERR");
51 open (STDERR
, ">&STDOUT") or die "can't redirect stderror: $!";
53 $server_status = $LI->SpawnWaitKill ($server->ProcessStartWaitInterval());
55 open (STDOUT
, ">&OLDOUT");
56 open (STDERR
, ">&OLDERR");
58 open (INTERFACES
, "<$server_datafile") || die "Unable to open $server_datafile: $!\n";
59 chomp(@IPADDRS = <INTERFACES
>);
62 if ($server_status != 0) {
63 print STDERR
"ERROR: server returned $server_status\n";
67 # Fill up the array of hostnames; can't use the hostname() from
68 # Sys :: Hostname because it's too good at figuring out that IP
69 # addresses that aren't in a host table actually DO match to a host
70 # name. So, we use gethostbyaddr().
71 @HOSTNAMES = map { (gethostbyaddr(inet_aton
($_),AF_INET
))[0] || $_ } @IPADDRS;
73 $HN = hostname
(); # Shorthand so we do not have to use 'hostname' all over.
75 @PERL_IPADDRS = map { inet_ntoa
($_) || $_ } (gethostbyname($HN))[4];
78 # $TEST_DATA is a reference to an anonymous hash that has
79 # key: string representation/description of a test
80 # value: ref to anonymous array consisting of
81 # [0] = -ORBDottedDecimalAddresses value (must be 0 or 1)
82 # [1] = -ORBendpoint hosname spec (undef if not provided)
83 # [2] = -ORBendpoint "hostname_in_ior" value (undef if not provided)
84 # [3] = ref to array containing profiles expected in IOR
90 # This is kind of like a "truth table" for what should happen when
91 # -ORBDottedDecimalAddresses (DDA) and the "hostname_in_ior" (HIOR)
92 # option for -ORBListenEndpoints (nee -ORBEndpoint) interact. Note
93 # that DDA's default value is "0", so there is no way to have an
94 # unspecified value for DDA.
99 # DDA | hostspec | HIOR | Profile(s) in IOR
100 # --------------------------------------------------------------
101 # 0 | unspec | unspec | One profile for each interface
103 # TAO_IIOP_Acceptor::probe_interfaces(),
104 # where the host's name is that
105 # returned from a reverse lookup of
106 # the interface's address from
107 # whatever facility is doing
108 # name<->address translations for
111 "0:unspec:unspec" => [ 0, undef, undef, \
@HOSTNAMES ],
113 # 1 | unspec | unspec | One profile for each interface
115 # TAO_IIOP_Acceptor::probe_interfaces(),
116 # where the host's name is the IP
117 # address associated with the
120 "1:unspec:unspec" => [ 1, undef, undef, \
@IPADDRS ],
122 # 0 | "foo" | unspec | Exactly one profile where the
123 # host's name is "foo".
125 "0:$HN:unspec" => [ 0, $HN, undef, [$HN] ],
127 # 1 | "foo" | unspec | Exactly one profile where the
128 # host's name is the IP address
129 # from the name<->address
130 # translation for the host.
132 "1:$HN:unspec" => [ 1, $HN, undef, \
@PERL_IPADDRS ],
134 # X | unspec | "bar" | Exactly one profile where the
135 # host's name is "bar".
136 #"d/c:unspec:".$HN."_blech" => [ undef, undef, $HN."_blech", [$HN."_blech"] ],
137 #"d/c:unspec:blech" => [ undef, undef, "blech", ["blech"] ],
138 "0:unspec:blech" => [ 0, undef, "blech", ["blech"] ],
139 "1:unspec:blech" => [ 1, undef, "blech", ["blech"] ],
141 # X | "foo" | "bar" | Exactly one profile where the
142 # host's name is "bar".
143 #"d/c:$HN:".$HN."_blech" => [ undef, $HN, $HN."_blech", [$HN."_blech"] ],
144 #"d/c:$HN:blech" => [ undef, $HN, "blech", ["blech"] ],
145 "0:$HN:blech" => [ 0, $HN, "blech", ["blech"] ],
146 "1:$HN:blech" => [ 1, $HN, "blech", ["blech"] ],
151 # pass in undef for 'unspec' in the table
152 my ($dda, $endpointhost, $hior) = @_;
154 $dda = 0 if (!defined($dda));
155 $endpointhost = '' if (!defined($endpointhost));
156 $hior_opt = ($hior ne '') ?
"/hostname_in_ior=$hior" : '';
158 $server->DeleteFile($database);
160 $GI->Arguments ("-ORBListenEndpoints iiop://$endpointhost".$hior_opt." ".
161 "-ORBDottedDecimalAddresses $dda ".
162 "-o $server_iorfile");
164 $server_status = $GI->SpawnWaitKill ($server->ProcessStartWaitInterval());
166 if ($server_status != 0) {
167 print STDERR
"ERROR: server returned $server_status\n";
171 open (OLDOUT
, ">&STDOUT");
172 open (STDOUT
, ">$server_datafile") or die "can't redirect stdout: $!";
173 open (OLDERR
, ">&STDERR");
174 open (STDERR
, ">&STDOUT") or die "can't redirect stderror: $!";
176 $server_status = $CI->SpawnWaitKill ($server->ProcessStartWaitInterval());
178 open (STDOUT
, ">&OLDOUT");
179 open (STDERR
, ">&OLDERR");
181 if ($server_status != 0) {
182 print STDERR
"ERROR: server returned $server_status\n";
188 # print $GI->Executable()." ".$GI->Arguments()."\n";
189 # print $CI->Executable()." ".$CI->Arguments()."\n";
190 open (PIOR
, "<$server_datafile") || die "Unable to exec generate_ior: $!\n";
191 # print "XXX: $_" while (<PIOR>);
192 while ($line = <PIOR
>) {
193 # Need to look for the following lines:
194 # Host Name: <ipaddr_or_host>
196 # endpoint: <ipaddr_or_host>:<portnum>
199 # print "Looking at $line\n";
200 if ($line =~ /.*Host Name:\s+(.+)$/) {
202 # print "HN pushing $x\n";
204 } elsif ($line =~ /.*endpoint: ([^:]+):.*/) {
206 # print "EP pushing $x\n";
212 $server->DeleteFile($database);
218 # $are_equal = compare_arrays(\@frogs, \@toads);
220 my ($first, $second) = @_;
221 no warnings
; # silence spurious -w undef complaints
222 return 0 unless @
$first == @
$second;
224 @sorted_first = sort @
$first;
225 @sorted_second = sort @
$second;
227 $first = \
@sorted_first;
228 $second = \
@sorted_second;
229 for (my $i = 0; $i < @
$first; $i++) {
230 return 0 if $first->[$i] ne $second->[$i];
237 my ($test_info, $profiles_a) = @_;
239 print "$test_info: ", join(' ', @
$profiles_a), "\n";
243 my ($test_info, $found_profiles, $expected_profiles) = @_;
244 # &print_profiles($test_info, $profiles);
247 # Do number of found profiles match expected?
248 if ($#$found_profiles != $#$expected_profiles) {
249 push @
$failinfo, "(num IOR profiles[$#$found_profiles] != expected[$#$expected_profiles]";
252 # Really need to compare these as hashes to avoid ordering issues.
253 if (compare_arrays
($found_profiles, $expected_profiles) == 0) {
254 push @
$failinfo, "(profiles in IOR != profiles expected)";
255 push @
$failinfo, "Found profiles (".join(',', @
$found_profiles).")";
261 # Brute force implementation of each of the lines in the table above
264 | | -ORBendpoint
| | Expected
265 FAIL?
| DDA
| hostspec
| hostname_in_ior
| Profile
(s
) in IOR
266 *=============================================================================*
269 @
<<< | @
|| | @
<<<<<<<<<<<<<<<<<< | @
<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<
270 $pf, $dda, $endpointhost, $hior, $expected_prof_in_ior
271 ~~ | | | | ^<<<<<<<<<<<<<<<<<<<
272 $expected_prof_in_ior
273 ~ | Details
: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
275 ~~ | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
277 ------+-----+---------------------+----------------------+---------------------
281 for $test (sort keys %$TEST_DATA) {
282 my $testargs = $TEST_DATA->{$test};
283 my @p = &do_test
($testargs->[0], $testargs->[1], $testargs->[2]);
284 my $failinfo = &check_profiles
($test, \
@p, $TEST_DATA->{$test}[3]);
286 # Set up all the global vars so we can write our output
287 ($dda, $endpointhost, $hior) = split(':', $test);
288 $expected_prof_in_ior = join(',', @
{$TEST_DATA->{$test}[3]});
289 if ($#$failinfo != -1) {
291 $detail = join("\r", @
$failinfo);
300 $server->DeleteFile($iorbase);
301 $server->DeleteFile($database);
305 # @p = &do_test(0, undef, undef);
306 # &check_profiles("0 unspec unspec", \@p, \@HOSTNAMES);
308 # @p = &do_test(1, undef, undef);
309 # &check_profiles("1 unspec unspec", \@p, \@IPADDRS);
311 # @p = &do_test(0, hostname, undef);
312 # &check_profiles("0 ".hostname." undef", \@p, [hostname]);
314 # @p = &do_test(1, hostname, undef);
315 # &check_profiles("1 ".hostname." undef", \@p, [ inet_ntoa((gethostbyname(hostname))[4]) ] );
317 # @p = &do_test(undef, undef, hostname . "_blech");
318 # &check_profiles("undef undef ".hostname."_blech", \@p, [hostname."_blech"]);
320 # @p = &do_test(undef, hostname, hostname."_blech");
321 # &check_profiles("undef ".hostname." ".hostname."_blech", \@p, [hostname."_blech"]);