Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2285_Regression / run_test2.pl
blob45db7ba8bed01f497b9ae74ff76367f9f8739cd3
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 $client = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
21 my $number_of_servers = 5;
23 #These files are used only in ServerRequest_Interceptor2.cpp for internal tasks.
24 my $last_exp_time = "last_expiration_time";
25 my $no_more_retries = "no_more_retries";
27 my @iorfiles = ();
28 my @servers = ();
29 my @servers_iorfile = ();
30 my @client_iorfiles = ();
31 my @SV = ();
33 for ($i = 0; $i < $number_of_servers + 1; $i++) {
34 $servers[$i] = PerlACE::TestTarget::create_target ($i + 2) || die "Create target $i + 2 failed\n";
35 $iorfiles[$i] = "n".$i.".ior";
37 $servers_iorfile[$i] = $servers[$i]->LocalFile($iorfiles[$i]);
38 $client_iorfiles[$i] = $client->LocalFile($iorfiles[$i]);
40 $servers[$i]->DeleteFile ($iorfiles[$i]);
41 $client->DeleteFile ($iorfiles[$i]);
42 $servers[$i]->DeleteFile ($last_exp_time);
43 $servers[$i]->DeleteFile ($no_more_retries);
45 $SV [$i] = $servers[$i]->CreateProcess("server2", "-n $i");
48 $CL = $client->CreateProcess ("client2", " -n $number_of_servers");
50 sub wait_get_send_ior {
51 my $number = $_[0];
52 if ($servers[$number]->WaitForFileTimed ($iorfiles[$number],
53 $servers[$number]->ProcessStartWaitInterval()) == -1) {
54 print STDERR "ERROR: cannot find file <$servers[$number]_iorfile>\n";
55 return 1;
58 if ($servers[$number]->GetFile ($iorfiles[$number]) == -1) {
59 print STDERR "ERROR: cannot retrieve file <$servers[$number]_iorfile>\n";
60 return 1;
63 if ($client->PutFile ($iorfiles[$number]) == -1) {
64 print STDERR "ERROR: cannot set file <$client_iorfiles[$number]>\n";
65 return 1;
68 return 0;
71 for($i = 0; $i < $number_of_servers; $i++) {
72 $process_status = $SV[$i]->Spawn ();
73 if ($process_status != 0) {
74 print STDERR "ERROR: server $i returned $process_status\n";
75 for ($j = 0; $j < $i + 1; $j++) {
76 $SV[$j]->Kill (); $SV[$j]->TimedWait (1);
78 exit 1;
82 # Loops are cheap.
83 for ($i = 0; $i < $number_of_servers; $i++) {
84 $result = wait_get_send_ior($i);
86 if ($result != 0) {
87 for ($j = 0; $j < $i + 1; $j++) {
88 $SV[$j]->Kill (); $SV[$j]->TimedWait (1);
90 exit 1;
94 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 285);
96 if ($client_status != 0) {
97 print STDERR "ERROR: client returned $client_status\n";
98 $status = 1;
102 for ($i = 0; $i < $number_of_servers; $i++) {
103 $server_status = $SV[$i]->WaitKill ($servers[$i]->ProcessStopWaitInterval(), {self_crash => 1});
105 if ($server_status < 0) {
106 print STDERR "ERROR: server $i returned $server_status\n";
107 $status = 1;
110 $servers[$i]->DeleteFile ($iorfiles[$i]);
111 $client->DeleteFile ($iorfiles[$i]);
112 $servers[$i]->DeleteFile ($last_exp_time);
113 $servers[$i]->DeleteFile ($no_more_retries);
116 exit $status;