Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2247_Regression / run_test.pl
blob5d95c8c9c618ea7bb25833d9760dff681c21978a
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 $file1_ior = "file1.ior";
20 my $file2_ior = "file2.ior";
21 my $output_ior = "output.ior";
23 my $server1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
24 my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
25 my $managers_number = 4;
26 my @managers = ();
27 for ($i = 0; $i < $managers_number; $i++) {
28 $managers[$i] = PerlACE::TestTarget::create_target ($i + 3) || die "Create target $i + 3 failed\n";
31 my $server1_file1_ior = $server1->LocalFile($file1_ior);
32 my $server2_file2_ior = $server2->LocalFile($file2_ior);
33 my @managers_file1_ior = ();
34 my @managers_file2_ior = ();
35 my @managers_output_ior = ();
36 for ($i = 0; $i < $managers_number; $i++) {
37 $managers_file1_ior[$i] = $managers[$i]->LocalFile($file1_ior);
38 $managers_file2_ior[$i] = $managers[$i]->LocalFile($file2_ior);
39 $managers_output_ior[$i] = $managers[$i]->LocalFile($output_ior);
42 $SV1 = $server1->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server1_file1_ior -k KEY1");
43 $SV2 = $server2->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server2_file2_ior -k KEY2");
45 my @MNS_ARG_SUFFIX = ("", " -s", " -m", " -m -s");
47 @MNS = ();
48 for ($i = 0; $i < $managers_number; $i++) {
49 $MNS[$i] = $managers[$i]->CreateProcess ("Manager", "-a file://$managers_file1_ior[$i] -k KEY1 ".
50 "-b file://$managers_file2_ior[$i] -l KEY2 ".
51 "-c $managers_output_ior[$i]".$MNS_ARG_SUFFIX[$i]);
54 sub clean_all {
55 $server1->DeleteFile($file1_ior);
56 $server2->DeleteFile($file2_ior);
57 for ($i = 0; $i < $managers_number; $i++) {
58 $managers[$i]->DeleteFile($file1_ior);
59 $managers[$i]->DeleteFile($file2_ior);
60 $managers[$i]->DeleteFile($output_ior);
64 sub run_single {
65 clean_all();
67 my $name = $_[0];
68 my $mn_id = $_[1];
70 print STDERR "Starting $name test\n";
71 print STDERR "Starting Server 1\n";
72 my $server_result = $SV1->Spawn ();
73 if ($server_result != 0) {
74 print STDERR "ERROR: server 1 returned $server_status\n";
75 return 1;
78 if ($server1->WaitForFileTimed ($file1_ior,
79 $server1->ProcessStartWaitInterval()) == -1) {
80 print STDERR "ERROR: cannot find file <$server1_file1_ior>\n";
81 $SV1->Kill (); $SV1->TimedWait (1);
82 return 1;
85 if ($server1->GetFile ($file1_ior) == -1) {
86 print STDERR "ERROR: cannot retrieve file <$server1_file1_ior>\n";
87 $SV1->Kill (); $SV1->TimedWait (1);
88 return 1;
91 if ($managers[$mn_id]->PutFile ($file1_ior) == -1) {
92 print STDERR "ERROR: cannot set file <$managers_file1_ior[$mn_id]>\n";
93 $SV1->Kill (); $SV1->TimedWait (1);
94 return 1;
97 print STDERR "Starting $name Manager\n";
98 my $mn_status = $MNS[$mn_id]->SpawnWaitKill ($managers[$mn_id]->ProcessStartWaitInterval() + 15);
100 if ($mn_status != 0) {
101 print STDERR "ERROR: Manager $mn_id returned $mn_status\n";
102 $status = 1;
105 $server_status = $SV1->WaitKill ($server1->ProcessStopWaitInterval(), {self_crash => 1});
107 if ($server1_status != 0) {
108 print STDERR "ERROR: server 1 returned $server_status\n";
109 $status = 1;
112 return 0;
115 sub run_merged {
116 clean_all();
118 my $name = $_[0];
119 my $mn_id = $_[1];
121 print STDERR "Starting MERGED $name test\n";
122 print STDERR "Starting Server 1\n";
123 my $server_result = $SV1->Spawn ();
124 if ($server_result != 0) {
125 print STDERR "ERROR: server 1 returned $server_status\n";
126 return 1;
129 if ($server1->WaitForFileTimed ($file1_ior,
130 $server1->ProcessStartWaitInterval()) == -1) {
131 print STDERR "ERROR: cannot find file <$server1_file1_ior>\n";
132 $SV1->Kill (); $SV1->TimedWait (1);
133 return 1;
136 if ($server1->GetFile ($file1_ior) == -1) {
137 print STDERR "ERROR: cannot retrieve file <$server1_file1_ior>\n";
138 $SV1->Kill (); $SV1->TimedWait (1);
139 return 1;
142 if ($managers[$mn_id]->PutFile ($file1_ior) == -1) {
143 print STDERR "ERROR: cannot set file <$managers_file1_ior[$mn_id]>\n";
144 $SV1->Kill (); $SV1->TimedWait (1);
145 return 1;
148 print STDERR "Starting Server 2\n";
149 $server_result = $SV2->Spawn ();
150 if ($server_result != 0) {
151 print STDERR "ERROR: server 2 returned $server_status\n";
152 $SV1->Kill (); $SV1->TimedWait (1);
153 return 1;
156 if ($server2->WaitForFileTimed ($file2_ior,
157 $server2->ProcessStartWaitInterval()) == -1) {
158 print STDERR "ERROR: cannot find file <$server2_file2_ior>\n";
159 $SV2->Kill (); $SV2->TimedWait (1);
160 $SV1->Kill (); $SV1->TimedWait (1);
161 return 1;
164 if ($server2->GetFile ($file2_ior) == -1) {
165 print STDERR "ERROR: cannot retrieve file <$server2_file2_ior>\n";
166 $SV2->Kill (); $SV2->TimedWait (1);
167 $SV1->Kill (); $SV1->TimedWait (1);
168 return 1;
171 if ($managers[$mn_id]->PutFile ($file2_ior) == -1) {
172 print STDERR "ERROR: cannot set file <$managers_file2_ior[$mn_id]>\n";
173 $SV2->Kill (); $SV2->TimedWait (1);
174 $SV1->Kill (); $SV1->TimedWait (1);
175 return 1;
178 print STDERR "Starting $name Manager\n";
179 my $mn_status = $MNS[$mn_id]->SpawnWaitKill ($managers[$mn_id]->ProcessStartWaitInterval() + 15);
181 if ($mn_status != 0) {
182 print STDERR "ERROR: Manager $mn_id returned $mn_status\n";
183 $status = 1;
186 $server_status = $SV1->WaitKill ($server1->ProcessStopWaitInterval() + 5, {self_crash => 1});
188 if ($server1_status != 0) {
189 print STDERR "ERROR: server 1 returned $server_status\n";
190 $status = 1;
193 $server_status = $SV2->WaitKill ($server2->ProcessStopWaitInterval() + 5, {self_crash => 1});
195 if ($server_status != 0) {
196 print STDERR "ERROR: server 2 returned $server_status\n";
197 $status = 1;
200 return $status;
203 if (run_single("ABORT", 0) != 0) {
204 exit 1;
207 if (run_single("SHUTDOWN", 1) != 0) {
208 exit 1;
211 if (run_merged("ABORT", 2) != 0) {
212 exit 1;
215 if (run_merged("SHUTDOWN", 3) != 0) {
216 exit 1;
219 clean_all();
221 exit $status