Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Callback_Quoter / run_test.pl
blobaa17ce46de6c969f205ace2d8db67fae1fc5bb88
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 # amount of delay between running the servers
15 $sleeptime = 15;
17 foreach $i (@ARGV) {
18 if ($i eq '-debug') {
19 $debug_level = '10';
23 my $nstarget = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
24 my $ntarget = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
25 my $ctarget = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
26 my $starget = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
28 my $nsiorbase = "ns.ior";
29 my $examplebase = "example.stocks";
30 my $nstarget_nsiorfile = $nstarget->LocalFile ($nsiorbase);
31 my $ntarget_nsiorfile = $ntarget->LocalFile ($nsiorbase);
32 my $ctarget_nsiorfile = $ctarget->LocalFile ($nsiorbase);
33 my $starget_nsiorfile = $starget->LocalFile ($nsiorbase);
34 my $starget_examplefile = $starget->LocalFile ($examplebase);
35 $nstarget->DeleteFile($nsiorbase);
36 $ntarget->DeleteFile($nsiorbase);
37 $ctarget->DeleteFile($nsiorbase);
38 $starget->DeleteFile($nsiorbase);
40 # Programs that are run
42 $NS = $nstarget->CreateProcess (
43 "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
44 "-o $nstarget_nsiorfile");
45 $N = $ntarget->CreateProcess (
46 "notifier",
47 "-ORBDebugLevel $debug_level ".
48 "-ORBInitRef NameService=file://$ntarget_nsiorfile");
49 $C = $ctarget->CreateProcess (
50 "consumer",
51 "-ORBInitRef NameService=file://$ctarget_nsiorfile -t 12 -a TAO");
52 $S = $starget->CreateProcess (
53 "supplier",
54 "-ORBInitRef NameService=file://$starget_nsiorfile -i $starget_examplefile");
56 print STDERR "================ Remote test\n";
58 $ns_status = $NS->Spawn ();
60 if ($ns_status != 0) {
61 print STDERR "ERROR: tao_cosnaming returned $ns_status\n";
62 exit 1;
65 if ($nstarget->WaitForFileTimed ($nsiorbase,
66 $nstarget->ProcessStartWaitInterval()) == -1) {
67 print STDERR "ERROR: cannot find file <$nstarget_nsiorfile>\n";
68 $NS->Kill (); $NS->TimedWait (1);
69 exit 1;
71 if ($nstarget->GetFile ($nsiorbase) == -1) {
72 print STDERR "ERROR: cannot retrieve file <$nstarget_nsiorfile>\n";
73 $NS->Kill (); $NS->TimedWait (1);
74 exit 1;
76 if ($ntarget->PutFile ($nsiorbase) == -1) {
77 print STDERR "ERROR: cannot set file <$ntarget_nsiorfile>\n";
78 $NS->Kill (); $NS->TimedWait (1);
79 exit 1;
81 if ($ctarget->PutFile ($nsiorbase) == -1) {
82 print STDERR "ERROR: cannot set file <$ctarget_nsiorfile>\n";
83 $NS->Kill (); $NS->TimedWait (1);
84 exit 1;
86 if ($starget->PutFile ($nsiorbase) == -1) {
87 print STDERR "ERROR: cannot set file <$starget_nsiorfile>\n";
88 $NS->Kill (); $NS->TimedWait (1);
89 exit 1;
92 $n_status = $N->Spawn ();
94 if ($n_status != 0) {
95 print STDERR "ERROR: notifier returned $n_status\n";
96 $NS->Kill (); $NS->TimedWait (1);
97 exit 1;
99 sleep $sleeptime;
101 $c_status = $C->Spawn ();
103 if ($c_status != 0) {
104 print STDERR "ERROR: consumer returned $c_status\n";
105 $NS->Kill (); $NS->TimedWait (1);
106 $N->Kill (); $N->TimedWait (1);
107 exit 1;
109 sleep $sleeptime;
111 $s_status = $S->SpawnWaitKill ($starget->ProcessStopWaitInterval() + 60);
113 if ($s_status != 0) {
114 print STDERR "ERROR: supplier returned $s_status\n";
115 $NS->Kill (); $NS->TimedWait (1);
116 $N->Kill (); $N->TimedWait (1);
117 $C->Kill (); $C->TimedWait (1);
118 exit 1;
121 $c_status = $C->TerminateWaitKill ($ctarget->ProcessStopWaitInterval());
123 if ($c_status != 0) {
124 print STDERR "ERROR: consumer returned $c_status\n";
125 $status = 1;
128 $n_status = $N->TerminateWaitKill ($ntarget->ProcessStopWaitInterval());
130 if ($n_status != 0) {
131 print STDERR "ERROR: notifier returned $n_status\n";
132 $status = 1;
135 $ns_status = $NS->TerminateWaitKill ($nstarget->ProcessStopWaitInterval());
137 if ($ns_status != 0) {
138 print STDERR "ERROR: tao_cosnaming returned $ns_status\n";
139 $status = 1;
142 $nstarget->DeleteFile($nsiorbase);
143 $ntarget->DeleteFile($nsiorbase);
144 $ctarget->DeleteFile($nsiorbase);
145 $starget->DeleteFile($nsiorbase);
147 exit $status;