Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / CSD_Strategy_Tests / TP_Test_2 / run_test.pl
bloba63f81b52ff0bf9bddf95af4dd686bbf5487d753
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;
56 elsif ($subtest eq 'remote_orbthreads') {
57 $num_orb_threads = 5;
58 $num_remote_clients = 40;
60 elsif ($subtest eq 'remote_servants') {
61 $num_servants = 5;
62 $num_remote_clients = 40;
64 elsif ($subtest eq 'remote_csdthreads') {
65 $num_csd_threads = 5;
66 $num_remote_clients = 40;
68 elsif ($subtest eq 'remote_big') {
69 $num_csd_threads = 5;
70 $num_servants = 10;
71 $num_orb_threads = 4;
72 $num_remote_clients = 40;
74 elsif ($subtest eq 'big') {
75 $num_csd_threads = 5;
76 $num_servants = 10;
77 $num_orb_threads = 4;
78 $num_remote_clients = 40;
79 $num_collocated_clients = 40;
81 elsif ($subtest eq 'usage') {
82 print STDOUT "Usage: $0 [<subtest>]\n" .
83 "\n" .
84 "Supported <subtest> values:\n" .
85 "\n" .
86 "\tremote\n" .
87 "\tcollocated\n" .
88 "\tremote_orbthreads\n" .
89 "\tremote_servants\n" .
90 "\tremote_csdthreads\n" .
91 "\tremote_big\n" .
92 "\tusage\n" .
93 "\n";
94 exit 0;
96 else {
97 print STDERR "ERROR: invalid subtest argument for $0: $subtest\n";
98 exit 1;
102 #Fill array and delete old ior files.
103 for ($i = 0; $i < $num_servants; $i++) {
104 my $servant_id = sprintf("%02d", ($i + 1));
105 $iorbase[$i] = $iorfname_prefix . "_$servant_id.ior";
106 $server_iorfile[$i] = $server->LocalFile($iorbase[$i]);
107 $client_iorfile[$i] = $client->LocalFile($iorbase[$i]);
108 $server->DeleteFile ($iorbase[$i]);
109 $client->DeleteFile ($iorbase[$i]);
111 $server_fname = $server->LocalFile ($iorfname_prefix);
112 $server->DeleteFile ($server_fname);
114 $SV = $server->CreateProcess ("server_main",
115 "-p $server_fname " .
116 "-s $num_servants " .
117 "-n $num_csd_threads " .
118 "-t $num_orb_threads " .
119 "-r $num_remote_clients " .
120 "-c $num_collocated_clients " .
121 "-k $collocated_client_kind");
122 $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(2 * $client->ProcessStopWaitInterval ());
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 ());
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;