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
;
9 use POSIX
"sys_wait_h";
17 $debug_opts = '-ORBDebugLevel 10 -ORBVerboseLogging 1 '
18 . '-ORBLogFile client';
19 $srv_debug = '-ORBDebugLevel 5';
23 my $server = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
24 my $client = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
25 my $shutdown = PerlACE
::TestTarget
::create_target
(3) || die "Create target 3 failed\n";
27 my $iorbase = "server.ior";
28 my $server_iorfile = $server->LocalFile ($iorbase);
29 my $client_iorfile = $client->LocalFile ($iorbase);
30 my $shutdown_iorfile = $shutdown->LocalFile ($iorbase);
31 $server->DeleteFile($iorbase);
32 $client->DeleteFile($iorbase);
33 $shutdown->DeleteFile ($iorbase);
35 $SV = $server->CreateProcess ("server", "-o $server_iorfile $srv_debug");
36 my $threads = int (rand() * 6) + 1;
37 $CL = $client->CreateProcess ("client", "-k file://$client_iorfile -t $threads $debug_opts");
38 $SH = $shutdown->CreateProcess ("shutdown", "-k file://$shutdown_iorfile");
40 $server_status = $SV->Spawn ();
42 if ($server_status != 0) {
43 print STDERR
"ERROR: server returned $server_status\n";
47 if ($server->WaitForFileTimed ($iorbase,
48 $server->ProcessStartWaitInterval()) == -1) {
49 print STDERR
"ERROR: cannot find file <$server_iorfile>\n";
50 $SV->Kill (); $SV->TimedWait (1);
54 if ($server->GetFile ($iorbase) == -1) {
55 print STDERR
"ERROR: cannot retrieve file <$server_iorfile>\n";
56 $SV->Kill (); $SV->TimedWait (1);
60 if ($client->PutFile ($iorbase) == -1) {
61 print STDERR
"ERROR: cannot set file <$client_iorfile>\n";
62 $SV->Kill (); $SV->TimedWait (1);
66 local $start_time = time();
67 local $max_running_time = 720;
68 local $elapsed = time() - $start_time;
70 if ($ARGV[0] eq '-quick') {
72 $max_running_time = 1;
76 while (($elapsed < $max_running_time)) {
77 # Start all clients in parallel
78 my $args_saved = $CL->Arguments ();
79 $CL->Arguments ("$args_saved$client_idx.log") unless $debug_opts eq '';
80 my $client_status = $CL->Spawn ();
81 if ($client_status != 0) {
82 print STDERR
"ERROR: client returned $client_status\n";
86 if ($debug_opts ne '') {
87 $CL->Arguments ($args_saved);
88 print "Spawned client $client_idx\n";
92 if ($client_status == 0) {
93 $CL->WaitKill($client->ProcessStartWaitInterval() + 75, {self_crash
=> 1});
94 if ($client_status != 0) {
95 print STDERR
"ERROR: client returned $client_status\n";
100 print STDERR
"checking server alive\n";
102 my $res = $SV->Wait(1);
109 $elapsed = time() - $start_time;
113 my $shutdown_status = $SH->SpawnWaitKill($shutdown->ProcessStartWaitInterval());
114 if ($shutdown_status != 0) {
115 print STDERR
"ERROR: shutdown returned $$shutdown_status\n";
119 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 300);
120 if ($server_status != 0) {
121 print STDERR
"ERROR: server returned $server_status\n";
126 $server->DeleteFile($iorbase);
127 $client->DeleteFile($iorbase);
128 $shutdown->DeleteFile ($iorbase);