Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / IPV6 / run_test.pl
blobcd2109e61bb4fc2e82b8f2ee4e55b78191a92db1
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 use lib "$ENV{ACE_ROOT}/bin";
8 use PerlACE::TestTarget;
10 $status = 0;
11 $debug_level = '0';
13 foreach $i (@ARGV) {
14 if ($i eq '-debug') {
15 $debug_level = '10';
19 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
22 my $iorbase = "server.ior";
23 my $server_iorfile = $server->LocalFile ($iorbase);
24 my $client_iorfile = $client->LocalFile ($iorbase);
25 $server->DeleteFile($iorbase);
26 $client->DeleteFile($iorbase);
28 # -*- perl -*-
29 $server_arg = "-ORBdebuglevel $debug_level -o $server_iorfile -ORBUseSharedProfile 0 ";
30 $client_arg = "-k file://$client_iorfile ";
32 @configurations =
34 description => "Testing server with '-ORBConnectIPV6Only 1'.\n",
35 server => "$server_arg -ORBConnectIPV6Only 1",
36 client => "$client_arg",
37 error => 0,
38 url => 0,
39 url_address => "",
40 },{
41 description => "Testing client with '-ORBPreferIPV6Interfaces 1'.\n",
42 server => "$server_arg ",
43 client => "$client_arg -ORBPreferIPV6Interfaces 1",
44 error => 0,
45 url => 0,
46 url_address => "",
47 },{
48 description => "Testing IPV4 server with client with '-ORBConnectIPV6Only 1'.\n",
49 server => "$server_arg -ORBListenEndpoints iiop://127.0.0.1",
50 client => "$client_arg -x -ORBConnectIPV6Only 1",
51 error => 1,
52 url => 0,
53 url_address => "",
54 },{
55 description => "Testing IPV4 server with client with '-ORBPreferIPV6Interfaces 1'.\n",
56 server => "$server_arg -ORBListenEndpoints iiop://127.0.0.1",
57 client => "$client_arg -ORBPreferIPV6Interfaces 1",
58 error => 0,
59 url => 0,
60 url_address => "",
61 },{
62 description => "Testing IPV4 server with client and URL-style IOR",
63 server => "$server_arg -ORBListenEndpoints iiop://0.0.0.0 -ORBObjRefStyle url",
64 client => "$client_arg",
65 error => 0,
66 url => 0,
67 url_address => "",
68 },{
69 description => "Testing IPV4 server with client and IPV6-forced URL",
70 server => "$server_arg -ORBListenEndpoints iiop://0.0.0.0 -ORBObjRefStyle url",
71 client => "-x",
72 error => 1,
73 url => 1,
74 url_address => "corbaloc:iiop:1.2\@[::1]:",
75 },{
76 description => "Testing IPV6 server with client and IPV4-forced URL",
77 server => "$server_arg -ORBListenEndpoints iiop://[::1] -ORBObjRefStyle url",
78 client => "-x",
79 error => 1,
80 url => 1,
81 url_address => "corbaloc:iiop:1.2\@127.0.0.1:",
82 },{
83 description => "Testing IPV6Only server with client and IPV4-forced URL",
84 server => "$server_arg -ORBConnectIPV6Only 1 -ORBObjRefStyle url",
85 client => "-x",
86 error => 1,
87 url => 1,
88 url_address => "corbaloc:iiop:1.2\@127.0.0.1:",
89 },{
90 description => "Testing server with client and IPV4-forced URL",
91 server => "$server_arg -ORBObjRefStyle url",
92 client => "",
93 error => 0,
94 url => 1,
95 url_address => "corbaloc:iiop:1.2\@127.0.0.1:",
100 sub run_test_
102 my $server_args = $_[0]->{server};
103 my $client_args = $_[0]->{client};
104 my $error = $_[0]->{error};
105 my $test_status = 0;
107 print STDERR "\n******************************************************\n";
108 print $_[0]->{description};
110 print "\nRunning server with the following args:\n$server_args\n\n";
112 $SV = $server->CreateProcess ("server", $server_args);
113 $server_status = $SV->Spawn ();
115 if ($server_status != 0) {
116 print STDERR "ERROR: server returned $server_status\n";
117 return 1;
120 if ($server->WaitForFileTimed ($iorbase,
121 $server->ProcessStartWaitInterval()) == -1) {
122 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
123 $SV->Kill (); $SV->TimedWait (1);
124 return 1;
127 if ($server->GetFile ($iorbase) == -1) {
128 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
129 $SV->Kill (); $SV->TimedWait (1);
130 return 1;
133 if ($client->PutFile ($iorbase) == -1) {
134 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
135 $SV->Kill (); $SV->TimedWait (1);
136 return 1;
139 if ($_[0]->{url}) {
140 my $fh;
141 open $fh, $client_iorfile;
142 my $url = <$fh>;
143 close $fh;
145 print "Changing corbaloc url from:\n$url\nto\n";
147 my $url_addr = $_[0]->{url_address};
148 if ($url =~ /corbaloc:iiop:1.[01234]\@[\[].*[\]]\:.*/) {
149 $url =~ s/(corbaloc:iiop:1.[01234]\@[\[].*[\]]\:)(.*)/$url_addr$2/;
151 else {
152 $url =~ s/(corbaloc:iiop:1.[01234]\@[^:]*\:)(.*)/$url_addr$2/;
154 print $url . "\n";
156 $client_args .= " -k \"$url\"";
159 print "\nRunning client with the following args:\n$client_args\n\n";
161 $CL = $client->CreateProcess ("client", $client_args);
163 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 285);
164 if ($client_status != 0) {
165 print STDERR "ERROR: client returned $client_status\n";
166 $test_status = 1;
169 if ($error) {
170 $server_status = $SV->TerminateWaitKill ($server->ProcessStopWaitInterval());
172 if ($server_status != 0) {
173 print STDERR "ERROR: server returned $server_status\n";
174 $test_status = 1;
177 else {
178 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
180 if ($server_status != 0) {
181 print STDERR "ERROR: server returned $server_status\n";
182 $test_status = 1;
186 return $test_status;
189 for $test (@configurations) {
190 if (run_test_($test) != 0) {
191 $status = 1;
194 $server->DeleteFile($iorbase);
195 $client->DeleteFile($iorbase);
198 exit $status;