Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / examples / Log / RTEvent / run_test.pl
blobcd80ce9f4f85e72172f6786afeb4a6317cd91ed6
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 use lib "$ENV{ACE_ROOT}/bin";
8 use PerlACE::TestTarget;
10 $status = 0;
11 $debug_level = '0';
13 foreach $i (@ARGV) {
14 if ($i eq '-debug') {
15 $debug_level = '10';
19 my $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $ls = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $con = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $sup = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
24 $nsiorfile = "ns.ior";
26 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
27 my $ls_nsiorfile = $ls->LocalFile ($nsiorfile);
28 my $con_nsiorfile = $con->LocalFile ($nsiorfile);
29 my $sup_nsiorfile = $sup->LocalFile ($nsiorfile);
30 $ns->DeleteFile ($nsiorfile);
31 $ls->DeleteFile ($nsiorfile);
32 $con->DeleteFile ($nsiorfile);
33 $sup->DeleteFile ($nsiorfile);
35 $NS = $ns->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
36 " -o $ns_nsiorfile");
37 $LS = $ls->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Logging_Service/RTEvent_Logging_Service/tao_tls_rtevent",
38 " -ORBInitRef NameService=file://$ls_nsiorfile");
39 $CON = $con->CreateProcess ("RTEvent_Consumer",
40 "-ORBInitRef NameService=file://$con_nsiorfile");
41 $SUP = $sup->CreateProcess ("RTEvent_Supplier",
42 "-ORBInitRef NameService=file://$sup_nsiorfile");
44 print STDERR "Starting Naming Service\n";
45 $NS_status = $NS->Spawn ();
47 if ($NS_status != 0) {
48 print STDERR "ERROR: Name Service returned $NS_status\n";
49 exit 1;
52 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
53 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
54 $NS->Kill (); $NS->TimedWait (1);
55 exit 1;
58 if ($ns->GetFile ($nsiorfile) == -1) {
59 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
60 $NS->Kill (); $NS->TimedWait (1);
61 exit 1;
63 if ($ls->PutFile ($nsiorfile) == -1) {
64 print STDERR "ERROR: cannot set file <$ls_nsiorfile>\n";
65 $NS->Kill (); $NS->TimedWait (1);
66 exit 1;
68 if ($con->PutFile ($nsiorfile) == -1) {
69 print STDERR "ERROR: cannot set file <$con_nsiorfile>\n";
70 $NS->Kill (); $NS->TimedWait (1);
71 exit 1;
73 if ($sup->PutFile ($nsiorfile) == -1) {
74 print STDERR "ERROR: cannot set file <$sup_nsiorfile>\n";
75 $NS->Kill (); $NS->TimedWait (1);
76 exit 1;
79 print STDERR "Starting Logging Service\n";
81 $LS_status = $LS->Spawn ();
83 if ($LS_status != 0) {
84 print STDERR "ERROR: Logging Service returned $LS_status\n";
85 $LS->Kill (); $LS->TimedWait (1);
86 $NS->Kill (); $NS->TimedWait (1);
87 exit 1;
90 # Give time for logging service to initialize and install its object
91 # reference in the naming service.
92 sleep (5);
94 print STDERR "Starting Consumer\n";
96 $CON_status = $CON->Spawn ();
97 if ($CON_status != 0) {
98 print STDERR "ERROR: RTEvent Consumer returned $CON_status\n";
99 $CON->Kill (); $CON->TimedWait (1);
100 $LS->Kill (); $LS->TimedWait (1);
101 $NS->Kill (); $NS->TimedWait (1);
102 exit 1;
105 sleep (1);
107 print STDERR "Starting Supplier\n";
109 $SUP_status = $SUP->Spawn ();
110 if ($SUP_status != 0) {
111 print STDERR "ERROR: RTEvent Supplier returned $SUP_status\n";
112 $status = 1;
115 $SUP_status = $SUP->WaitKill ($sup->ProcessStopWaitInterval());
116 if ($SUP_status != 0) {
117 print STDERR "ERROR: RTEvent Supplier returned $SUP_status\n";
118 $status = 1;
121 $CON_status = $CON->TerminateWaitKill ($con->ProcessStopWaitInterval());
123 if ($CON_status != 0) {
124 print STDERR "ERROR: RTEvent Consumer returned $CON_status\n";
125 $status = 1;
128 $LS_status = $LS->TerminateWaitKill ($ls->ProcessStopWaitInterval());
130 if ($LS_status != 0) {
131 print STDERR "ERROR: Logging Service returned $LS_status\n";
132 $status = 1;
135 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
137 if ($NS_status != 0) {
138 print STDERR "ERROR: Name Service returned $NS_status\n";
139 $status = 1;
143 $ns->DeleteFile ($nsiorfile);
144 $ls->DeleteFile ($nsiorfile);
145 $con->DeleteFile ($nsiorfile);
146 $sup->DeleteFile ($nsiorfile);
148 exit $status;