Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / NamingService / Naming_Client / run_test.pl
blobd02cb93bce8a04dd3cc2c8f2d7fcc4f7c887568a
2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
4 if 0;
6 use lib "$ENV{ACE_ROOT}/bin";
7 use PerlACE::TestTarget;
9 $status = 0;
10 $debug_level = '0';
12 foreach $i (@ARGV) {
13 if ($i eq '-debug') {
14 $debug_level = '10';
18 my $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
19 my $srv = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $cli = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $nsiorfile = "ns.ior";
24 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
25 my $srv_nsiorfile = $srv->LocalFile ($nsiorfile);
26 my $cli_nsiorfile = $cli->LocalFile ($nsiorfile);
27 $ns->DeleteFile ($nsiorfile);
28 $srv->DeleteFile ($nsiorfile);
29 $cli->DeleteFile ($nsiorfile);
31 $NameService = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming";
32 $NS = $ns->CreateProcess ($NameService, " -o $ns_nsiorfile");
33 $SRV = $srv->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
34 "-ORBInitRef NameService=file://$srv_nsiorfile");
35 $CLI = $cli->CreateProcess ("MessengerClient", "-ORBInitRef NameService=file://$cli_nsiorfile");
37 # start Naming Service
38 $NS_status = $NS->Spawn ();
40 if ($NS_status != 0) {
41 print STDERR "ERROR: Name Service returned $NS_status\n";
42 exit 1;
45 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
46 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
47 $NS->Kill (); $NS->TimedWait (1);
48 exit 1;
51 if ($ns->GetFile ($nsiorfile) == -1) {
52 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
53 $NS->Kill (); $NS->TimedWait (1);
54 exit 1;
56 if ($srv->PutFile ($nsiorfile) == -1) {
57 print STDERR "ERROR: cannot set file <$srv_nsiorfile>\n";
58 $NS->Kill (); $NS->TimedWait (1);
59 exit 1;
61 if ($cli->PutFile ($nsiorfile) == -1) {
62 print STDERR "ERROR: cannot set file <$cli_nsiorfile>\n";
63 $NS->Kill (); $NS->TimedWait (1);
64 exit 1;
67 # start MessengerServer
68 $SRV_status = $SRV->Spawn ();
70 if ($SRV_status != 0) {
71 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
72 exit 1;
75 # start MessengerClient
76 $CLI_status = $CLI->SpawnWaitKill ($cli->ProcessStartWaitInterval());
78 if ($CLI_status != 0) {
79 print STDERR "ERROR: Messenger Client returned $CLI_status\n";
80 $status = 1;
83 # clean-up
84 $SRV_status = $SRV->TerminateWaitKill ($srv->ProcessStopWaitInterval());
86 if ($SRV_status != 0) {
87 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
88 $status = 1;
91 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
93 if ($NS_status != 0) {
94 print STDERR "ERROR: Name Service returned $NS_status\n";
95 $status = 1;
98 $ns->DeleteFile ($nsiorfile);
99 $srv->DeleteFile ($nsiorfile);
100 $cli->DeleteFile ($nsiorfile);
102 exit $status;