Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Bug_1270_Regression / run_test.pl
blobece8ad06daad1d22ed3825b4901c32c56d5fd4b9
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';
12 $quick = 0;
14 foreach $i (@ARGV) {
15 if ($i eq '-debug') {
16 $debug_level = '10';
17 } elsif ($i eq '-quick') {
18 $quick = 1;
22 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
23 my $client1 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
24 my $client2 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
25 my $client3 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
27 my $iorbase = "server.ior";
28 my $server_iorfile = $server->LocalFile ($iorbase);
29 my $client1_iorfile = $client1->LocalFile ($iorbase);
30 my $client2_iorfile = $client2->LocalFile ($iorbase);
31 my $client3_iorfile = $client3->LocalFile ($iorbase);
32 $server->DeleteFile($iorbase);
33 $client1->DeleteFile($iorbase);
34 $client2->DeleteFile($iorbase);
35 $client3->DeleteFile($iorbase);
37 $SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile");
38 $CL1 = $client1->CreateProcess ("client", "-k file://$client1_iorfile");
39 $CL2 = $client2->CreateProcess ("client", "-k file://$client2_iorfile");
40 $CL3 = $client3->CreateProcess ("client", "-k file://$client3_iorfile");
42 $server_status = $SV->Spawn ();
44 if ($server_status != 0) {
45 print STDERR "ERROR: server returned $server_status\n";
46 exit 1;
49 if ($server->WaitForFileTimed ($iorbase,
50 $server->ProcessStartWaitInterval()) == -1) {
51 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
52 $SV->Kill (); $SV->TimedWait (1);
53 exit 1;
56 if ($server->GetFile ($iorbase) == -1) {
57 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
58 $SV->Kill (); $SV->TimedWait (1);
59 exit 1;
61 if ($client1->PutFile ($iorbase) == -1) {
62 print STDERR "ERROR: cannot set file <$client1_iorfile>\n";
63 $SV->Kill (); $SV->TimedWait (1);
64 exit 1;
66 if ($client2->PutFile ($iorbase) == -1) {
67 print STDERR "ERROR: cannot set file <$client2_iorfile>\n";
68 $SV->Kill (); $SV->TimedWait (1);
69 exit 1;
71 if ($client3->PutFile ($iorbase) == -1) {
72 print STDERR "ERROR: cannot set file <$client3_iorfile>\n";
73 $SV->Kill (); $SV->TimedWait (1);
74 exit 1;
77 local $start_time = time();
78 local $max_running_time = 240; # 4 minutes
79 local $elapsed = time() - $start_time;
81 if ($quick) {
82 $elapsed = 0;
83 $max_running_time = 1;
86 while($elapsed < $max_running_time) {
87 $client_status = $CL1->Spawn ();
88 if ($client_status != 0) {
89 print STDERR "ERROR: client returned $client_status\n";
90 $SV->Kill (); $SV->TimedWait (1);
91 exit 1;
94 $client_status = $CL2->Spawn ();
95 if ($client_status != 0) {
96 print STDERR "ERROR: client returned $client_status\n";
97 $SV->Kill (); $SV->TimedWait (1);
98 $CL1->Kill (); $CL1->TimedWait (1);
99 exit 1;
102 $client_status = $CL3->Spawn ();
103 if ($client_status != 0) {
104 print STDERR "ERROR: client returned $client_status\n";
105 $SV->Kill (); $SV->TimedWait (1);
106 $CL1->Kill (); $CL1->TimedWait (1);
107 $CL2->Kill (); $CL2->TimedWait (1);
108 exit 1;
111 $client_status = $CL1->WaitKill ($client1->ProcessStopWaitInterval() + 45, {self_crash => 1});
112 if ($client_status != 0) {
113 print STDERR "ERROR: client 1 returned $client_status\n";
114 $SV->Kill (); $SV->TimedWait (1);
115 $CL2->Kill (); $CL2->TimedWait (1);
116 $CL3->Kill (); $CL3->TimedWait (1);
117 exit 1;
120 $client_status = $CL2->WaitKill ($client2->ProcessStopWaitInterval() + 45, {self_crash => 1});
121 if ($client_status != 0) {
122 print STDERR "ERROR: client 2 returned $client_status\n";
123 $SV->Kill (); $SV->TimedWait (1);
124 $CL1->Kill (); $CL1->TimedWait (1);
125 $CL3->Kill (); $CL3->TimedWait (1);
126 exit 1;
129 $client_status = $CL3->WaitKill ($client3->ProcessStopWaitInterval() + 45, {self_crash => 1});
130 if ($client_status != 0) {
131 print STDERR "ERROR: client 3 returned $client_status\n";
132 $SV->Kill (); $SV->TimedWait (1);
133 $CL1->Kill (); $CL1->TimedWait (1);
134 $CL2->Kill (); $CL2->TimedWait (1);
135 exit 1;
138 $elapsed = time() - $start_time;
141 $SH = $client1->CreateProcess ("shutdown", "-k file://$client1_iorfile");
143 $client_status = $SH->SpawnWaitKill ($client1->ProcessStartWaitInterval());
145 if ($client_status != 0) {
146 print STDERR "ERROR: client returned $client_status\n";
147 $SV->Kill (); $SV->TimedWait (1);
148 exit 1;
151 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
153 if ($server_status != 0) {
154 print STDERR "ERROR: server returned $server_status\n";
155 $status = 1;
158 $server->DeleteFile($iorbase);
159 $client1->DeleteFile($iorbase);
160 $client2->DeleteFile($iorbase);
161 $client3->DeleteFile($iorbase);
163 exit $status;