Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / CSD_Strategy / ThreadPool2 / run_test.pl
blob4ff4b1ba948e61f03e386633ca36c9ae59247029
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 foreach $i (@ARGV) {
14 if ($i eq '-debug') {
15 $debug_level = '10';
19 my $iorfname_prefix = "server";
20 my $num_servants = 10;
21 my $num_clients_per_servant = 4;
22 my $num_clients = $num_servants * $num_clients_per_servant;
24 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
26 $SV = $server->CreateProcess("server_main", "-p $iorfname_prefix ".
27 "-s $num_servants -c $num_clients");
29 my @clients = ();
30 for ($i = 0; $i < $num_clients; $i++) {
31 $clients[$i] = PerlACE::TestTarget::create_target ($i+1) || die "Create target $i+1 failed\n";
34 #Delete old ior files.
35 my @iorfiles = ();
36 my @server_iorfiles = ();
37 for ($i = 0; $i < $num_servants; $i++) {
38 $servant_id = sprintf("%02d", ($i + 1));
39 $iorfiles[$i] = $iorfname_prefix . "_$servant_id.ior";
40 $server_iorfiles[$i] = $server->LocalFile($iorfiles[$i]);
41 $server->DeleteFile($iorfiles[$i]);
44 my @CLS = ();
45 my @clients_iorfile = ();
46 $count = 0;
47 for ($i = 0; $i < $num_servants; $i++) {
48 for ($j = 0; $j < $num_clients_per_servant; $j++) {
49 $clients_iorfile[$count] = $clients[$count]->LocalFile($iorfiles[$i]);
50 $clients[$count]->DeleteFile($iorfiles[$i]);
51 $CLS[$count] = $clients[$count]->CreateProcess ("client_main",
52 " -i file://$clients_iorfile[$count]");
53 $count ++;
57 $server_status = $SV->Spawn ();
59 if ($server_status != 0) {
60 print STDERR "ERROR: server returned $server_status\n";
61 exit 1;
64 # Wait for the servant ior files created by server.
65 for ($i = 0; $i < $num_servants; $i++) {
66 if ($server->WaitForFileTimed ($iorfiles[$i],
67 $server->ProcessStartWaitInterval()) == -1) {
68 print STDERR "ERROR: cannot find file <$server_iorfiles[$i]>\n";
69 $SV->Kill (); $SV->TimedWait (1);
70 exit 1;
74 for ($i = 0; $i < $num_servants; $i++) {
75 if ($server->GetFile ($iorfiles[$i]) == -1) {
76 print STDERR "ERROR: cannot retrieve $i-th file <$server_iorfiles[$i]>\n";
77 $SV->Kill (); $SV->TimedWait (1);
78 exit 1;
82 $count = 0;
83 for ($i = 0; $i < $num_servants; $i++) {
84 for ($j = 0; $j < $num_clients_per_servant; $j++) {
85 if ($clients[$count]->PutFile ($iorfiles[$i]) == -1) {
86 print STDERR "ERROR: client $count cannot set file <$clients_iorfile[$count]>\n";
87 $SV->Kill (); $SV->TimedWait (1);
88 exit 1;
90 $count ++;
94 $count = 0;
96 for ($i = 0; $i < $num_servants; $i++) {
97 for ($j = 0; $j < $num_clients_per_servant; $j++) {
98 my $client_status = $CLS[$count]->Spawn();
99 if ($client_status != 0) {
100 print STDERR "ERROR: client $count Spawn returned $client_status\n";
101 $status = 1;
103 $count ++;
107 for ($i = 0; $i < $num_clients; $i++) {
108 my $client_status = $CLS[$i]->WaitKill ($clients[$i]->ProcessStartWaitInterval() + 45);
110 if ($client_status != 0) {
111 print STDERR "ERROR: client $i WaitKill returned $client_status\n";
112 $status = 1;
116 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 45);
118 if ($server_status != 0) {
119 print STDERR "ERROR: server returned $server_status\n";
120 $status = 1;
124 #Delete ior files generated by this run.
125 for ($i = 0; $i < $num_servants; $i++) {
126 $server->DeleteFile($iorfiles[$i]);
129 $count = 0;
130 for ($i = 0; $i < $num_servants; $i++) {
131 for ($j = 0; $j < $num_clients_per_servant; $j++) {
132 $clients[$count]->DeleteFile($iorfiles[$i]);
133 $count++;
137 exit $status;