Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / TAO / performance-tests / CSD_Strategy / TestApps / run_test.pl
blobd326f2a8115f6f9be19378738e198fe79ad47393
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 ('../TestInf/.');
14 $server->AddLibPath ('../TestServant/.');
15 $client->AddLibPath ('../TestInf/.');
16 $client->AddLibPath ('../TestServant/.');
18 # 5 Minute server timeout.
19 my $server_timeout_secs = 300;
21 my $status = 0;
23 my $iorfname_prefix = "servant";
24 my $num_servants = 1;
25 my $num_orb_threads = 1;
26 my $num_remote_clients = 1;
27 my $num_csd_threads = 1;
28 my $num_collocated_clients = 0;
29 my $num_loops = 100;
30 my $use_csd = 1;
31 my $scenario_id = "UnsetScenarioId";
32 my $trial_id = 1;
34 my $i;
35 my $j;
36 my @iorbase;
37 my @server_iorfile;
38 my @client_iorfile;
40 my $ARGC = @ARGV;
42 if ($ARGC > 0) {
43 if ($ARGC > 3) {
44 print STDERR "ERROR: Too many command-line arguments for $0.\n";
45 exit 1;
48 if ($ARGC < 2) {
49 print STDERR "ERROR: Too few command-line arguments for $0.\n";
50 exit 1;
53 if ($ARGC > 2) {
54 $num_loops = $ARGV[2];
57 $scenario_id = $ARGV[0];
58 $trial_id = $ARGV[1];
60 my $subtest = $ARGV[0];
62 if ($subtest =~ /^x_(.+)$/) {
63 $subtest = $1;
64 $use_csd = 0;
67 if ($subtest eq 'remote') {
68 $num_remote_clients = 40;
70 elsif ($subtest eq 'collocated') {
71 $num_remote_clients = 0;
72 $num_collocated_clients = 10;
74 elsif ($subtest eq 'remote_orbthreads') {
75 $num_orb_threads = 5;
76 $num_remote_clients = 40;
78 elsif ($subtest eq 'remote_servants') {
79 $num_servants = 5;
80 $num_remote_clients = 40;
82 elsif ($subtest eq 'remote_csdthreads') {
83 $num_csd_threads = 5;
84 $num_servants = 5;
85 $num_remote_clients = 40;
87 elsif ($subtest eq 'remote_big') {
88 $num_csd_threads = 5;
89 $num_servants = 10;
90 $num_orb_threads = 4;
91 $num_remote_clients = 40;
93 elsif ($subtest eq 'collocated_big') {
94 $num_csd_threads = 5;
95 $num_servants = 10;
96 $num_remote_clients = 0;
97 $num_collocated_clients = 40;
99 elsif ($subtest eq 'big') {
100 $num_csd_threads = 5;
101 $num_servants = 10;
102 $num_orb_threads = 4;
103 $num_remote_clients = 40;
104 $num_collocated_clients = 40;
106 elsif ($subtest eq 'remote_huge') {
107 $num_csd_threads = 5;
108 $num_servants = 10;
109 $num_orb_threads = 4;
110 $num_remote_clients = 400;
111 $num_loops = $num_loops / 10;
112 # 15 minute server timeout
113 $server_timeout_secs = 1800;
115 elsif ($subtest eq 'collocated_huge') {
116 $num_csd_threads = 20;
117 $num_servants = 10;
118 $num_remote_clients = 0;
119 $num_collocated_clients = 40;
121 elsif ($subtest eq 'usage') {
122 print STDOUT "Usage: $0 [<subtest>]\n" .
123 "\n" .
124 "Supported <subtest> values:\n" .
125 "\n" .
126 "\tremote\n" .
127 "\tcollocated\n" .
128 "\tremote_orbthreads\n" .
129 "\tremote_servants\n" .
130 "\tremote_csdthreads\n" .
131 "\tremote_big\n" .
132 "\tcollocated_big\n" .
133 "\tbig\n" .
134 "\tremote_huge\n" .
135 "\tcollocated_huge\n" .
136 "\tusage\n" .
137 "\n";
138 exit 0;
140 else {
141 print STDERR "ERROR: invalid subtest argument for $0: $subtest\n";
142 exit 1;
146 #Fill array and delete old ior files.
147 for ($i = 0; $i < $num_servants; $i++) {
148 my $servant_id = sprintf("%02d", ($i + 1));
149 $iorbase[$i] = $iorfname_prefix . "_$servant_id.ior";
150 $server_iorfile[$i] = $server->LocalFile($iorbase[$i]);
151 $client_iorfile[$i] = $client->LocalFile($iorbase[$i]);
152 $server->DeleteFile ($iorbase[$i]);
153 $client->DeleteFile ($iorbase[$i]);
155 $server_fname = $server->LocalFile ($iorfname_prefix);
157 $SV = $server->CreateProcess ("server_main",
158 "-p $server_fname " .
159 "-s $num_servants " .
160 "-n $num_csd_threads " .
161 "-t $num_orb_threads " .
162 "-r $num_remote_clients " .
163 "-c $num_collocated_clients " .
164 "-l $num_loops " .
165 "-u $use_csd " .
166 "-x $scenario_id " .
167 "-z $trial_id");
168 $SV->Spawn();
170 # Wait for the servant ior files created by server.
171 for ($i = 0; $i < $num_servants; $i++) {
172 if ($server->WaitForFileTimed ($iorbase[$i],
173 $server->ProcessStartWaitInterval()) == -1) {
174 print STDERR "ERROR: cannot find file <$server_iorfile[$i]>\n";
175 $SV->Kill(); $SV->TimedWait(1);
176 exit 1;
180 for ($i = 0; $i < $num_remote_clients; $i++) {
182 $client_id = $i+1;
184 $j = $i % $num_servants;
185 $CLS[$i] = $client->CreateProcess ("client_main",
186 "-i file://$client_iorfile[$j] ".
187 "-l $num_loops ".
188 "-n $client_id");
189 $CLS[$i]->Spawn();
192 for ($i = 0; $i < $num_remote_clients; $i++) {
193 $client_status = $CLS[$i]->WaitKill($client->ProcessStopWaitInterval () + 600);
195 if ($client_status != 0) {
196 print STDERR "ERROR: client $i returned $client_status\n";
197 $status = 1;
201 $server_status = $SV->WaitKill($server->ProcessStopWaitInterval () + 600);
203 if ($server_status != 0) {
204 print STDERR "ERROR: server returned $server_status\n";
205 $status = 1;
208 #Delete ior files generated by this run.
209 for ($i = 0; $i < $num_servants; $i++) {
210 $server->DeleteFile ($iorbase[$i]);
211 $client->DeleteFile ($iorbase[$i]);
214 exit $status;