Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / NestedUpcall / MT_Client_Test / run_test.pl
bloba9fddc447ee41f3832e1e4a534bfcfd531fe6e88
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 $iterations = '10';
14 $number_threads = '2';
15 $server_iterations = '5';
18 foreach $i (@ARGV) {
19 if ($i eq '-debug') {
20 $debug_level = '10';
24 my $server1 = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
25 my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
26 my $client = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
28 my $ior1file = "server1.ior";
29 my $ior2file = "server2.ior";
31 #Files which used by server1
32 my $server1_ior1file = $server1->LocalFile ($ior1file);
33 $server1->DeleteFile($ior1file);
35 #Files which used by server2
36 my $server2_ior2file = $server2->LocalFile ($ior2file);
37 $server2->DeleteFile($ior2file);
39 #Files which used by server2
40 my $client_ior1file = $client->LocalFile ($ior1file);
41 my $client_ior2file = $client->LocalFile ($ior2file);
42 $client->DeleteFile($ior1file);
43 $client->DeleteFile($ior2file);
45 $SV1 = $server1->CreateProcess ("server",
46 "-ORBdebuglevel $debug_level " .
47 "-o $server1_ior1file");
49 $SV2 = $server2->CreateProcess ("server",
50 "-ORBdebuglevel $debug_level " .
51 "-o $server2_ior2file");
54 $CL = $client->CreateProcess ("client",
55 "-f $ior1file " .
56 "-g $ior2file " .
57 "-n $number_threads " .
58 "-i $iterations " .
59 "-s $server_iterations");
61 $server_status = $SV1->Spawn ();
63 if ($server_status != 0) {
64 print STDERR "ERROR: server returned $server_status\n";
65 exit 1;
68 $server_status = $SV2->Spawn ();
70 if ($server_status != 0) {
71 print STDERR "ERROR: server returned $server_status\n";
72 exit 1;
75 sub KillServers{
76 $SV1->Kill (); $SV1->TimedWait (1);
77 $SV2->Kill (); $SV2->TimedWait (1);
80 if ($server1->WaitForFileTimed ($ior1file,
81 $server1->ProcessStartWaitInterval()) == -1) {
82 print STDERR "ERROR: cannot find file <$server1_ior1file>\n";
83 KillServers ();
84 exit 1;
87 if ($server2->WaitForFileTimed ($ior2file,
88 $server2->ProcessStartWaitInterval()) == -1) {
89 print STDERR "ERROR: cannot find file <$server2_ior2file>\n";
90 KillServers ();
91 exit 1;
94 if ($server1->GetFile ($ior1file) == -1) {
95 print STDERR "ERROR: cannot retrieve file <$server1_ior1file>\n";
96 KillServers ();
97 exit 1;
99 if ($client->PutFile ($ior1file) == -1) {
100 print STDERR "ERROR: cannot set file <$client_ior1file>\n";
101 KillServers ();
102 exit 1;
105 if ($server2->GetFile ($ior2file) == -1) {
106 print STDERR "ERROR: cannot retrieve file <$server2_ior2file>\n";
107 KillServers ();
108 exit 1;
110 if ($client->PutFile ($ior2file) == -1) {
111 print STDERR "ERROR: cannot set file <$client_ior2file>\n";
112 KillServers ();
113 exit 1;
116 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 45);
118 if ($client_status != 0) {
119 print STDERR "ERROR: client returned $client_status\n";
120 $status = 1;
123 $server_status = $SV1->TerminateWaitKill ($server1->ProcessStopWaitInterval());
125 if ($server_status != 0) {
126 print STDERR "ERROR: server returned $server_status\n";
127 $status = 1;
130 $server_status = $SV2->TerminateWaitKill ($server2->ProcessStopWaitInterval());
132 if ($server_status != 0) {
133 print STDERR "ERROR: server returned $server_status\n";
134 $status = 1;
138 $server1->DeleteFile($ior1file);
139 $server2->DeleteFile($ior2file);
140 $client->DeleteFile($ior1file);
141 $client->DeleteFile($ior2file);
143 exit $status;