Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / CSD_Strategy_Tests / TP_Test_3 / run_test.pl
blob26fcb1c6e7e0fff243319964121eb081bc017031
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 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
11 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
13 $server->AddLibPath ('../TP_Foo_A/.');
14 $client->AddLibPath ('../TP_Foo_A/.');
15 $server->AddLibPath ('../TP_Foo_B/.');
16 $client->AddLibPath ('../TP_Foo_B/.');
17 $server->AddLibPath ('../TP_Foo_C/.');
18 $client->AddLibPath ('../TP_Foo_C/.');
19 $server->AddLibPath ('../TP_Common/.');
20 $client->AddLibPath ('../TP_Common/.');
22 my $status = 0;
24 my $iorfname_prefix = "servant";
25 my $num_servants = 1;
26 my $num_orb_threads = 1;
27 my $num_remote_clients = 1;
28 my $num_csd_threads = 1;
29 my $num_collocated_clients = 0;
30 my $collocated_client_kind = 0;
31 my $client_kind = 0;
33 my $i;
34 my $j;
35 my @iorbase;
36 my @server_iorfile;
37 my @client_iorfile;
39 my $ARGC = @ARGV;
41 if ($ARGC > 0) {
42 if ($ARGC > 1) {
43 print STDERR "ERROR: Too many command-line arguments for $0.\n";
44 exit 1;
47 my $subtest = $ARGV[0];
49 if ($subtest eq 'remote') {
50 $num_remote_clients = 40;
52 elsif ($subtest eq 'collocated') {
53 $num_remote_clients = 0;
54 $num_collocated_clients = 1;
55 $num_csd_threads=1;
57 elsif ($subtest eq 'remote_orbthreads') {
58 $num_orb_threads = 5;
59 $num_remote_clients = 40;
61 elsif ($subtest eq 'remote_servants') {
62 $num_servants = 5;
63 $num_remote_clients = 40;
65 elsif ($subtest eq 'remote_csdthreads') {
66 $num_csd_threads = 5;
67 $num_remote_clients = 40;
69 elsif ($subtest eq 'remote_big') {
70 $num_csd_threads = 5;
71 $num_servants = 10;
72 $num_orb_threads = 4;
73 $num_remote_clients = 40;
75 elsif ($subtest eq 'big') {
76 $num_csd_threads = 5;
77 $num_servants = 10;
78 $num_orb_threads = 4;
79 $num_remote_clients = 40;
80 $num_collocated_clients = 40;
82 elsif ($subtest eq 'usage') {
83 print STDOUT "Usage: $0 [<subtest>]\n" .
84 "\n" .
85 "Supported <subtest> values:\n" .
86 "\n" .
87 "\tremote\n" .
88 "\tcollocated\n" .
89 "\tremote_orbthreads\n" .
90 "\tremote_servants\n" .
91 "\tremote_csdthreads\n" .
92 "\tremote_big\n" .
93 "\tusage\n" .
94 "\n";
95 exit 0;
97 else {
98 print STDERR "ERROR: invalid subtest argument for $0: $subtest\n";
99 exit 1;
103 #Fill array and delete old ior files.
104 for ($i = 0; $i < $num_servants; $i++) {
105 my $servant_id = sprintf("%02d", ($i + 1));
106 $iorbase[$i] = $iorfname_prefix . "_$servant_id.ior";
107 $server_iorfile[$i] = $server->LocalFile($iorbase[$i]);
108 $client_iorfile[$i] = $client->LocalFile($iorbase[$i]);
109 $server->DeleteFile ($iorbase[$i]);
110 $client->DeleteFile ($iorbase[$i]);
112 $server_fname = $server->LocalFile ($iorfname_prefix);
113 $server->DeleteFile ($server_fname);
115 $SV = $server->CreateProcess ("server_main",
116 "-p $server_fname " .
117 "-s $num_servants " .
118 "-n $num_csd_threads " .
119 "-t $num_orb_threads " .
120 "-r $num_remote_clients " .
121 "-c $num_collocated_clients " .
122 "-k $collocated_client_kind");
123 $SV->Spawn();
125 # Wait for the servant ior files created by server.
126 for ($i = 0; $i < $num_servants; $i++) {
127 if ($server->WaitForFileTimed ($iorbase[$i],
128 2*$server->ProcessStartWaitInterval()) == -1) {
129 print STDERR "ERROR: cannot find file <$server_iorfile[$i]>\n";
130 $SV->Kill(); $SV->TimedWait(1);
131 exit 1;
135 for ($i = 0; $i < $num_remote_clients; $i++) {
137 $client_id = $i+1;
139 $j = $i % $num_servants;
140 $CLS[$i] = $client->CreateProcess ("client_main",
141 "-i file://$client_iorfile[$j] ".
142 "-k $client_kind ".
143 "-n $client_id");
144 $CLS[$i]->Spawn();
147 for ($i = 0; $i < $num_remote_clients; $i++) {
148 $client_status = $CLS[$i]->WaitKill($client->ProcessStopWaitInterval () + 60);
150 if ($client_status != 0) {
151 print STDERR "ERROR: client $i returned $client_status\n";
152 $status = 1;
156 $server_status = $SV->WaitKill($server->ProcessStopWaitInterval () + 60);
158 if ($server_status != 0) {
159 print STDERR "ERROR: server returned $server_status\n";
160 $status = 1;
163 #Delete ior files generated by this run.
164 for ($i = 0; $i < $num_servants; $i++) {
165 $server->DeleteFile ($iorbase[$i]);
166 $client->DeleteFile ($iorbase[$i]);
169 exit $status;