2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
6 use lib
"$ENV{ACE_ROOT}/bin";
7 use PerlACE
::TestTarget
;
18 my $srv = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
19 my $cli = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
20 my $imr = PerlACE
::TestTarget
::create_target
(3) || die "Create target 3 failed\n";
24 my $OBJ_REF_STYLE = "-orbobjrefstyle url";
26 my $implrepo_server = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator";
28 my $implrepo_ior = "imr.ior";
29 my $messenger_ior = "messenger.ior";
31 my $imr_imriorfile = $imr->LocalFile ($implrepo_ior);
32 my $srv_imriorfile = $srv->LocalFile ($implrepo_ior);
33 my $srv_srviorfile = $srv->LocalFile ($messenger_ior);
34 my $cli_srviorfile = $cli->LocalFile ($messenger_ior);
36 $Srv = $srv->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
39 "-ORBInitRef ImplRepoService=file://$srv_imriorfile");
40 $Cli = $cli->CreateProcess ("MessengerClient", "-k file://$cli_srviorfile");
43 $imr->DeleteFile ($implrepo_ior);
44 $srv->DeleteFile ($implrepo_ior);
45 $srv->DeleteFile ($messenger_ior);
46 $cli->DeleteFile ($messenger_ior);
49 # Use url object reference style for readability, and startup timeout of 2 seconds.
50 # Unlike the chapter we'll forgo using -m, because we want to be able to run this
51 # as a test in our nightly builds, and multicast could interfere with other machines.
52 $ImR = $imr->CreateProcess ($implrepo_server, "-d $DEBUG_LEVEL ".
55 "-o $imr_imriorfile");
59 #### Start the example
60 print ">>> " . $ImR->CommandLine() . "\n";
61 $ImR_status = $ImR->Spawn ();
63 if ($ImR_status != 0) {
64 print STDERR
"ERROR: ImplRepo Service returned $ImR_status\n";
68 if ($imr->WaitForFileTimed ($implrepo_ior,$imr->ProcessStartWaitInterval()) == -1) {
69 print STDERR
"ERROR: cannot find file <$imr_imriorfile>\n";
70 $ImR->Kill (); $ImR->TimedWait (1);
74 if ($imr->GetFile ($implrepo_ior) == -1) {
75 print STDERR
"ERROR: cannot retrieve file <$imr_imriorfile>\n";
76 $ImR->Kill (); $ImR->TimedWait (1);
79 if ($srv->PutFile ($implrepo_ior) == -1) {
80 print STDERR
"ERROR: cannot set file <$srv_imriorfile>\n";
81 $ImR->Kill (); $ImR->TimedWait (1);
85 print ">>> " . $Srv->CommandLine() . "\n";
86 $Srv_status = $Srv->Spawn ();
88 if ($Srv_status != 0) {
89 print STDERR
"ERROR: Server returned $Srv_status\n";
90 $ImR->Kill (); $ImR->TimedWait (1);
94 if ($srv->WaitForFileTimed ($messenger_ior,$srv->ProcessStartWaitInterval()) == -1) {
95 print STDERR
"ERROR: cannot find file <$srv_srviorfile>\n";
96 $Srv->Kill (); $Srv->TimedWait (1);
97 $ImR->Kill (); $ImR->TimedWait (1);
101 if ($srv->GetFile ($messenger_ior) == -1) {
102 print STDERR
"ERROR: cannot retrieve file <$srv_srviorfile>\n";
103 $Srv->Kill (); $Srv->TimedWait (1);
104 $ImR->Kill (); $ImR->TimedWait (1);
107 if ($cli->PutFile ($messenger_ior) == -1) {
108 print STDERR
"ERROR: cannot set file <$cli_srviorfile>\n";
109 $Srv->Kill (); $Srv->TimedWait (1);
110 $ImR->Kill (); $ImR->TimedWait (1);
114 $Cli_status = $Cli->SpawnWaitKill ($cli->ProcessStartWaitInterval());
115 if ($Cli_status != 0) {
116 print STDERR
"ERROR: Client failed to run correctly. Client returned $Cli_status\n";
120 $Srv_status = $Srv->TerminateWaitKill ($srv->ProcessStopWaitInterval());
122 if ($Srv_status != 0) {
123 print STDERR
"ERROR: Server returned $Srv_status\n";
127 $ImR_status = $ImR->TerminateWaitKill ($imr->ProcessStopWaitInterval());
129 if ($ImR_status != 0) {
130 print STDERR
"ERROR: ImplRepo Service returned $ImR_status\n";
134 #### Clean up any output files