Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / CSD_Strategy_Tests / Broken / run_test.pl
blob6977b6c13cbcace91301df976588f7dc1e172f48
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 $server->AddLibPath ('../TP_Foo_B/.');
15 $server->AddLibPath ('../TP_Foo_C/.');
16 $server->AddLibPath ('../TP_Common/.');
18 $client->AddLibPath ('../TP_Foo_A/.');
19 $client->AddLibPath ('../TP_Foo_B/.');
20 $client->AddLibPath ('../TP_Foo_C/.');
21 $client->AddLibPath ('../TP_Common/.');
23 my $status = 0;
25 my $iorfname_prefix = "servant";
26 my $num_servants = 1;
27 my $num_orb_threads = 1;
28 my $num_remote_clients = 1;
29 my $num_csd_threads = 1;
30 my $num_collocated_clients = 0;
31 my $collocated_client_kind = 0;
32 my $client_kind = 0;
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 > 1) {
44 print STDERR "ERROR: Too many command-line arguments for $0.\n";
45 exit 1;
48 my $subtest = $ARGV[0];
50 if ($subtest eq 'remote') {
51 $num_remote_clients = 40;
53 elsif ($subtest eq 'collocated') {
54 $num_remote_clients = 0;
55 $num_collocated_clients = 1;
56 $num_collocated_clients = 1;
58 elsif ($subtest eq 'remote_orbthreads') {
59 $num_orb_threads = 5;
60 $num_remote_clients = 40;
62 elsif ($subtest eq 'remote_servants') {
63 $num_servants = 5;
64 $num_remote_clients = 40;
66 elsif ($subtest eq 'remote_csdthreads') {
67 $num_csd_threads = 5;
68 $num_remote_clients = 40;
70 elsif ($subtest eq 'remote_big') {
71 $num_csd_threads = 5;
72 $num_servants = 10;
73 $num_orb_threads = 4;
74 $num_remote_clients = 40;
76 elsif ($subtest eq 'big') {
77 $num_csd_threads = 5;
78 $num_servants = 10;
79 $num_orb_threads = 4;
80 $num_remote_clients = 40;
81 $num_collocated_clients = 40;
83 elsif ($subtest eq 'usage') {
84 print STDOUT "Usage: $0 [<subtest>]\n" .
85 "\n" .
86 "Supported <subtest> values:\n" .
87 "\n" .
88 "\tremote\n" .
89 "\tcollocated\n" .
90 "\tremote_orbthreads\n" .
91 "\tremote_servants\n" .
92 "\tremote_csdthreads\n" .
93 "\tremote_big\n" .
94 "\tbig\n" .
95 "\tusage\n" .
96 "\n";
97 exit 0;
99 else {
100 print STDERR "ERROR: invalid subtest argument for $0: $subtest\n";
101 exit 1;
105 #Fill array and delete old ior files.
106 for ($i = 0; $i < $num_servants; $i++) {
107 my $servant_id = sprintf("%02d", ($i + 1));
108 $iorbase[$i] = $iorfname_prefix . "_$servant_id.ior";
109 $server_iorfile[$i] = $server->LocalFile($iorbase[$i]);
110 $client_iorfile[$i] = $client->LocalFile($iorbase[$i]);
111 $server->DeleteFile ($iorbase[$i]);
112 $client->DeleteFile ($iorbase[$i]);
114 $server_fname = $server->LocalFile ($iorfname_prefix);
116 $SV = $server->CreateProcess ("server_main",
117 "-p $server_fname " .
118 "-s $num_servants " .
119 "-n $num_csd_threads " .
120 "-t $num_orb_threads " .
121 "-r $num_remote_clients " .
122 "-c $num_collocated_clients " .
123 "-k $collocated_client_kind");
124 $SV->Spawn();
126 # Wait for the servant ior files created by server.
127 for ($i = 0; $i < $num_servants; $i++) {
128 if ($server->WaitForFileTimed ($iorbase[$i],
129 $server->ProcessStartWaitInterval()) == -1) {
130 print STDERR "ERROR: cannot find file <$server_iorfile[$i]>\n";
131 $SV->Kill(); $SV->TimedWait(1);
132 exit 1;
136 for ($i = 0; $i < $num_remote_clients; $i++) {
138 $client_id = $i+1;
140 $j = $i % $num_servants;
141 $CLS[$i] = $client->CreateProcess ("client_main",
142 "-i file://$client_iorfile[$j] ".
143 "-k $client_kind ".
144 "-n $client_id");
145 $CLS[$i]->Spawn();
148 for ($i = 0; $i < $num_remote_clients; $i++) {
149 $client_status = $CLS[$i]->WaitKill($client->ProcessStopWaitInterval () + 60);
151 if ($client_status != 0) {
152 print STDERR "ERROR: client $i returned $client_status\n";
153 $status = 1;
157 $server_status = $SV->WaitKill($server->ProcessStopWaitInterval () + 60);
159 if ($server_status != 0) {
160 print STDERR "ERROR: server returned $server_status\n";
161 $status = 1;
164 #Delete ior files generated by this run.
165 for ($i = 0; $i < $num_servants; $i++) {
166 $server->DeleteFile ($iorbase[$i]);
167 $client->DeleteFile ($iorbase[$i]);
170 exit $status;