summaryrefslogtreecommitdiff
path: root/TAO/examples/ior_corbaloc/run_test.pl
blob: 31ef6777eae3d3db977efc9bb5424258a1052982 (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
145
146
147
148
149
     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 the corbaloc: style URL tests.
# It starts the servers and client.

use lib "$ENV{ACE_ROOT}/bin";

use PerlACE::Run_Test;

$TARGETHOSTNAME = "localhost";

$status = 0;

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

@iorfile = ("ns1.ior",
            "ns2.ior",
            "ns2.ior" );

$def_port = 2809;
@ns_orb_port=( 12000 + PerlACE::uniqueid (),
               $def_port);

# List of tests to test corbaloc URL syntax.
@corbaloc_tests = ("corbaloc:rir:/NameService",
         "corbaloc:rir:/",
         "corbaloc:iiop:$TARGETHOSTNAME:$ns_orb_port[0]/NameService",
         "corbaloc::$TARGETHOSTNAME:$ns_orb_port[0]/NameService",
         "corbaloc::1.0\@$TARGETHOSTNAME:$ns_orb_port[0]/NameService",
	 "corbaloc::$TARGETHOSTNAME/NameService",
         "corbaloc::1.1\@$TARGETHOSTNAME:$ns_orb_port[0]/NameService",
         "corbaloc::1.2\@$TARGETHOSTNAME:$ns_orb_port[0]/NameService");


@comments = ("Using RIR protocol with the object key specified: \n",
             "Using RIR protocol without specifying the object key: \n(empty object key defaults to \"NameService\"\n",
             "Using IIOP protocol with the hostname, port specified: \n",
             "Using IIOP protocol, with protocol unspecified, hostname specified, port specified: \n",
             "Using the default protocol (iiop) with the hostname, port specified: \n",
             "Using IIOP protocol with protocol unspecified, hostname specified, port unspecified\n(should default to $def_port): \n");

$test_number = 0;

# Run the naming service, server. Run the client for each of the test. 
# Client uses ior in a file to bootstrap to the server.

@SR = (new PerlACE::Process ("server"),
       new PerlACE::Process ("server"),
       new PerlACE::Process ("server"));
@SR_NAME=( "STATUS", "STATUS1", "STATUS");

$CL = new PerlACE::Process ("client");
$CN_CL = new PerlACE::Process ("corbaname_client");

# We run two Naming_Service processes.  One on an arbitrary port,
# and one on the corbaloc: default port of 2809
@NS = (new PerlACE::Process ("../../orbsvcs/Naming_Service/Naming_Service"),
       new PerlACE::Process ("../../orbsvcs/Naming_Service/Naming_Service"));

for($i=0; $i <= $#NS; $i++){
  # Make sure the files are gone, so we can wait on them.
  unlink $iorfile[$i];
  print STDERR "Spawning Naming Service on port $ns_orb_port[$i]......\n";
  $NS[$i]->Arguments (" -ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port[$i]"
                      ." -o $iorfile[$i] -m 0");
  
  $NS[$i]->Spawn ();
  
  if (PerlACE::waitforfile_timed ($iorfile[$i], $sleeptime) == -1) {
    print STDERR "ERROR: cannot find IOR file <$iorfile[$i]>\n";
    $NS[$i]->Kill (); 
    exit 1;
  }
}

sleep 2;

for($i=0; $i <= $#SR; $i++){
  print STDERR "Spawning server with name $SR_NAME[$i]\n";
  $SR[$i]->Arguments ("-ORBInitRef NameService=file://$iorfile[$i] $SR_NAME[$i]");
  $SR[$i]->Spawn ();
}

sleep 5;


print STDERR "\n======= Running corbaloc: tests\n";
foreach $o (@corbaloc_tests) {  
  print STDERR "\n".$test_number.".  ".$comments[$test_number];
  print STDERR "             $o\n";
  
  
  $CL->Arguments ("$o -ORBInitRef NameService=file://$iorfile[0]");
  $client = $CL->SpawnWaitKill (60);
  
  if ($client != 0) {
    print STDERR "ERROR: client returned $client\n";
    $status = 1;
  }
  
  $test_number++;
}



print STDERR "\n======= Running corbaname: tests\n";
@corbaname_tests = ("corbaname:iiop:$TARGETHOSTNAME:$ns_orb_port[0]#$SR_NAME[0]",
                    "corbaname::$TARGETHOSTNAME:$ns_orb_port[0]#$SR_NAME[0]",

                    "corbaname::$TARGETHOSTNAME#$SR_NAME[1]",
                    "corbaname::$TARGETHOSTNAME:$ns_orb_port[1]#$SR_NAME[1]",
                    "corbaname:rir:#$SR_NAME[1] -orbinitref NameService=file://$iorfile[1]");

foreach $o ( @corbaname_tests ){
  print STDERR "\n$test_number:  $o\n";
  $CN_CL->Arguments ("$o $corbaname_tests[$i]");
  $client = $CN_CL->SpawnWaitKill (60);


  $test_number++;
}


for($i=0; $i <= $#NS; $i++){
$nameservice = $NS[$i]->TerminateWaitKill (10); 

if ($nameservice != 0) {
  print STDERR "ERROR: name server $i returned $nameservice\n";
  $status = 1;
}
}


for($i=0; $i <= $#SR; $i++){
$server = $SR[$i]->TerminateWaitKill (10);
if ($server != 0) {
  print STDERR "ERROR: server $i returned $server\n";
  $status = 1;
}
}

exit $status;