Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Simple_Naming / run_test.pl
blob58c41e2ced3d149f336af1fe46005e15303b3ced
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 # This is a Perl script that runs some Naming Service tests.
8 # It runs all the tests that will run with min CORBA.
9 # It starts all the servers and clients as necessary.
11 use lib "$ENV{ACE_ROOT}/bin";
12 use PerlACE::TestTarget;
13 use Cwd;
15 ## Save the starting directory
16 $status = 0;
17 $multicast = '224.9.9.2';
18 $startdir = getcwd();
20 $quiet = 0;
21 $skip_mmap = 0;
22 $mt_only = 0;
24 foreach $i (@ARGV) {
25 if ($i eq '-q') {
26 $quiet = 1;
28 elsif ($i eq '-nommap') {
29 $skip_mmap = 1;
31 elsif ($i eq '-mtonly') {
32 $mt_only = 1;
36 my $test = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
38 # Variables for command-line arguments to client and server
39 # executables.
40 $ns_multicast_port = 10001 + $test->RandomPort();
41 $ns_orb_port = 12000 + $test->RandomPort();
43 $iorfile = "ns.ior";
44 $persistent_ior_file = "pns.ior";
45 $persistent_log_file = "test_log";
47 $data_file = "test_run.data";
49 ## Allow the user to determine where the persistent file will be located
50 ## just in case the current directory is not suitable for locking.
51 ## We can't change the name of the persistent file because that is not
52 ## sufficient to work around locking problems for Tru64 when the current
53 ## directory is NFS mounted from a system that does not properly support
54 ## locking.
55 foreach my $possible ($ENV{TMPDIR}, $ENV{TEMP}, $ENV{TMP}) {
56 if (defined $possible && -d $possible) {
57 if (chdir($possible)) {
58 last;
63 $test_log = $test->LocalFile ($data_file);
64 $test->DeleteFile ($data_file);
66 #Files which used by test
67 my $test_iorfile = $test->LocalFile ($iorfile);
68 my $test_persistent_log_file = $test->LocalFile ($persistent_log_file);
69 my $test_persistent_ior_file = $test->LocalFile ($persistent_ior_file);
71 $test->DeleteFile($persistent_ior_file);
72 $test->DeleteFile($iorfile);
73 $test->DeleteFile($persistent_log_file);
75 sub name_server
77 my $args = "-ORBMulticastDiscoveryEndpoint $multicast:$ns_multicast_port -o $test_iorfile -m 1 @_";
78 my $prog = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming";
80 $SV = $test->CreateProcess ("$prog", "$args");
82 $test->DeleteFile($iorfile);
84 $SV->Spawn ();
86 if ($test->WaitForFileTimed ($iorfile,
87 $test->ProcessStartWaitInterval()) == -1) {
88 print STDERR "ERROR: cannot find file <$test_iorfile>\n";
89 $SV->Kill (); $SV->TimedWait (1);
90 exit 1;
93 sleep(1);
96 sub client
98 my $args = "@_"." ";
99 my $prog = "$ENV{TAO_ROOT}/orbsvcs/tests/Simple_Naming/client";
101 $CL = $test->CreateProcess ("$prog", "$args");
103 $client_status = $CL->SpawnWaitKill ($test->ProcessStartWaitInterval() + 45);
105 if ($client_status != 0) {
106 print STDERR "ERROR: client returned $client_status\n";
107 $status = 1;
112 ## The options below have been reordered due to a
113 ## initialization problem (within the Naming_Service)
114 ## that has only been seen on Windows XP.
116 sub common_tests
118 # Options for all simple tests recognized by the 'client' program.
119 @opts = ("-s -ORBInitRef NameService=file://$test_iorfile",
120 "-p $test_persistent_ior_file -ORBInitRef NameService=file://$test_iorfile",
121 "-s -ORBInitRef NameService=mcast://$multicast:$ns_multicast_port\::/NameService",
122 "-t -ORBInitRef NameService=file://$test_iorfile",
123 "-i -ORBInitRef NameService=file://$test_iorfile",
124 "-e -ORBInitRef NameService=file://$test_iorfile",
125 "-y -ORBInitRef NameService=file://$test_iorfile",
126 "-c file://$test_persistent_ior_file -ORBInitRef NameService=file://$test_iorfile",
129 $hostname = $test->HostName ();
131 @server_opts = ("-t 30",
132 "-ORBEndpoint iiop://$hostname:$ns_orb_port -f $test_persistent_log_file",
133 "", "", "", "", "",
134 "-ORBEndpoint iiop://$hostname:$ns_orb_port -f $test_persistent_log_file",
137 @comments = ("Simple Test: \n",
138 "mmap() Persistent Test (Part 1): \n",
139 "Simple Test (using multicast to locate the server): \n",
140 "Tree Test: \n",
141 "Iterator Test: \n",
142 "Exceptions Test: \n",
143 "Destroy Test: \n",
144 "mmap() Persistent Test (Part 2): \n",
147 $test_number = 0;
149 print "INFO: Running the test in ", getcwd(), "\n";
151 # Run server and client for each of the tests. Client uses ior in a
152 # file to bootstrap to the server.
153 foreach $o (@opts) {
154 if (index($comments[$test_number],"mmap") != -1 && $skip_mmap == 1) {
155 print STDERR "\n *** skipping ".$comments[$test_number];
157 else {
158 name_server ($server_opts[$test_number]);
159 print STDERR "\n ".$comments[$test_number];
160 client ($o);
161 $SV->Kill ();
163 ## For some reason, only on Windows XP, we need to
164 ## wait before starting another tao_cosnaming when
165 ## the mmap persistence option is used
166 if ($^O eq "MSWin32") {
167 sleep(1);
169 $test_number++;
172 $test->DeleteFile($persistent_ior_file);
173 $test->DeleteFile($persistent_log_file);
174 $test->DeleteFile($iorfile);
178 sub mt_test ()
180 # Now run the multithreaded test, sending output to the file.
181 print STDERR "\n Multithreaded Test:\n";
182 $test->DeleteFile ($data_file);
184 name_server ("");
185 client ("-ORBInitRef NameService=file://$test_iorfile -ORBLogFile $test_log", "-m15");
187 $SV->Kill ();
189 $errors = system ("perl $startdir/process-m-output.pl $test_log 15") >> 8;
191 if ($errors > 0) {
192 $status = 1;
194 if (!$quiet) {
195 print STDERR "Errors Detected, printing output\n";
196 if (open (DATA, "<$test_log")) {
197 print STDERR "================================= Begin\n";
198 print STDERR <DATA>;
199 print STDERR "================================= End\n";
200 close (DATA);
202 else {
203 print STDERR "ERROR: Could not open $test_log\n";
205 $test->DeleteFile ($data_file);
209 $test->DeleteFile($iorfile);
212 ##############################################################################
215 common_tests () if (!$mt_only);
216 mt_test ();
217 exit $status;