Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / AMI / run_exclusive_rw.pl
blobd5dfc2208cabde36b21987674bb6e0cd0234697a
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 $client_conf_base = "exclusive_rw$PerlACE::svcconf_ext";
14 $client_conf = $client->LocalFile ($client_conf_base);
15 if ($client->PutFile ($client_conf_base) == -1) {
16 print STDERR "ERROR: cannot set file <$client_conf>\n";
17 exit 1;
20 $debug = 0;
21 $iterations = 5;
22 $threads = 5;
24 foreach $i (@ARGV) {
25 if ($i eq '-debug') {
26 $debug = 10;
30 my $iorbase = "server.ior";
31 my $server_iorfile = $server->LocalFile ($iorbase);
32 my $client_iorfile = $client->LocalFile ($iorbase);
33 $server->DeleteFile($iorbase);
34 $client->DeleteFile($iorbase);
36 my $server_dbg = "-ORBdebuglevel $debug -ORBLogFile server.log" if ($debug > 0);
37 my $client_dbg = "-ORBdebuglevel $debug -ORBLogFile client.log" if ($debug > 0);
39 $SV = $server->CreateProcess ("server", "$server_dbg -o $server_iorfile");
41 $server_status = $SV->Spawn ();
43 if ($server_status != 0) {
44 print STDERR "ERROR: server returned $server_status\n";
45 exit 1;
48 if ($server->WaitForFileTimed ($iorbase,
49 $server->ProcessStartWaitInterval()) == -1) {
50 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
51 $SV->Kill (); $SV->TimedWait (1);
52 exit 1;
54 if ($server->GetFile ($iorbase) == -1) {
55 print STDERR "ERROR: cannot get file <$server_iorfile>\n";
56 $SV->Kill (); $SV->TimedWait (1);
57 exit 1;
59 if ($client->PutFile ($iorbase) == -1) {
60 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
61 $SV->Kill (); $SV->TimedWait (1);
62 exit 1;
65 $CL = $client->CreateProcess ("client",
66 "-ORBsvcconf $client_conf $client_dbg"
67 . " -k file://$client_iorfile "
68 . " -n $threads -i $iterations -d -x");
70 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
72 if ($client_status != 0) {
73 print STDERR "ERROR: client returned $client_status\n";
74 $status = 1;
77 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
79 if ($server_status != 0) {
80 print STDERR "ERROR: server returned $server_status\n";
81 $status = 1;
84 $server->DeleteFile($iorbase);
85 $client->DeleteFile($iorbase);
87 exit $status;