1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 use lib
"$ENV{ACE_ROOT}/bin";
8 use PerlACE
::TestTarget
;
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");
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.
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]);
45 my @clients_iorfile = ();
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]");
57 $server_status = $SV->Spawn ();
59 if ($server_status != 0) {
60 print STDERR
"ERROR: server returned $server_status\n";
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);
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);
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);
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";
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";
116 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 45);
118 if ($server_status != 0) {
119 print STDERR
"ERROR: server returned $server_status\n";
124 #Delete ior files generated by this run.
125 for ($i = 0; $i < $num_servants; $i++) {
126 $server->DeleteFile($iorfiles[$i]);
130 for ($i = 0; $i < $num_servants; $i++) {
131 for ($j = 0; $j < $num_clients_per_servant; $j++) {
132 $clients[$count]->DeleteFile($iorfiles[$i]);