summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/run_test.pl
blob: ce9cf02cfaab0203a604e42de782df8cfcf91d54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# -*- perl -*-

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::Run_Test;
use strict;

my %isa = ();
$isa{"InterfaceRoot::get_root"}      = "operation";
$isa{"InterfaceRoot::get_all_roots"} = "operation";
$isa{"InterfaceRoot::root_attr1"}    = "attribute";
$isa{"InterfaceRoot::root_attr2"}    = "attribute";
$isa{"InterfaceRoot::root_attr3"}    = "attribute";
$isa{"SubInterface::get_root"}       = "operation";
$isa{"SubInterface::get_all_roots"}  = "operation";
$isa{"SubInterface::set_sub"}        = "operation";
$isa{"SubInterface::get_all_subs"}   = "operation";
$isa{"SubInterface::root_attr1"}     = "attribute";
$isa{"SubInterface::root_attr2"}     = "attribute";
$isa{"SubInterface::root_attr3"}     = "attribute";
$isa{"SubInterface::sub_attr1"}      = "attribute";
$isa{"SubInterface::sub_attr2"}      = "attribute";

my %got = ();
$got{"InterfaceRoot::get_root"}      = 13;
$got{"InterfaceRoot::get_all_roots"} = 13;
$got{"InterfaceRoot::root_attr1"}    = 13;
$got{"InterfaceRoot::root_attr2"}    = 13;
$got{"InterfaceRoot::root_attr3"}    = 13;
$got{"SubInterface::get_root"}       = 13;
$got{"SubInterface::get_all_roots"}  = 13;
$got{"SubInterface::set_sub"}        = 13;
$got{"SubInterface::get_all_subs"}   = 13;
$got{"SubInterface::root_attr1"}     = 13;
$got{"SubInterface::root_attr2"}     = 13;
$got{"SubInterface::root_attr3"}     = 13;
$got{"SubInterface::sub_attr1"}      = 13;
$got{"SubInterface::sub_attr2"}      = 13;

my $iorfile = "if_repo.ior";

my $testoutputfilename = "IFR_Inheritance_test.output";

unlink $testoutputfilename;

my $status = 0;

unlink $iorfile;

my $SV = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " -o $iorfile" );

my $CL = new PerlACE::Process ("IFR_Inheritance_Test",
                            " -ORBInitRef InterfaceRepository=file://$iorfile");

# The location of the tao_idl utility - depends on O/S
my $tao_ifr = "undefined";
if ($^O eq "MSWin32")
{
   $tao_ifr = "$ENV{ACE_ROOT}/bin/tao_ifr";
}
else
{
   $tao_ifr = "../../../IFR_Service/tao_ifr";
}

# Compile the IDL
#
my $TAO_IFR    = new PerlACE::Process("$tao_ifr",
                            "IFR_Inheritance_Test.idl"
                          . " -ORBInitRef InterfaceRepository=file://$iorfile");

$SV->Spawn ();

if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) {
    print STDERR "ERROR: cannot find file <$iorfile>\n";
    $SV->Kill ();
    exit 1;
}

if( $TAO_IFR->SpawnWaitKill(20) != 0 )
{
   print STDERR "ERROR: can't compile IDL\n";
   $TAO_IFR->Kill ();
   $status = 1;
   exit $status;
}

# Redirect STDERR to a log file so that
# we can make sure that we got a warning
open(SAVE, ">&STDOUT");
open(STDOUT, ">$testoutputfilename");

my $client = $CL->SpawnWaitKill (60);

# Close the log file and restore STDERR
close(STDOUT);
open(STDOUT, ">&SAVE");


my $type = "";
my $name = "";
open(THELOG, "< $testoutputfilename") or die "could not open the saved log";
while (<THELOG>) {
   if (/^attribute/ || "^operation") {
      chomp($_);
      ($type, $name) = split(/ /, $_);
      #print "found $type $name\n";
      if ($isa{$name} eq $type) {
        #print "got $name\n";
        $got{$name} = 1;
      }
      else {
        print STDERR "ERROR: $type $name was not expected\n";
        $status = 1;
      }
   }
   else {
     print STDOUT "ERROR: unexpected line: $_\n";
   }
}
close(THELOG);

### did we get all of the expected attributes and operations?
my $key = "";
foreach $key (keys (%got)) {
    #print "got\{$key\} = $got{$key}\n";
    if (! exists $isa{$key} ) {
        print STDERR "CONFIG ERROR: \$got has $key but \$isa does not\n";
        $status = 1;
    }
    if ($got{$key} == 13) {
        print STDERR "ERROR: $isa{$key} $key was not found\n";
        $status = 1;
    }
}

if ($client != 0) {
    print STDERR "ERROR: client returned $client\n";
    $status = 1;
}

my $server = $SV->TerminateWaitKill (5);

if ($server != 0) {
    print STDERR "ERROR: server returned $server\n";
    $status = 1;
}

unlink $iorfile;
unlink $testoutputfilename;

exit $status;