Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / EventServices / OMG_Basic / run_test.pl
blobe00e28e7dd6583592e757b4db63ce5cba1b90f5a
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 $es = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $s = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $c = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $nsiorfile = "ns.ior";
24 my $esiorfile = "es.ior";
26 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
27 my $es_nsiorfile = $es->LocalFile ($nsiorfile);
28 my $s_nsiorfile = $s->LocalFile ($nsiorfile);
29 my $c_nsiorfile = $c->LocalFile ($nsiorfile);
30 my $es_esiorfile = $es->LocalFile ($esiorfile);
31 $ns->DeleteFile ($nsiorfile);
32 $es->DeleteFile ($nsiorfile);
33 $s->DeleteFile ($nsiorfile);
34 $c->DeleteFile ($nsiorfile);
35 $es->DeleteFile ($esiorfile);
37 $sleeptime = 10;
39 $NameService = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming";
40 $NS = $ns->CreateProcess ($NameService, "-ORBdebuglevel $debug_level -ORBListenEndpoints iiop://:2809 ".
41 " -o $ns_nsiorfile");
43 $EventService = "$ENV{TAO_ROOT}/orbsvcs/CosEvent_Service/tao_cosevent";
44 $ES = $es->CreateProcess ($EventService, " -o $es_esiorfile ".
45 "-ORBInitRef NameService=file://$es_nsiorfile");
46 $S = $ns->CreateProcess ("EchoEventSupplier", "-ORBInitRef NameService=file://$s_nsiorfile");
47 $C = $ns->CreateProcess ("EchoEventConsumer", "-ORBInitRef NameService=file://$c_nsiorfile");
49 # start Naming Service
50 $NS_status = $NS->Spawn ();
52 if ($NS_status != 0) {
53 print STDERR "ERROR: Name Service returned $NS_status\n";
54 exit 1;
57 sleep $sleeptime;
59 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
60 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
61 $NS->Kill (); $NS->TimedWait (1);
62 exit 1;
65 if ($ns->GetFile ($nsiorfile) == -1) {
66 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
67 $NS->Kill (); $NS->TimedWait (1);
68 exit 1;
70 if ($es->PutFile ($nsiorfile) == -1) {
71 print STDERR "ERROR: cannot set file <$es_nsiorfile>\n";
72 $NS->Kill (); $NS->TimedWait (1);
73 exit 1;
75 if ($s->PutFile ($nsiorfile) == -1) {
76 print STDERR "ERROR: cannot set file <$s_nsiorfile>\n";
77 $NS->Kill (); $NS->TimedWait (1);
78 exit 1;
80 if ($c->PutFile ($nsiorfile) == -1) {
81 print STDERR "ERROR: cannot set file <$c_nsiorfile>\n";
82 $NS->Kill (); $NS->TimedWait (1);
83 exit 1;
86 # start Event Service
87 $ES_status = $ES->Spawn ();
89 if ($ES_status != 0) {
90 print STDERR "ERROR: Event Service returned $ES_status\n";
91 exit 1;
94 sleep $sleeptime;
96 if ($es->WaitForFileTimed ($esiorfile,$es->ProcessStartWaitInterval()) == -1) {
97 print STDERR "ERROR: cannot find file <$es_esiorfile>\n";
98 $ES->Kill (); $ES->TimedWait (1);
99 exit 1;
102 # start EchoEventSupplier
103 $S_status = $S->Spawn ();
105 if ($S_status != 0) {
106 print STDERR "ERROR: Supplier returned $S_status\n";
107 exit 1;
110 # start EchoEventConsumer
111 $C_status = $C->Spawn ();
113 if ($C_status != 0) {
114 print STDERR "ERROR: Consumer returned $C_status\n";
115 exit 1;
118 $C_status = $C->WaitKill ($c->ProcessStopWaitInterval()+45);
120 if ($C_status != 0) {
121 print STDERR "ERROR: Consumer returned $C_status\n";
122 $status = 1;
125 $S_status = $S->TerminateWaitKill ($s->ProcessStopWaitInterval());
127 if ($S_status != 0) {
128 print STDERR "ERROR: Supplier returned $S_status\n";
129 $status = 1;
132 $ES_status = $ES->TerminateWaitKill ($es->ProcessStopWaitInterval());
134 if ($ES_status != 0) {
135 print STDERR "ERROR: Event Service returned $ES_status\n";
136 $status = 1;
139 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
141 if ($NS_status != 0) {
142 print STDERR "ERROR: Name Service returned $NS_status\n";
143 $status = 1;
146 $ns->DeleteFile ($nsiorfile);
147 $es->DeleteFile ($nsiorfile);
148 $s->DeleteFile ($nsiorfile);
149 $c->DeleteFile ($nsiorfile);
150 $es->DeleteFile ($esiorfile);
152 exit $status;