Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Simple_Naming / run_test_ft.pl
bloba2755838966a24e88749287530080796c12e3cff
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 # 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;
14 use Cwd;
16 ## Save the starting directory
17 $status = 0;
18 $multicast = '224.9.9.2';
19 $startdir = getcwd();
21 $quiet = 0;
23 # check for -q flag
24 if ($ARGV[0] eq '-q') {
25 $quiet = 1;
28 my $test = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
30 # Variables for command-line arguments to client and server
31 # executables.
32 $ns_multicast_port = 10001 + $test->RandomPort();
34 $iorfile = "ns.ior";
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
45 ## locking.
46 foreach my $possible ($ENV{TMPDIR}, $ENV{TEMP}, $ENV{TMP}) {
47 if (defined $possible && -d $possible) {
48 if (chdir($possible)) {
49 last;
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);
66 sub name_server
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);
75 $SV->Spawn ();
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);
81 exit 1;
84 sleep(10);
87 sub client
89 my $args = "@_"." ";
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";
98 $status = 1;
103 sub make_or_clean_state
105 # Create a directory to hold the persistent state
106 if ( ! -d "NameService" ) {
107 mkdir (NameService, 0777);
109 else {
110 chdir "NameService";
111 opendir(THISDIR, ".");
112 @allfiles = grep(!/^\.\.?$/, readdir(THISDIR));
113 closedir(THISDIR);
114 foreach $tmp (@allfiles){
115 $test->DeleteFile ($tmp);
117 chdir "..";
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",
144 "Tree Test: \n",
145 "Iterator Test: \n",
146 "Exceptions Test: \n",
147 "Destroy Test: \n"
150 $test_number = 0;
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.
156 foreach $o (@opts) {
158 # Ensure that the name service is starting clean each time
159 make_or_clean_state;
161 print STDERR "Running Test: $comments[$test_number]\n";
163 name_server ($server_opts[$test_number]);
165 client ($o);
167 $SV->Kill ();
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") {
173 sleep(1);
175 $test_number++;
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);
186 name_server ();
187 client ("-ORBInitRef NameService=file://$test_iorfile -ORBLogFile $test_log", "-m15");
189 $SV->Kill ();
191 $errors = system ("perl $startdir/process-m-output.pl $test_log 15") >> 8;
193 if ($errors > 0) {
194 $status = 1;
196 if (!$quiet) {
197 print STDERR "Errors Detected, printing output\n";
198 if (open (DATA, "<$test_log")) {
199 print STDERR "================================= Begin\n";
200 print STDERR <DATA>;
201 print STDERR "================================= End\n";
202 close (DATA);
204 else {
205 print STDERR "ERROR: Could not open $test_log\n";
207 $test->DeleteFile ($data_file);
211 $test->DeleteFile($iorfile);
212 # Remove the persistence directory
213 rmdir "NameService";
216 exit $status;