summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Simple_Naming/run_test.pl
blob: 7f5167f5db52df12f7ed14c62596d7fc6913d324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# -*- perl -*-

# This is a Perl script that runs all Naming Service tests.  It starts
# all the servers and clients as necessary.

unshift @INC, '../../../../bin';
require Process;
require ACEutils;
require Uniqueid;

# Amount of delay (in seconds) between starting a server and a client
# to allow proper server initialization.
$sleeptime = 8;

# Variables for command-line arguments to client and server
# executables. 
$ns_multicast_port = 10000 + uniqueid ();  
$ns_orb_port = 12000 + uniqueid ();
$iorfile = "ns.ior";
$persistent_ior_file = "pns.ior";
$persistent_log_file = "test_log";
$data_file = "test_run.data";

sub name_server
{
  my $args = "@_ "."-ORBnameserviceport $ns_multicast_port -o $iorfile";
  my $prog = "..$DIR_SEPARATOR..$DIR_SEPARATOR".
      "Naming_Service".$DIR_SEPARATOR.
          "Naming_Service".$EXE_EXT;

  unlink $iorfile;
  $NS = Process::Create ($prog, $args);

  if (ACE::waitforfile_timed ($iorfile, $sleeptime) == -1) {
    print STDERR "ERROR: cannot find IOR file <$iorfile>\n";
    $NS->Kill (); $NS->TimedWait (1);
    exit 1;
  }
}

sub client
{
  my $args = "@_"." ";
  my $prog = $EXEPREFIX."client".$EXE_EXT;

  $CL = Process::Create ($prog, $args);

  $client = $CL->TimedWait (60);
  if ($client == -1) {
      print STDERR "ERROR: client timedout\n";
      $CL->Kill (); $CL->TimedWait (1);
  }
}

# Options for all simple tests recognized by the 'client' program.
@opts = ("-s -ORBnameserviceior file://$iorfile",
         "-s -ORBnameserviceport $ns_multicast_port",
         "-t -ORBnameserviceior file://$iorfile", 
         "-i -ORBnameserviceior file://$iorfile", 
         "-e -ORBnameserviceior file://$iorfile", 
         "-y -ORBnameserviceior file://$iorfile",
         "-p $persistent_ior_file -ORBnameserviceior file://$iorfile",
         "-c file://$persistent_ior_file -ORBnameserviceior file://$iorfile");

@server_opts = ("", "", "", "", "", "",
                "-ORBEndpoint iiop://localhost:$ns_orb_port -f $persistent_log_file",
                "-ORBEndpoint iiop://localhost:$ns_orb_port -f $persistent_log_file");

@comments = ("Simple Test: \n",
             "Simple Test (using multicast to locate the server): \n",
             "Tree Test: \n",
             "Iterator Test: \n",
             "Exceptions Test: \n",
             "Destroy Test: \n",
             "Persistent Test (Part 1): \n",
             "Persistent Test (Part 2): \n");

$test_number = 0;

unlink $persistent_ior_file, $persistent_log_file;

# Run server and client for each of the tests.  Client uses ior in a
# file to bootstrap to the server.
foreach $o (@opts)
{
  name_server ($server_opts[$test_number]);

  print STDERR "\n          ".$comments[$test_number];

  client ($o);

  $NS->Terminate (); $server = $NS->TimedWait (5);
  if ($server == -1) {
    print STDERR "ERROR: server timedout\n";
    $NS->Kill (); $NS->TimedWait (1);
  }
  $test_number++;
}

unlink $persistent_ior_file, $persistent_log_file;

# Now run the multithreaded test, sending output to the file.
print STDERR "\n          Multithreaded Test:\n";
unlink $data_file;

open (OLDOUT, ">&STDOUT");
open (STDOUT, ">$data_file") or die "can't redirect stdout: $!";
open (OLDERR, ">&STDERR");
open (STDERR, ">&STDOUT") or die "can't redirect stderror: $!";

name_server ();

client ("-ORBnameserviceior file://$iorfile", "-m25");

close (STDERR);
close (STDOUT);
open (STDOUT, ">&OLDOUT");
open (STDERR, ">&OLDERR");

$NS->Terminate (); $server = $NS->TimedWait (5);
if ($server == -1) {
  print STDERR "ERROR: server timedout\n";
  $NS->Kill (); $NS->TimedWait (1);
}

unlink $iorfile;

$FL = Process::Create ($EXEPREFIX."process-m-output.pl",
                       " test_run.data 25");
$filter = $FL->TimedWait (60);
if ($filter == -1) {
  print STDERR "ERROR: filter timedout\n";
  $FL->Kill (); $FL->TimedWait (1);
}
print STDERR "\n";

# @@ Capture any exit status from the processes.
exit 0;