Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_2935_Regression / run_test.pl
blob80a8b896f3e50cc6f8370c58f86b44d7e37f2339
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 sub count_matching_lines {
11 my($file) = shift;
12 my($pattern) = shift;
13 my($count) = 0;
14 open(FILE, $file);
15 while(<FILE>) {
16 ++$count if /$pattern/;
18 close FILE;
19 return $count;
22 $status = 0;
24 my $sink = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
25 my $middle = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
26 my $source = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
28 my $sinkiorfilebase = "sink.ior";
29 my $sinkiorfile = $sink->LocalFile ($sinkiorfilebase);
31 my $middleiorfilebase = "middle.ior";
32 my $middleiorfile = $middle->LocalFile ($middleiorfilebase);
34 my $sinklogfilebase = "sink.log";
35 my $sinklogfile = $sink->LocalFile ($sinklogfilebase);
37 my $middlelogfilebase = "middle.log";
38 my $middlelogfile = $middle->LocalFile ($middlelogfilebase);
40 my $sourcelogfilebase = "source.log";
41 my $sourcelogfile = $source->LocalFile ($sourcelogfilebase);
43 $sink->DeleteFile ($sinkiorfilebase);
44 $sink->DeleteFile ($sinklogfilebase);
46 $middle->DeleteFile ($middleiorfilebase);
47 $middle->DeleteFile ($middlelogfilebase);
49 $source->DeleteFile ($sourcelogfilebase);
51 my $middleconffilebase = "middle.conf";
52 my $middleconffile = $middle->LocalFile ($middleconffilebase);
54 # copy the configuation file
55 if ($middle->PutFile ($middleconffilebase) == -1) {
56 print STDERR "ERROR: cannot set file <$middleconffile>\n";
57 $SV->Kill (); $SV->TimedWait (1);
58 return 1;
62 $SV = $sink->CreateProcess ("sink", "-o $sinkiorfile -orblogfile $sinklogfile -orbdebuglevel 9");
63 $MD = $middle->CreateProcess ("middle", "-o $middleiorfile -f $sinkiorfile -ORBSvcConf $middleconffile -orblogfile $middlelogfile -orbdebuglevel 9");
64 $CL = $source->CreateProcess ("source", "-f $middleiorfile -orblogfile $sourcelogfile -orbdebuglevel 9");
66 $SV->Spawn ();
68 if ($sink->WaitForFileTimed ($sinkiorfilebase,
69 $sink->ProcessStartWaitInterval ()) == -1) {
70 print STDERR "ERROR: Could not find file <$sinkiorfile>\n";
71 $SV->Kill (); $SV->TimedWait (1);
72 exit 1;
75 $MD->Spawn ();
77 if ($middle->WaitForFileTimed($middleiorfilebase,
78 $middle->ProcessStartWaitInterval ()) == -1) {
79 print STDERR "ERROR: Could not find file <$middleiorfile>\n";
80 $SV->Kill (); $SV->TimedWait (1);
81 $MD->Kill (); $MD->TimedWait (1);
82 exit 1;
86 $source_status = $CL->SpawnWaitKill ($source->ProcessStartWaitInterval ());
88 if ($source_status != 0) {
89 print STDERR "ERROR: source returned $source_status\n";
90 $status = 1;
93 $middle_status = $MD->WaitKill ($middle->ProcessStopWaitInterval ());
94 if ($middle_status != 0) {
95 print STDERR "ERROR: middle returned $middle_status\n";
96 $status = 1;
99 $sink_status = $SV->WaitKill ($sink->ProcessStopWaitInterval ());
100 if ($sink_status != 0) {
101 print STDERR "ERROR: sink returned $sink_status\n";
102 $status = 1;
105 if($status == 0){
106 $connections = count_matching_lines($sinklogfile, "IIOP connection to peer");
107 if ($connections != 1) {
108 print STDERR "ERROR: Connections to sink should be 1: $connections\n";
109 $status = 1;
111 else {
112 print STDERR "OK: Found 1 connection to sink.\n";
116 if($status == 0){
117 $sink->DeleteFile ($sinkiorfilebase);
118 $sink->DeleteFile ($sinklogfilebase);
120 $middle->DeleteFile ($middleiorfilebase);
121 $middle->DeleteFile ($middlelogfilebase);
123 $source->DeleteFile ($sourcelogfilebase);
126 exit $status;