summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/run_test.pl
blob: 42b85861cf6c0fa0bb47231f5c32a6467961eb47 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
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::TestTarget;

$status = 0;

# 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";
}

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 $test = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";

my $iorbase = "if_repo.ior";
my $testoutputfilename = "IFR_Inheritance_test.output";

my $log1 = "server1.log"; 
my $log2 = "server2.log";
my $log3 = "client.log";

my $log1_test = $test->LocalFile ($log1);
my $log2_test = $test->LocalFile ($log2); 
my $log3_test = $test->LocalFile ($log3);

$test->DeleteFile ($log1);
$test->DeleteFile ($log2); 
$test->DeleteFile ($log3);

my $test_iorfile = $test->LocalFile ($iorbase);
$test->DeleteFile($iorbase);

$SV1 = $test->CreateProcess ("../../../IFR_Service/IFR_Service",
                              " -o $test_iorfile " .
                              "-ORBLogFile $log1_test");

$SV2 = $test->CreateProcess ("$tao_ifr",
                              " IFR_Inheritance_Test.idl " .
                              "-ORBInitRef InterfaceRepository=file://$test_iorfile " .
                              "-ORBLogFile $log2_test");
                              
$CL = $test->CreateProcess ("IFR_Inheritance_Test",
                              "-ORBInitRef InterfaceRepository=file://$test_iorfile " .
                              "-ORBLogFile $log3_test"); 

$server_status = $SV1->Spawn ();

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

if ($test->WaitForFileTimed ($iorbase,
                               $test->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$test_iorfile>\n";
    $SV1->Kill (); $SV1->TimedWait (1);
    exit 1;
}

$server_status = $SV2->SpawnWaitKill ($test->ProcessStartWaitInterval());

if ($server_status != 0) {
    print STDERR "ERROR: server returned $server_status\n";
    $SV1->Kill (); $SV1->TimedWait (1);
    $SV2->Kill (); $SV2->TimedWait (1);
    exit 1;
}

$client_status = $CL->SpawnWaitKill ($test->ProcessStartWaitInterval() + 45);

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

my $type = "";
my $name = "";

foreach $result_file ("$log3_test"){
    open(THELOG, "< $result_file") 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;
    }
}

$server_status = $SV1->TerminateWaitKill ($test->ProcessStopWaitInterval());

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

$test->DeleteFile ($log1);
$test->DeleteFile ($log2); 
$test->DeleteFile ($log3);
$test->DeleteFile($iorbase);

exit $status;