1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 # This is a Perl script that runs some Naming Service tests
8 # for the FT_Naming_Service.
9 # It runs all the tests that will run with min CORBA.
10 # It starts all the servers and clients as necessary.
12 use lib
"$ENV{ACE_ROOT}/bin";
13 use PerlACE
::TestTarget
;
16 ## Save the starting directory
18 $multicast = '224.9.9.2';
24 if ($ARGV[0] eq '-q') {
28 my $test = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
30 # Variables for command-line arguments to client and server
32 $ns_multicast_port = 10001 + $test->RandomPort();
35 $persistent_ior_file = "pns.ior";
36 $persistent_log_file = "test_log";
38 $data_file = "test_run.data";
40 ## Allow the user to determine where the persistent file will be located
41 ## just in case the current directory is not suitable for locking.
42 ## We can't change the name of the persistent file because that is not
43 ## sufficient to work around locking problems for Tru64 when the current
44 ## directory is NFS mounted from a system that does not properly support
46 foreach my $possible ($ENV{TMPDIR
}, $ENV{TEMP
}, $ENV{TMP
}) {
47 if (defined $possible && -d
$possible) {
48 if (chdir($possible)) {
54 $test_log = $test->LocalFile ($data_file);
55 $test->DeleteFile ($data_file);
57 #Files which used by test
58 my $test_iorfile = $test->LocalFile ($iorfile);
59 my $test_persistent_log_file = $test->LocalFile ($persistent_log_file);
60 my $test_persistent_ior_file = $test->LocalFile ($persistent_ior_file);
62 $test->DeleteFile($persistent_ior_file);
63 $test->DeleteFile($iorfile);
64 $test->DeleteFile($persistent_log_file);
68 my $args = "-u NameService -ORBMulticastDiscoveryEndpoint $multicast:$ns_multicast_port -o $test_iorfile -m 1 @_";
69 my $prog = "$ENV{TAO_ROOT}/orbsvcs/FT_Naming_Service/tao_ft_naming";
71 $SV = $test->CreateProcess ("$prog", "$args");
73 $test->DeleteFile($iorfile);
77 if ($test->WaitForFileTimed ($iorfile,
78 $test->ProcessStartWaitInterval()) == -1) {
79 print STDERR
"ERROR: cannot find file <$test_iorfile>\n";
80 $SV->Kill (); $SV->TimedWait (1);
90 my $prog = "$startdir/client";
92 $CL = $test->CreateProcess ("$prog", "$args");
94 $client_status = $CL->SpawnWaitKill ($test->ProcessStartWaitInterval() + 45);
96 if ($client_status != 0) {
97 print STDERR
"ERROR: client returned $client_status\n";
103 sub make_or_clean_state
105 # Create a directory to hold the persistent state
106 if ( ! -d
"NameService" ) {
107 mkdir (NameService
, 0777);
111 opendir(THISDIR
, ".");
112 @allfiles = grep(!/^\.\.?$/, readdir(THISDIR
));
114 foreach $tmp (@allfiles){
115 $test->DeleteFile ($tmp);
121 ## The options below have been reordered due to a
122 ## initialization problem (within the Naming_Service)
123 ## that has only been seen on Windows XP.
125 # Options for all simple tests recognized by the 'client' program.
126 @opts = ("-s -ORBInitRef NameService=file://$test_iorfile",
127 "-s -ORBInitRef NameService=mcast://$multicast:$ns_multicast_port\::/NameService",
128 "-t -ORBInitRef NameService=file://$test_iorfile",
129 "-i -ORBInitRef NameService=file://$test_iorfile",
130 "-e -ORBInitRef NameService=file://$test_iorfile",
131 "-y -ORBInitRef NameService=file://$test_iorfile"
134 @server_opts = ("-t 30",
142 @comments = ("Simple Test: \n",
143 "Simple Test (using multicast to locate the server): \n",
146 "Exceptions Test: \n",
152 print "INFO: Running the test in ", getcwd
(), "\n";
154 # Run server and client for each of the tests. Client uses ior in a
155 # file to bootstrap to the server.
158 # Ensure that the name service is starting clean each time
161 print STDERR
"Running Test: $comments[$test_number]\n";
163 name_server
($server_opts[$test_number]);
169 ## For some reason, only on Windows XP, we need to
170 ## wait before starting another tao_cosnaming when
171 ## the mmap persistence option is used
172 if ($^O
eq "MSWin32") {
178 $test->DeleteFile($persistent_ior_file);
179 $test->DeleteFile($persistent_log_file);
180 $test->DeleteFile($iorfile);
182 # Now run the multithreaded test, sending output to the file.
183 print STDERR
"\n Multithreaded Test:\n";
184 $test->DeleteFile ($data_file);
187 client
("-ORBInitRef NameService=file://$test_iorfile -ORBLogFile $test_log", "-m15");
191 $errors = system ("perl $startdir/process-m-output.pl $test_log 15") >> 8;
197 print STDERR
"Errors Detected, printing output\n";
198 if (open (DATA
, "<$test_log")) {
199 print STDERR
"================================= Begin\n";
201 print STDERR
"================================= End\n";
205 print STDERR
"ERROR: Could not open $test_log\n";
207 $test->DeleteFile ($data_file);
211 $test->DeleteFile($iorfile);
212 # Remove the persistence directory