Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / tests / FT_App / run_test_basic.pl
blob77383086883b0560d29befc8cde9e1935eba9aee
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 ########################
11 #command line options
12 #set defaults:
13 my($status) = 0;
15 my($verbose) = 0; # 1: report perl actions before executing them
16 my($debug_builds) = 0; # 0: use exes from Release directories
18 foreach $i (@ARGV) {
19 if ($i eq "--debug_build"){
20 $debug_builds = 1;
22 elsif ($i eq "-v"){
23 $verbose += 1;
27 my($build_directory) = "/Release";
28 if ( $debug_builds ) {
29 $build_directory = "";
32 if ( $verbose > 1) {
33 print "verbose: $verbose\n";
34 print "debug_builds: $debug_builds -> $build_directory\n";
37 my $server1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
38 my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
39 my $client = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
41 ######## Define files for targets
43 my $factory1_ior = "factory1.ior";
44 my $factory2_ior = "factory2.ior";
45 my $replica1_ior = "replica1.ior";
46 my $replica2_ior = "replica2.ior";
48 my $data_file = "persistent.dat";
50 # Files which used by server1
51 my $server1_factory1_ior = $server1->LocalFile ($factory1_ior);
52 my $server1_replica1_ior = $server1->LocalFile ($replica1_ior);
53 my $server1_data_file = $server1->LocalFile ($data_file);
55 # Files which used by server2
56 my $server2_factory2_ior = $server2->LocalFile ($factory2_ior);
57 my $server2_replica2_ior = $server2->LocalFile ($replica2_ior);
58 my $server2_data_file = $server2->LocalFile ($data_file);
60 # Files which used by client
61 my $client_replica1_ior = $client->LocalFile ($replica1_ior);
62 my $client_replica2_ior = $client->LocalFile ($replica2_ior);
64 # remove all files
65 $server1->DeleteFile ($factory1_ior);
66 $server1->DeleteFile ($replica1_ior);
67 $server1->DeleteFile ($data_file);
68 $server2->DeleteFile ($factory2_ior);
69 $server2->DeleteFile ($replica2_ior);
70 $server2->DeleteFile ($data_file);
71 $client->DeleteFile ($replica1_ior);
72 $client->DeleteFile ($replica2_ior);
74 ### Create process
75 $SV1 = $server1->CreateProcess ("./$build_directory/ft_replica",
76 "-o $server1_factory1_ior -t $server1_replica1_ior -q -f none -p $server1_data_file");
78 $SV2 = $server2->CreateProcess ("./$build_directory/ft_replica",
79 "-o $server2_factory2_ior -t $server2_replica2_ior -q -f none -p $server2_data_file");
81 $CL = $client->CreateProcess ("./$build_directory/ft_client",
82 "-f file://$client_replica1_ior -f file://$client_replica2_ior -c testscript");
86 print "\nTest: Starting replica 1 " . $SV1->CommandLine . "\n" if ($verbose);
88 $server_status = $SV1->Spawn ();
90 if ($server_status != 0) {
91 print STDERR "ERROR: server returned $server_status\n";
92 exit 1;
95 print "waiting for replica 1's IOR\n" if ($verbose);
97 if ($server1->WaitForFileTimed ($replica1_ior,
98 $server1->ProcessStartWaitInterval()) == -1) {
99 print STDERR "ERROR: cannot find file <$server1_replica1_ior>\n";
100 $SV1->Kill (); $SV1->TimedWait (1);
101 exit 1;
104 if ($server1->GetFile ($replica1_ior) == -1) {
105 print STDERR "ERROR: cannot retrieve file <$server1_replica1_ior>\n";
106 $SV1->Kill (); $SV1->TimedWait (1);
107 exit 1;
109 if ($client->PutFile ($replica1_ior) == -1) {
110 print STDERR "ERROR: cannot set file <$client_replica1_ior>\n";
111 $SV1->Kill (); $SV1->TimedWait (1);
112 exit 1;
116 print "\nTest: Starting replica 2 " . $SV2->CommandLine . "\n" if ($verbose);
118 $server_status = $SV2->Spawn ();
120 if ($server_status != 0) {
121 print STDERR "ERROR: server returned $server_status\n";
122 $SV1->Kill (); $SV1->TimedWait (1);
123 exit 1;
126 print "waiting for replica 2's IOR\n" if ($verbose);
128 if ($server2->WaitForFileTimed ($replica2_ior,
129 $server2->ProcessStartWaitInterval()) == -1) {
130 print STDERR "ERROR: cannot find file <$server2_replica2_ior>\n";
131 $SV1->Kill (); $SV1->TimedWait (1);
132 $SV2->Kill (); $SV2->TimedWait (1);
133 exit 1;
135 if ($server2->GetFile ($replica2_ior) == -1) {
136 print STDERR "ERROR: cannot retrieve file <$server2_replica2_ior>\n";
137 $SV1->Kill (); $SV1->TimedWait (1);
138 $SV2->Kill (); $SV2->TimedWait (1);
139 exit 1;
141 if ($client->PutFile ($replica2_ior) == -1) {
142 print STDERR "ERROR: cannot set file <$client_replica2_ior>\n";
143 $SV1->Kill (); $SV1->TimedWait (1);
144 $SV2->Kill (); $SV2->TimedWait (1);
145 exit 1;
148 print "\nTest: Starting client " . $CL->CommandLine . "\n" if ($verbose);
150 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 45);
152 if ($client_status != 0) {
153 print STDERR "ERROR: client returned $client_status\n";
154 $status = 1;
157 print "wait for server 1.\n" if ($verbose);
158 $server_status = $SV1->WaitKill ($server1->ProcessStopWaitInterval() + 50);
160 if ($server_status != 0) {
161 print STDERR "TEST ERROR: server returned $server_status\n";
162 $status = 1;
165 print "wait for server 2.\n" if ($verbose);
166 $server_status = $SV2->WaitKill ($server2->ProcessStopWaitInterval() + 50);
168 if ($server_status != 0) {
169 print STDERR "TEST ERROR: server returned $server_status\n";
170 $status = 1;
173 print "Clean up scratch files\n" if ($verbose);
175 # remove all files
176 $server1->DeleteFile ($factory1_ior);
177 $server1->DeleteFile ($replica1_ior);
178 $server1->DeleteFile ($data_file);
179 $server2->DeleteFile ($factory2_ior);
180 $server2->DeleteFile ($replica2_ior);
181 $server2->DeleteFile ($data_file);
182 $client->DeleteFile ($replica1_ior);
183 $client->DeleteFile ($replica2_ior);
185 exit $status;