summaryrefslogtreecommitdiff
path: root/TAO/tests/IOR_Endpoint_Hostnames
diff options
context:
space:
mode:
authordbudko <dbudko@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-02 10:08:36 +0000
committerdbudko <dbudko@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-12-02 10:08:36 +0000
commit9e260213f3fff6863390bd487c5c50edf4ff3ff9 (patch)
tree62346c0fbb1e2379aa980125e4a97c2d0467d321 /TAO/tests/IOR_Endpoint_Hostnames
parent07c3e73278a03c2eda94b29da9255c05df8dc780 (diff)
downloadATCD-9e260213f3fff6863390bd487c5c50edf4ff3ff9.tar.gz
Wed Dec 2 10:07:02 UTC 2009 Denis Budko <denis.budko@remedy.nl>
* orbsvcs/tests/Bug_1630_Regression/run_test.pl: * orbsvcs/tests/BiDir_CORBALOC/run_test.pl: * orbsvcs/tests/HTIOP/Hello/run_test.pl: * orbsvcs/tests/HTIOP/AMI/run_test.pl: * orbsvcs/tests/HTIOP/BiDirectional/run_test.pl: * orbsvcs/tests/Notify/Lanes/README: * orbsvcs/tests/Notify/Lanes/run_test.pl: * orbsvcs/tests/FaultTolerance/IOGR/run_test.pl: * orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/run_test.pl: * orbsvcs/tests/Bug_2248_Regression/run_test.pl: * orbsvcs/tests/Time/run_test.pl: * DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl: * tests/IOR_Endpoint_Hostnames/list_interfaces.cpp: * tests/IOR_Endpoint_Hostnames/generate_ior.cpp: * tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc: * tests/IOR_Endpoint_Hostnames/Makefile.am: * tests/IOR_Endpoint_Hostnames/run_test.pl: * tests/Bug_1482_Regression/run_test.pl: * tests/Nested_Upcall_Crash/run_test.pl: * examples/RTScheduling/Fixed_Priority_Scheduler/run_test.pl: * examples/RTScheduling/MIF_Scheduler/run_test.pl: * examples/AMH/Sink_Server/run_test.pl: * examples/Load_Balancing/run_test.pl: Tests are converted to use new test framework and added to fuzz build.
Diffstat (limited to 'TAO/tests/IOR_Endpoint_Hostnames')
-rw-r--r--TAO/tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc4
-rw-r--r--TAO/tests/IOR_Endpoint_Hostnames/Makefile.am10
-rw-r--r--TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp46
-rw-r--r--TAO/tests/IOR_Endpoint_Hostnames/list_interfaces.cpp142
-rwxr-xr-xTAO/tests/IOR_Endpoint_Hostnames/run_test.pl303
5 files changed, 369 insertions, 136 deletions
diff --git a/TAO/tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc b/TAO/tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc
index 5df1c80b09f..3d2f45850f7 100644
--- a/TAO/tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc
+++ b/TAO/tests/IOR_Endpoint_Hostnames/IOR_Endpoint_Hostnames.mpc
@@ -3,10 +3,12 @@
//
// $Id$
-project(list_interfaces) : aceexe {
+project(list_interfaces) : taoexe {
Source_Files {
list_interfaces.cpp
}
+ IDL_Files {
+ }
}
project(generate_ior) : taoserver {
diff --git a/TAO/tests/IOR_Endpoint_Hostnames/Makefile.am b/TAO/tests/IOR_Endpoint_Hostnames/Makefile.am
index 0631706aec2..61beaf2a28c 100644
--- a/TAO/tests/IOR_Endpoint_Hostnames/Makefile.am
+++ b/TAO/tests/IOR_Endpoint_Hostnames/Makefile.am
@@ -78,13 +78,17 @@ noinst_PROGRAMS += list_interfaces
list_interfaces_CPPFLAGS = \
-I$(ACE_ROOT) \
- -I$(ACE_BUILDDIR)
+ -I$(ACE_BUILDDIR) \
+ -I$(TAO_ROOT) \
+ -I$(TAO_BUILDDIR)
list_interfaces_SOURCES = \
- list_interfaces.cpp \
- bogus_i.h
+ list_interfaces.cpp
list_interfaces_LDADD = \
+ $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \
+ $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \
+ $(TAO_BUILDDIR)/tao/libTAO.la \
$(ACE_BUILDDIR)/ace/libACE.la
## Clean up template repositories, etc.
diff --git a/TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp b/TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp
index 5d00607fa99..8d13e5ff5f2 100644
--- a/TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp
+++ b/TAO/tests/IOR_Endpoint_Hostnames/generate_ior.cpp
@@ -6,10 +6,41 @@
#include "tao/corba.h"
#include "tao/PortableServer/PortableServer.h"
+#include "ace/Get_Opt.h"
#include "bogus_i.h"
-ACE_RCSID (IOR_Endpoint_Hostnames, generate_ior, "$Id$")
+ACE_RCSID (IOR_Endpoint_Hostnames,
+ generate_ior,
+ "$Id$")
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
@@ -26,6 +57,9 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if (CORBA::is_nil (rp.in()))
ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) panic: nil root poa\n"), 1);
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
bogus* bogus_impl = new bogus();
PortableServer::ServantBase_var owner_transfer(bogus_impl);
PortableServer::ObjectId_var id =
@@ -37,7 +71,15 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
CORBA::String_var ior =
orb->object_to_string (b.in());
- ACE_OS::printf ("%s\n", ior.in());
+ // Output the IOR to the <ior_output_file>
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s\n",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
orb->shutdown();
orb->destroy();
diff --git a/TAO/tests/IOR_Endpoint_Hostnames/list_interfaces.cpp b/TAO/tests/IOR_Endpoint_Hostnames/list_interfaces.cpp
index 5959a2e797c..cd7770af82b 100644
--- a/TAO/tests/IOR_Endpoint_Hostnames/list_interfaces.cpp
+++ b/TAO/tests/IOR_Endpoint_Hostnames/list_interfaces.cpp
@@ -5,13 +5,22 @@
// "expected results" for hostnames in IORs.
//
+#include "tao/corba.h"
#include "ace/ACE.h"
#include "ace/Auto_Ptr.h"
#include "ace/INET_Addr.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_stdio.h"
-ACE_RCSID (IOR_Endpoint_Hostnames, list_interfaces, "$Id$")
+ACE_RCSID (IOR_Endpoint_Hostnames,
+ list_interfaces,
+ "$Id$")
+
+#if defined (ACE_HAS_IPV6) && !defined (ACE_USES_IPV4_IPV6_MIGRATION)
+ACE_INET_Addr default_address (static_cast<unsigned short> (0), ACE_IPV6_ANY, AF_INET6);
+#else
+ACE_INET_Addr default_address (static_cast<unsigned short> (0), static_cast<ACE_UINT32> (INADDR_ANY));
+#endif /* ACE_HAS_IPV6 && !ACE_USES_IPV4_IPV6_MIGRATION */
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
@@ -19,12 +28,13 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
ACE_UNUSED_ARG (argc);
ACE_UNUSED_ARG (argv);
+ CORBA::ULong endpoint_count;
+ int def_type = AF_UNSPEC;
+
// network interfaces.
ACE_INET_Addr *if_addrs = 0;
size_t if_cnt = 0;
- unsigned long endpoint_count;
-
if (ACE::get_ip_interfaces (if_cnt,
if_addrs) != 0
&& errno != ENOTSUP)
@@ -43,25 +53,106 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
if_cnt = 1; // Force the network interface count to be one.
delete [] if_addrs;
- if_addrs = new ACE_INET_Addr[if_cnt];
+ ACE_NEW_RETURN (if_addrs,
+ ACE_INET_Addr[if_cnt],
+ -1);
}
// Scan for the loopback interface since it shouldn't be included in
// the list of cached hostnames unless it is the only interface.
size_t lo_cnt = 0; // Loopback interface count
for (size_t j = 0; j < if_cnt; ++j)
- if (if_addrs[j].get_ip_address () == INADDR_LOOPBACK)
- lo_cnt++;
+ if (if_addrs[j].is_loopback ())
+ ++lo_cnt;
+
+#if defined (ACE_HAS_IPV6)
+ size_t ipv4_cnt = 0;
+ size_t ipv4_lo_cnt = 0;
+ size_t ipv6_ll = 0;
+ bool ipv6_non_ll = false;
+ // Scan for IPv4 interfaces since these should not be included
+ // when IPv6-only is selected.
+ for (size_t j = 0; j < if_cnt; ++j)
+ if (if_addrs[j].get_type () != AF_INET6 ||
+ if_addrs[j].is_ipv4_mapped_ipv6 ())
+ {
+ ++ipv4_cnt;
+ if (if_addrs[j].is_loopback ())
+ ++ipv4_lo_cnt; // keep track of IPv4 loopback ifs
+ }
+ else if (!if_addrs[j].is_linklocal () &&
+ !if_addrs[j].is_loopback())
+ {
+ ipv6_non_ll = true; // we have at least 1 non-local IPv6 if
+ }
+ else if (// !orb_core->orb_params ()->use_ipv6_link_local () &&
+ if_addrs[j].is_linklocal ())
+ {
+ ++ipv6_ll; // count link local addrs to exclude them afterwards
+ }
+#endif /* ACE_HAS_IPV6 */
ACE_Auto_Basic_Array_Ptr<ACE_INET_Addr> safe_if_addrs (if_addrs);
+#if defined (ACE_HAS_IPV6)
+ bool ipv4_only = def_type == AF_INET;
+ bool ipv6_only = (def_type == AF_INET6); // ||
+ // orb_core->orb_params ()->connect_ipv6_only ();
+#if defined (ACE_WIN32)
+ if (default_address.get_type () == AF_INET)
+ ipv4_only = true;
+ else
+ ipv6_only = true;
+#endif /* ACE_WIN32 */
+ // If the loopback interface is the only interface then include it
+ // in the list of interfaces to query for a hostname, otherwise
+ // exclude it from the list.
+ bool ignore_lo;
+ if (ipv6_only)
+ // only exclude loopback if non-local if exists
+ ignore_lo = ipv6_non_ll;
+ else if (ipv4_only)
+ ignore_lo = ipv4_cnt != ipv4_lo_cnt;
+ else
+ ignore_lo = if_cnt != lo_cnt;
+
+ // Adjust counts for IPv6 only if required
+ size_t if_ok_cnt = if_cnt;
+ if (ipv6_only)
+ {
+ if_ok_cnt -= ipv4_cnt;
+ lo_cnt -= ipv4_lo_cnt;
+ ipv4_lo_cnt = 0;
+ }
+ else if (ipv4_only)
+ {
+ if_ok_cnt = ipv4_cnt;
+ lo_cnt = ipv4_lo_cnt;
+ ipv6_ll = 0;
+ }
+
+ // In case there are no non-local IPv6 ifs in the list only exclude
+ // IPv4 loopback.
+ // IPv6 loopback will be needed to successfully connect IPv6 clients
+ // in a localhost environment.
+ if (!ipv4_only && !ipv6_non_ll)
+ lo_cnt = ipv4_lo_cnt;
+
+ if (!ignore_lo)
+ endpoint_count = static_cast<CORBA::ULong> (if_ok_cnt - ipv6_ll);
+ else
+ endpoint_count = static_cast<CORBA::ULong> (if_ok_cnt - ipv6_ll - lo_cnt);
+#else /* ACE_HAS_IPV6 */
// If the loopback interface is the only interface then include it
// in the list of interfaces to query for a hostname, otherwise
// exclude it from the list.
- if (if_cnt == lo_cnt)
- endpoint_count = static_cast<unsigned long> (if_cnt);
+ bool ignore_lo;
+ ignore_lo = if_cnt != lo_cnt;
+ if (!ignore_lo)
+ endpoint_count = static_cast<CORBA::ULong> (if_cnt);
else
- endpoint_count = static_cast<unsigned long> (if_cnt - lo_cnt);
+ endpoint_count = static_cast<CORBA::ULong> (if_cnt - lo_cnt);
+#endif /* !ACE_HAS_IPV6 */
// The number of hosts/interfaces we want to cache may not be the
// same as the number of detected interfaces so keep a separate
@@ -70,16 +161,43 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
for (size_t i = 0; i < if_cnt; ++i)
{
+#if defined (ACE_HAS_IPV6)
+ // Ignore any loopback interface if there are other
+ // non-loopback interfaces.
+ if (ignore_lo &&
+ if_addrs[i].is_loopback () &&
+ (ipv4_only ||
+ ipv6_non_ll ||
+ if_addrs[i].get_type () != AF_INET6))
+ continue;
+
+ // Ignore any non-IPv4 interfaces when so required.
+ if (ipv4_only &&
+ (if_addrs[i].get_type () != AF_INET))
+ continue;
+
+ // Ignore any non-IPv6 interfaces when so required.
+ if (ipv6_only &&
+ (if_addrs[i].get_type () != AF_INET6 ||
+ if_addrs[i].is_ipv4_mapped_ipv6 ()))
+ continue;
+
+ // Ignore all IPv6 link local interfaces when so required.
+ if (// !orb_core->orb_params ()->use_ipv6_link_local () &&
+ if_addrs[i].is_linklocal ())
+ continue;
+#else /* ACE_HAS_IPV6 */
// Ignore any loopback interface if there are other
// non-loopback interfaces.
- if (if_cnt != lo_cnt &&
- if_addrs[i].get_ip_address() == INADDR_LOOPBACK)
+ if (ignore_lo &&
+ if_addrs[i].is_loopback ())
continue;
+#endif /* !ACE_HAS_IPV6 */
// Print the address as a string.
ACE_OS::printf ("%s\n", if_addrs[i].get_host_addr());
- host_cnt++;
+ ++host_cnt;
}
return 0;
diff --git a/TAO/tests/IOR_Endpoint_Hostnames/run_test.pl b/TAO/tests/IOR_Endpoint_Hostnames/run_test.pl
index 50ebf1fdd0c..4714f1130ba 100755
--- a/TAO/tests/IOR_Endpoint_Hostnames/run_test.pl
+++ b/TAO/tests/IOR_Endpoint_Hostnames/run_test.pl
@@ -18,28 +18,63 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
#
use lib "$ENV{ACE_ROOT}/bin";
-use PerlACE::Run_Test;
+use PerlACE::TestTarget;
+use Socket;
use Sys::Hostname;
-# Add the current directory to our execution path
-use Env qw(@PATH);
-push @PATH, $PerlACE::Process::ExeSubDir;
+$status = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
+
+my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+
+$server->AddLibPath ($PerlACE::Process::ExeSubDir);
-open STDERR, ">&STDOUT" or die "cannot dup STDERR to STDOUT: $!\n";
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $database = "intf_run.data";
+my $server_datafile = $server->LocalFile ($database);
+$server->DeleteFile($iorbase);
+$server->DeleteFile($database);
-open (INTERFACES, "list_interfaces|") || die "Unable to exec list_interfaces: $!\n";
-# We want this global...
+$LI = $server->CreateProcess ("list_interfaces");
+$GI = $server->CreateProcess ("generate_ior");
+$CI = $server->CreateProcess ("../../utils/catior/tao_catior",
+ "-f $server_iorfile");
+
+open (OLDOUT, ">&STDOUT");
+open (STDOUT, ">$server_datafile") or die "can't redirect stdout: $!";
+open (OLDERR, ">&STDERR");
+open (STDERR, ">&STDOUT") or die "can't redirect stderror: $!";
+
+$server_status = $LI->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+open (STDOUT, ">&OLDOUT");
+open (STDERR, ">&OLDERR");
+
+open (INTERFACES, "<$server_datafile") || die "Unable to open $server_datafile: $!\n";
chomp(@IPADDRS = <INTERFACES>);
close (INTERFACES);
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
+
# Fill up the array of hostnames; can't use the hostname() from
# Sys::Hostname because it's too good at figuring out that IP
# addresses that aren't in a host table actually DO match to a host
# name. So, we use gethostbyaddr().
-use Socket;
@HOSTNAMES = map { (gethostbyaddr(inet_aton($_),AF_INET))[0] || $_ } @IPADDRS;
-$HN = hostname; # Shorthand so we do not have to use 'hostname' all over.
+$HN = hostname(); # Shorthand so we do not have to use 'hostname' all over.
+
+@PERL_IPADDRS = map { inet_ntoa($_) || $_ } (gethostbyname($HN))[4];
#
# $TEST_DATA is a reference to an anonymous hash that has
@@ -75,7 +110,7 @@ $TEST_DATA = {
# name<->address translations for
# that host.
-"0:unspec:unspec" => [ 0, undef, undef, \@HOSTNAMES ],
+ "0:unspec:unspec" => [ 0, undef, undef, \@HOSTNAMES ],
# 1 | unspec | unspec | One profile for each interface
# discovered in
@@ -84,126 +119,153 @@ $TEST_DATA = {
# address associated with the
# interface.
-"1:unspec:unspec" => [ 1, undef, undef, \@IPADDRS ],
+ "1:unspec:unspec" => [ 1, undef, undef, \@IPADDRS ],
# 0 | "foo" | unspec | Exactly one profile where the
# host's name is "foo".
-"0:$HN:unspec" => [ 0, $HN, undef, [$HN] ],
+ "0:$HN:unspec" => [ 0, $HN, undef, [$HN] ],
# 1 | "foo" | unspec | Exactly one profile where the
# host's name is the IP address
# from the name<->address
# translation for the host.
-"1:$HN:unspec" => [ 1, $HN, undef, [ inet_ntoa((gethostbyname(hostname))[4]) ] ],
+ "1:$HN:unspec" => [ 1, $HN, undef, \@PERL_IPADDRS ],
# X | unspec | "bar" | Exactly one profile where the
# host's name is "bar".
#"d/c:unspec:".$HN."_blech" => [ undef, undef, $HN."_blech", [$HN."_blech"] ],
#"d/c:unspec:blech" => [ undef, undef, "blech", ["blech"] ],
-"0:unspec:blech" => [ 0, undef, "blech", ["blech"] ],
-"1:unspec:blech" => [ 1, undef, "blech", ["blech"] ],
+ "0:unspec:blech" => [ 0, undef, "blech", ["blech"] ],
+ "1:unspec:blech" => [ 1, undef, "blech", ["blech"] ],
#
# X | "foo" | "bar" | Exactly one profile where the
# host's name is "bar".
#"d/c:$HN:".$HN."_blech" => [ undef, $HN, $HN."_blech", [$HN."_blech"] ],
#"d/c:$HN:blech" => [ undef, $HN, "blech", ["blech"] ],
-"0:$HN:blech" => [ 0, $HN, "blech", ["blech"] ],
-"1:$HN:blech" => [ 1, $HN, "blech", ["blech"] ],
+ "0:$HN:blech" => [ 0, $HN, "blech", ["blech"] ],
+ "1:$HN:blech" => [ 1, $HN, "blech", ["blech"] ],
};
sub do_test {
- # pass in undef for 'unspec' in the table
- my ($dda, $endpointhost, $hior) = @_;
- $dda = 0 if (!defined($dda));
- $endpointhost = '' if (!defined($endpointhost));
- $hior_opt = ($hior ne '') ? "/hostname_in_ior=$hior" : '';
-
- my $command = "generate_ior " .
- "-ORBDottedDecimalAddresses $dda " .
- "-ORBendpoint iiop://$endpointhost".$hior_opt;
-
- my @profiles;
- my $line;
-# print "$command\n";
- open (PIOR, "$command | catior -x 2>&1 |")
- || die "Unable to exec generate_ior: $!\n";
-# print "XXX: $_" while (<PIOR>);
- while ($line = <PIOR>) {
- # Need to look for the following lines:
- # Host Name: <ipaddr_or_host>
- # and
- # endpoint: <ipaddr_or_host>:<portnum>
- chomp $line;
- my $x;
-# print "Looking at $line\n";
- if ($line =~ /.*Host Name:\s+(.+)$/) {
- chomp($x = $1);
-# print "HN pushing $x\n";
- push @profiles, $x;
+ # pass in undef for 'unspec' in the table
+ my ($dda, $endpointhost, $hior) = @_;
+
+ $dda = 0 if (!defined($dda));
+ $endpointhost = '' if (!defined($endpointhost));
+ $hior_opt = ($hior ne '') ? "/hostname_in_ior=$hior" : '';
+
+ $server->DeleteFile($database);
+
+ $GI->Arguments ("-ORBListenEndpoints iiop://$endpointhost".$hior_opt." ".
+ "-ORBDottedDecimalAddresses $dda ".
+ "-o $server_iorfile");
+
+ $server_status = $GI->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+ if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+ }
+
+ open (OLDOUT, ">&STDOUT");
+ open (STDOUT, ">$server_datafile") or die "can't redirect stdout: $!";
+ open (OLDERR, ">&STDERR");
+ open (STDERR, ">&STDOUT") or die "can't redirect stderror: $!";
+
+ $server_status = $CI->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+ open (STDOUT, ">&OLDOUT");
+ open (STDERR, ">&OLDERR");
+
+ if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
}
- elsif ($line =~ /.*endpoint: ([^:]+):.*/) {
- chomp($x = $1);
-# print "EP pushing $x\n";
- push @profiles, $x;
+
+ my @profiles;
+ my $line;
+# print $GI->Executable()." ".$GI->Arguments()."\n";
+# print $CI->Executable()." ".$CI->Arguments()."\n";
+ open (PIOR, "<$server_datafile") || die "Unable to exec generate_ior: $!\n";
+# print "XXX: $_" while (<PIOR>);
+ while ($line = <PIOR>) {
+ # Need to look for the following lines:
+ # Host Name: <ipaddr_or_host>
+ # and
+ # endpoint: <ipaddr_or_host>:<portnum>
+ chomp $line;
+ my $x;
+# print "Looking at $line\n";
+ if ($line =~ /.*Host Name:\s+(.+)$/) {
+ chomp($x = $1);
+# print "HN pushing $x\n";
+ push @profiles, $x;
+ } elsif ($line =~ /.*endpoint: ([^:]+):.*/) {
+ chomp($x = $1);
+# print "EP pushing $x\n";
+ push @profiles, $x;
+ }
}
- }
- close (PIOR);
+ close (PIOR);
- return @profiles;
-}
+ $server->DeleteFile($database);
+ return @profiles;
+}
# Usage:
-# $are_equal = compare_arrays(\@frogs, \@toads);
+# $are_equal = compare_arrays(\@frogs, \@toads);
sub compare_arrays {
- my ($first, $second) = @_;
- no warnings; # silence spurious -w undef complaints
- return 0 unless @$first == @$second;
- @sorted_first = sort @$first;
- @sorted_second = sort @$second;
- $first = \@sorted_first;
- $second = \@sorted_second;
- for (my $i = 0; $i < @$first; $i++) {
- return 0 if $first->[$i] ne $second->[$i];
- }
- return 1;
-}
+ my ($first, $second) = @_;
+ no warnings; # silence spurious -w undef complaints
+ return 0 unless @$first == @$second;
+
+ @sorted_first = sort @$first;
+ @sorted_second = sort @$second;
+ $first = \@sorted_first;
+ $second = \@sorted_second;
+ for (my $i = 0; $i < @$first; $i++) {
+ return 0 if $first->[$i] ne $second->[$i];
+ }
+
+ return 1;
+}
sub print_profiles {
- my ($test_info, $profiles_a) = @_;
+ my ($test_info, $profiles_a) = @_;
- print "$test_info: ", join(' ', @$profiles_a), "\n";
+ print "$test_info: ", join(' ', @$profiles_a), "\n";
}
sub check_profiles {
- my ($test_info, $found_profiles, $expected_profiles) = @_;
-# &print_profiles($test_info, $profiles);
-
- my $failinfo = [];
- # Do number of found profiles match expected?
- if ($#$found_profiles != $#$expected_profiles) {
- push @$failinfo, "(num IOR profiles[$#$found_profiles] != expected[$#$expected_profiles]";
- }
-
- # Really need to compare these as hashes to avoid ordering issues.
- if (compare_arrays ($found_profiles, $expected_profiles) == 0) {
- push @$failinfo, "(profiles in IOR != profiles expected)";
- push @$failinfo, "Found profiles (".join(',', @$found_profiles).")";
- }
-
- return $failinfo;
+ my ($test_info, $found_profiles, $expected_profiles) = @_;
+# &print_profiles($test_info, $profiles);
+
+ my $failinfo = [];
+ # Do number of found profiles match expected?
+ if ($#$found_profiles != $#$expected_profiles) {
+ push @$failinfo, "(num IOR profiles[$#$found_profiles] != expected[$#$expected_profiles]";
+ }
+
+ # Really need to compare these as hashes to avoid ordering issues.
+ if (compare_arrays ($found_profiles, $expected_profiles) == 0) {
+ push @$failinfo, "(profiles in IOR != profiles expected)";
+ push @$failinfo, "Found profiles (".join(',', @$found_profiles).")";
+ }
+
+ return $failinfo;
}
# Brute force implementation of each of the lines in the table above
format STDOUT_TOP =
- | | -ORBendpoint | | Expected
-FAIL? | DDA | hostspec | hostname_in_ior | Profile(s) in IOR
-===============================================================================
+ | | -ORBendpoint | | Expected
+FAIL? | DDA | hostspec | hostname_in_ior | Profile(s) in IOR
+*=============================================================================*
.
format STDOUT =
@<<< | @|| | @<<<<<<<<<<<<<<<<<< | @<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<
@@ -214,43 +276,48 @@ $pf, $dda, $endpointhost, $hior, $expected_prof_in_ior
$detail
~~ | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$detail
- +-----+---------------------+----------------------+---------------------
+------+-----+---------------------+----------------------+---------------------
.
$: = ', ';
-for $test (sort keys %$TEST_DATA) {
- my $testargs = $TEST_DATA->{$test};
- my @p = &do_test ($testargs->[0], $testargs->[1], $testargs->[2]);
- my $failinfo = &check_profiles ($test, \@p, $TEST_DATA->{$test}[3]);
-
- # Set up all the global vars so we can write our output
- ($dda, $endpointhost, $hior) = split(':', $test);
- $expected_prof_in_ior = join(',', @{$TEST_DATA->{$test}[3]});
- if ($#$failinfo != -1) {
- $pf = 'FAIL';
- $detail = join("\r", @$failinfo);
- }
- else {
- $pf = $detail = '';
- }
-
- write;
+for $test (sort keys %$TEST_DATA) {
+ my $testargs = $TEST_DATA->{$test};
+ my @p = &do_test ($testargs->[0], $testargs->[1], $testargs->[2]);
+ my $failinfo = &check_profiles ($test, \@p, $TEST_DATA->{$test}[3]);
+
+ # Set up all the global vars so we can write our output
+ ($dda, $endpointhost, $hior) = split(':', $test);
+ $expected_prof_in_ior = join(',', @{$TEST_DATA->{$test}[3]});
+ if ($#$failinfo != -1) {
+ $pf = 'FAIL';
+ $detail = join("\r", @$failinfo);
+ } else {
+ $pf = 'OK';
+ $detail = '';
+ }
+
+ write;
}
-exit;
-@p = &do_test(0, undef, undef);
-&check_profiles("0 unspec unspec", \@p, \@HOSTNAMES);
-@p = &do_test(1, undef, undef);
-&check_profiles("1 unspec unspec", \@p, \@IPADDRS);
+$server->DeleteFile($iorbase);
+$server->DeleteFile($database);
+
+exit $status;
+
+# @p = &do_test(0, undef, undef);
+# &check_profiles("0 unspec unspec", \@p, \@HOSTNAMES);
+
+# @p = &do_test(1, undef, undef);
+# &check_profiles("1 unspec unspec", \@p, \@IPADDRS);
-@p = &do_test(0, hostname, undef);
-&check_profiles("0 ".hostname." undef", \@p, [hostname]);
+# @p = &do_test(0, hostname, undef);
+# &check_profiles("0 ".hostname." undef", \@p, [hostname]);
-@p = &do_test(1, hostname, undef);
-&check_profiles("1 ".hostname." undef", \@p, [ inet_ntoa((gethostbyname(hostname))[4]) ] );
+# @p = &do_test(1, hostname, undef);
+# &check_profiles("1 ".hostname." undef", \@p, [ inet_ntoa((gethostbyname(hostname))[4]) ] );
-@p = &do_test(undef, undef, hostname . "_blech");
-&check_profiles("undef undef ".hostname."_blech", \@p, [hostname."_blech"]);
+# @p = &do_test(undef, undef, hostname . "_blech");
+# &check_profiles("undef undef ".hostname."_blech", \@p, [hostname."_blech"]);
-@p = &do_test(undef, hostname, hostname."_blech");
-&check_profiles("undef ".hostname." ".hostname."_blech", \@p, [hostname."_blech"]);
+# @p = &do_test(undef, hostname, hostname."_blech");
+# &check_profiles("undef ".hostname." ".hostname."_blech", \@p, [hostname."_blech"]);