Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / NotifyService / RTNotify / run_test.pl
blobd2e11e0c8f5cb04cc76f87f098ee1bc4a49a61fa
2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
4 if 0;
6 use lib "$ENV{ACE_ROOT}/bin";
7 use PerlACE::TestTarget;
9 $status = 0;
10 $debug_level = '0';
12 foreach $i (@ARGV) {
13 if ($i eq '-debug') {
14 $debug_level = '10';
18 my $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
19 my $nfs = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $srv = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $con = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
22 my $cli = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 $nsiorfile = "ns.ior";
25 $srviorfile = "Messenger.ior";
26 $nfsiorfile = "notify.ior";
27 $confile = "MessengerConsumer.ready";
28 $conconf = "notify.conf";
29 $nscliconf = "nsclient.conf";
31 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
32 my $nfs_nsiorfile = $nfs->LocalFile ($nsiorfile);
33 my $srv_nsiorfile = $srv->LocalFile ($nsiorfile);
34 my $con_nsiorfile = $con->LocalFile ($nsiorfile);
35 my $nfs_nfsiorfile = $nfs->LocalFile ($nfsiorfile);
36 my $srv_srviorfile = $srv->LocalFile ($srviorfile);
37 my $cli_srviorfile = $cli->LocalFile ($srviorfile);
38 my $con_confile = $con->LocalFile ($confile);
39 my $con_conconf = $con->LocalFile ($conconf);
40 my $srv_nscliconf = $srv->LocalFile ($nscliconf);
41 my $con_nscliconf = $con->LocalFile ($nscliconf);
42 $ns->DeleteFile ($nsiorfile);
43 $nfs->DeleteFile ($nsiorfile);
44 $srv->DeleteFile ($nsiorfile);
45 $con->DeleteFile ($nsiorfile);
46 $nfs->DeleteFile ($nfsiorfile);
47 $srv->DeleteFile ($srviorfile);
48 $cli->DeleteFile ($srviorfile);
49 $con->DeleteFile ($confile);
51 $NameService = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming";
52 $NS = $ns->CreateProcess ($NameService, " -o $ns_nsiorfile");
55 $NotifyService = "$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification";
56 $NFS = $nfs->CreateProcess ($NotifyService, "-ORBInitRef NameService=file://$nfs_nsiorfile ".
57 "-IORoutput $nfs_nfsiorfile ".
58 "-ORBSvcConf $con_conconf");
59 $SRV = $srv->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
60 "-o $srv_srviorfile ".
61 "-ORBInitRef NameService=file://$srv_nsiorfile ".
62 "-ORBSvcConf $srv_nscliconf");
63 $CON = $con->CreateProcess ("MessengerConsumer", "-ORBInitRef NameService=file://$con_nsiorfile ".
64 "-ORBSvcConf $con_nscliconf ".
65 "-o $con_confile");
66 $CLI = $cli->CreateProcess ("MessengerClient", "-k file://$cli_srviorfile");
68 # start Naming Service
69 $NS_status = $NS->Spawn ();
71 if ($NS_status != 0) {
72 print STDERR "ERROR: Name Service returned $NS_status\n";
73 exit 1;
76 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
77 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
78 $NS->Kill (); $NS->TimedWait (1);
79 exit 1;
82 if ($ns->GetFile ($nsiorfile) == -1) {
83 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
84 $NS->Kill (); $NS->TimedWait (1);
85 exit 1;
87 if ($nfs->PutFile ($nsiorfile) == -1) {
88 print STDERR "ERROR: cannot set file <$nfs_nsiorfile>\n";
89 $NS->Kill (); $NS->TimedWait (1);
90 exit 1;
92 if ($srv->PutFile ($nsiorfile) == -1) {
93 print STDERR "ERROR: cannot set file <$srv_nsiorfile>\n";
94 $NS->Kill (); $NS->TimedWait (1);
95 exit 1;
97 if ($con->PutFile ($nsiorfile) == -1) {
98 print STDERR "ERROR: cannot set file <$con_nsiorfile>\n";
99 $NS->Kill (); $NS->TimedWait (1);
100 exit 1;
103 # start Notification Service
104 $NFS_status = $NFS->Spawn ();
106 if ($NFS_status != 0) {
107 print STDERR "ERROR: Notify Service returned $NFS_status\n";
108 exit 1;
111 if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
112 print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
113 $NS->Kill (); $NS->TimedWait (1);
114 $NFS->Kill (); $NFS->TimedWait (1);
115 exit 1;
118 # start MessengerServer
119 $SRV_status = $SRV->Spawn ();
121 if ($SRV_status != 0) {
122 print STDERR "ERROR: Server returned $SRV_status\n";
123 exit 1;
126 if ($srv->WaitForFileTimed ($srviorfile,$srv->ProcessStartWaitInterval()) == -1) {
127 print STDERR "ERROR: cannot find file <$srv_srviorfile>\n";
128 $SRV->Kill (); $SRV->TimedWait (1);
129 $NS->Kill (); $NS->TimedWait (1);
130 $NFS->Kill (); $NFS->TimedWait (1);
131 exit 1;
134 if ($srv->GetFile ($srviorfile) == -1) {
135 print STDERR "ERROR: cannot retrieve file <$srv_srviorfile>\n";
136 $SRV->Kill (); $SRV->TimedWait (1);
137 $NS->Kill (); $NS->TimedWait (1);
138 $NFS->Kill (); $NFS->TimedWait (1);
139 exit 1;
141 if ($cli->PutFile ($srviorfile) == -1) {
142 print STDERR "ERROR: cannot set file <$cli_srviorfile>\n";
143 $SRV->Kill (); $SRV->TimedWait (1);
144 $NS->Kill (); $NS->TimedWait (1);
145 $NFS->Kill (); $NFS->TimedWait (1);
146 exit 1;
149 # start MessengerConsumer
150 $CON_status = $CON->Spawn ();
152 if ($CON_status != 0) {
153 print STDERR "ERROR: Consumer returned $CON_status\n";
154 exit 1;
157 if ($con->WaitForFileTimed ($confile,$con->ProcessStartWaitInterval()) == -1) {
158 print STDERR "ERROR: cannot find file <$con_confile>\n";
159 $CON->Kill (); $CON->TimedWait (1);
160 $SRV->Kill (); $SRV->TimedWait (1);
161 $NS->Kill (); $NS->TimedWait (1);
162 $NFS->Kill (); $NFS->TimedWait (1);
163 exit 1;
166 # start MessengerClient
167 $CLI_status = $CLI->SpawnWaitKill ($cli->ProcessStartWaitInterval());
169 if ($CLI_status != 0) {
170 print STDERR "ERROR: Messenger Client returned $CLI_status\n";
171 $CON->Kill (); $CON->TimedWait (1);
172 $SRV->Kill (); $SRV->TimedWait (1);
173 $NFS->Kill (); $NFS->TimedWait (1);
174 $NS->Kill (); $NS->TimedWait (1);
175 $status = 1;
178 $CON_status = $CON->TerminateWaitKill ($con->ProcessStopWaitInterval());
180 if ($CON_status != 0) {
181 print STDERR "ERROR: Messenger Consumer returned $CON_status\n";
182 $status = 1;
185 $SRV_status = $SRV->TerminateWaitKill ($srv->ProcessStopWaitInterval());
187 if ($SRV_status != 0) {
188 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
189 $status = 1;
191 $NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
193 if ($NFS_status != 0) {
194 print STDERR "ERROR: Notification Service returned $NFS_status\n";
195 $status = 1;
198 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
200 if ($NS_status != 0) {
201 print STDERR "ERROR: Name Service returned $NS_status\n";
202 $status = 1;
205 $ns->DeleteFile ($nsiorfile);
206 $nfs->DeleteFile ($nsiorfile);
207 $srv->DeleteFile ($nsiorfile);
208 $con->DeleteFile ($nsiorfile);
209 $nfs->DeleteFile ($nfsiorfile);
210 $srv->DeleteFile ($srviorfile);
211 $cli->DeleteFile ($srviorfile);
212 $con->DeleteFile ($confile);
214 exit $status;