Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_1334_Regression / run_test.pl
blob233a392ec2770c08da3b449a0517fa92f4af077e
3 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
4 & eval 'exec perl -S $0 $argv:q'
5 if 0;
7 # -*- perl -*-
9 use lib "$ENV{ACE_ROOT}/bin";
10 use PerlACE::TestTarget;
12 $status = 0;
13 $debug_level = '0';
15 foreach $i (@ARGV) {
16 if ($i eq '-debug') {
17 $debug_level = '10';
21 my $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
23 # The NameService IOR file
25 $nsiorfile = "ns.ior";
27 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
28 $ns->DeleteFile ($nsiorfile);
30 # The client process
32 $CLI = $ns->CreateProcess ("client");
34 # Fire up the Name Service
36 $NS = $ns->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
37 "-ORBDebugLevel $debug_level ".
38 "-o $ns_nsiorfile");
39 $NS_status = $NS->Spawn ();
40 if ($NS_status != 0) {
41 print STDERR "ERROR: Name Service returned $NS_status\n";
42 $NS->Kill (); $NS->TimedWait (1);
43 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;
52 # Try the client with the name service ior in an environment variable of
53 # the form <service name>IOR.
54 # Expect it to succeed.
56 $ENV {'NameServiceIOR'} = "file://$ns_nsiorfile";
57 $CLI->Arguments("");
58 $CLI_status = $CLI->SpawnWaitKill ($ns->ProcessStartWaitInterval()+15);
59 if ($CLI_status != 0) {
60 print STDERR "ERROR: Name Service not resolved by environment variable\n";
61 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
62 if ($NS_status != 0) {
63 print STDERR "ERROR: Closing Name Service returned $NS_status\n";
65 $ns->DeleteFile ($nsiorfile);
66 exit 1;
69 # Now try it with a duff ior in the environment variable.
70 # Expect it to fail.
72 $ENV {'NameServiceIOR'} = "Banana";
73 $CLI->Arguments("");
74 $CLI_status = $CLI->SpawnWaitKill ($ns->ProcessStartWaitInterval()+15);
75 if ($CLI_status != 1) {
76 print STDERR "ERROR: Name Service resolved with duff environment\n";
77 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
78 if ($NS_status != 0) {
79 print STDERR "ERROR: Closing Name Service returned $NS_status\n";
81 $ns->DeleteFile ($nsiorfile);
82 exit 1;
85 # Now try with a duff ior in the environment variable but overridden by
86 # a command line parameter.
87 # Expect it to succeed.
89 $ENV {'NameServiceIOR'} = "Custard";
90 $CLI->Arguments("-ORBInitRef NameService=file://$ns_nsiorfile");
91 $CLI_status = $CLI->SpawnWaitKill ($ns->ProcessStartWaitInterval()+15);
92 if ($CLI_status != 0) {
93 print STDERR "ERROR: Name Service not resolved by command line override\n";
94 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
95 if ($NS_status != 0) {
96 print STDERR "ERROR: Closing Name Service returned $NS_status\n";
98 $ns->DeleteFile ($nsiorfile);
99 exit 1;
102 # Clean up and return
104 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
105 if ($NS_status != 0) {
106 print STDERR "ERROR: Closing Name Service returned $NS_status\n";
107 $status = 1;
110 $ns->DeleteFile ($nsiorfile);
112 exit $status;