Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / MProfile_Connection_Timeout / run_test.pl
blobfffacaefbb59a75d6f88cf63278d9e772c5ef362
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 $server1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $client = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
23 my $ior1file = "server1.ior";
24 my $ior2file = "server2.ior";
26 #Files which used by server1
27 my $server1_ior1file = $server1->LocalFile ($ior1file);
28 $server1->DeleteFile($ior1file);
30 #Files which used by server2
31 my $server2_ior2file = $server2->LocalFile ($ior2file);
32 $server2->DeleteFile($ior2file);
34 #Files which used by server2
35 my $client_ior1file = $client->LocalFile ($ior1file);
36 my $client_ior2file = $client->LocalFile ($ior2file);
37 $client->DeleteFile($ior1file);
38 $client->DeleteFile($ior2file);
40 $SV1 = $server1->CreateProcess ("server",
41 "-ORBdebuglevel $debug_level " .
42 "-o $server1_ior1file");
44 $SV2 = $server2->CreateProcess ("server",
45 "-ORBdebuglevel $debug_level " .
46 "-o $server2_ior2file " .
47 "-r");
49 $CL = $client->CreateProcess ("client",
50 "-k file://$ior1file " .
51 "-m file://$ior2file");
53 $server_status = $SV1->Spawn ();
55 if ($server_status != 0) {
56 print STDERR "ERROR: server returned $server_status\n";
57 exit 1;
60 $server_status = $SV2->Spawn ();
62 if ($server_status != 0) {
63 print STDERR "ERROR: server returned $server_status\n";
64 exit 1;
67 sub KillServers{
68 $SV1->Kill (); $SV1->TimedWait (1);
69 $SV2->Kill (); $SV2->TimedWait (1);
72 if ($server1->WaitForFileTimed ($ior1file,
73 $server1->ProcessStartWaitInterval()) == -1) {
74 print STDERR "ERROR: cannot find file <$server1_ior1file>\n";
75 KillServers ();
76 exit 1;
79 if ($server2->WaitForFileTimed ($ior2file,
80 $server2->ProcessStartWaitInterval()) == -1) {
81 print STDERR "ERROR: cannot find file <$server2_ior2file>\n";
82 KillServers ();
83 exit 1;
86 if ($server1->GetFile ($ior1file) == -1) {
87 print STDERR "ERROR: cannot retrieve file <$server1_ior1file>\n";
88 KillServers ();
89 exit 1;
91 if ($client->PutFile ($ior1file) == -1) {
92 print STDERR "ERROR: cannot set file <$client_ior1file>\n";
93 KillServers ();
94 exit 1;
97 if ($server2->GetFile ($ior2file) == -1) {
98 print STDERR "ERROR: cannot retrieve file <$server2_ior2file>\n";
99 KillServers ();
100 exit 1;
102 if ($client->PutFile ($ior2file) == -1) {
103 print STDERR "ERROR: cannot set file <$client_ior2file>\n";
104 KillServers ();
105 exit 1;
108 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 285);
110 if ($client_status != 0) {
111 print STDERR "ERROR: client returned $client_status\n";
112 $status = 1;
115 $server_status = $SV1->WaitKill ($server1->ProcessStopWaitInterval());
117 if ($server_status != 0) {
118 print STDERR "ERROR: server returned $server_status\n";
119 $status = 1;
122 $server_status = $SV2->WaitKill ($server2->ProcessStopWaitInterval());
124 if ($server_status != 0) {
125 print STDERR "ERROR: server returned $server_status\n";
126 $status = 1;
130 $server1->DeleteFile($ior1file);
131 $server2->DeleteFile($ior2file);
132 $client->DeleteFile($ior1file);
133 $client->DeleteFile($ior2file);
135 exit $status;