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
;
14 my $server = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
15 my $client = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
17 my $iorbase = "test.ior";
18 my $server_iorfile = $server->LocalFile ($iorbase);
19 my $client_iorfile = $client->LocalFile ($iorbase);
20 $server->DeleteFile($iorbase);
21 $client->DeleteFile($iorbase);
23 $srvdownfile = "server_terminated";
24 $server_srvdownfile = $server->LocalFile ($srvdownfile);
26 $SV = $server->CreateProcess ("server",
27 "-o $server_iorfile " .
30 $CL = $client->CreateProcess ("client", "-k file://$client_iorfile -n $cli_threads");
32 $server_status = $SV->Spawn ();
34 if ($server_status != 0) {
35 print STDERR
"ERROR: server returned $server_status\n";
38 if ($server->WaitForFileTimed ($iorbase,
39 $server->ProcessStartWaitInterval()) == -1) {
40 print STDERR
"ERROR: cannot find file <$server_iorfile>\n";
41 $SV->Kill (); $SV->TimedWait (1);
45 if ($server->GetFile ($iorbase) == -1) {
46 print STDERR
"ERROR: cannot retrieve file <$server_iorfile>\n";
47 $SV->Kill (); $SV->TimedWait (1);
50 if ($client->PutFile ($iorbase) == -1) {
51 print STDERR
"ERROR: cannot set file <$client_iorfile>\n";
52 $SV->Kill (); $SV->TimedWait (1);
57 #Client will not terminate on its own, kill it after 30 seconds
58 $CL->TimedWait ($client->ProcessStartWaitInterval() + 15);
61 print "***Client has been killed***\n";
63 #Server should still be running at this point, now start the client that asks
64 #the server to shut itself down
66 $CL->Arguments ("-k file://$client_iorfile -x");
68 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
69 if ($client_status != 0) {
70 print STDERR
"ERROR: client returned $client_status\n";
74 #Server should now be shutdown
75 if ($server->WaitForFileTimed ($srvdownfile,
76 $server->ProcessStartWaitInterval()) == -1) {
77 print STDERR
"ERROR: cannot find file <$server_srvdownfile>".
78 " -- server has not shut down cleanly.\n";
79 $SV->Kill (); $SV->TimedWait (1);
83 $status_server = $SV->WaitKill ($server->ProcessStopWaitInterval());
85 if ($status_server != 0) {
86 print STDERR
"ERROR: server returned $status_server\n";
90 $server->DeleteFile ($iorbase);
91 $client->DeleteFile ($iorbase);
92 $server->DeleteFile ($srvdownfile);