Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / ForwardOnceUponException / run_test.pl
blobe15162cd04bde90b5af1bd44f3ce10fc3ffb256c
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 # Current supported forward once exceptions:
20 # EF_OBJECT_NOT_EXIST = 0x1,
21 # EF_COMM_FAILURE = 0x2,
22 # EF_TRANSIENT = 0x4,
23 # EF_INV_OBJREF = 0x8,
24 @configurations = ({
25 description => "case 1: not forward upon OBJECT_NOT_EXIST exception",
26 orb_exception_forward_opt => "-ORBForwardOnceOnObjectNotExist 0",
27 num_requests => "1",
28 client_expect_num_ex => "1",
29 client_expect_ex_kind => "1",
30 server_raise_ex_kind => "1",
31 servant_calls => "1",
32 },{
33 description => "case 2: default Fault Tolerant always forward upon COMM_FAILURE exception",
34 orb_exception_forward_opt => "-ORBForwardOnceOnCommFailure 0",
35 num_requests => "1",
36 client_expect_num_ex => "0",
37 client_expect_ex_kind => "0",
38 server_raise_ex_kind => "2",
39 servant_calls => "0", # use 0 to indicate request looping case
40 },{
41 description => "case 3: default Fault Tolerant always forward upon TRANSIENT exception",
42 orb_exception_forward_opt => "-ORBForwardOnceOnTransient 0",
43 num_requests => "1",
44 client_expect_num_ex => "0",
45 client_expect_ex_kind => "0",
46 server_raise_ex_kind => "4",
47 servant_calls => "0", # use 0 to indicate request looping case
48 },{
49 description => "case 4: not forward upon INV_OBJREF exception",
50 orb_exception_forward_opt => "-ORBForwardOnceOnInvObjref 0",
51 num_requests => "1",
52 client_expect_num_ex => "1",
53 client_expect_ex_kind => "8",
54 server_raise_ex_kind => "8",
55 servant_calls => "1",
56 },{
57 description => "case 5: forward once upon OBJECT_NOT_EXIST exception",
58 orb_exception_forward_opt => "-ORBForwardOnceOnObjectNotExist 1",
59 num_requests => "4",
60 client_expect_num_ex => "4",
61 client_expect_ex_kind => "1",
62 server_raise_ex_kind => "1",
63 servant_calls => "5", # 4 requests + 1 forward
64 },{
65 description => "case 6: forward once upon COMM_FAILURE exception",
66 orb_exception_forward_opt => "-ORBForwardOnceOnCommFailure 1",
67 num_requests => "4",
68 client_expect_num_ex => "4",
69 client_expect_ex_kind => "2",
70 server_raise_ex_kind => "2",
71 servant_calls => "5", # 4 requests + 1 forward
72 },{
73 description => "case 7: forward once upon TRANSIENT exception",
74 orb_exception_forward_opt => "-ORBForwardOnceOnTransient 1",
75 num_requests => "4",
76 client_expect_num_ex => "4",
77 client_expect_ex_kind => "4",
78 server_raise_ex_kind => "4",
79 servant_calls => "5", # 4 requests + 1 forward
80 },{
81 description => "case 8: forward once upon INV_OBJREF exception",
82 orb_exception_forward_opt => "-ORBForwardOnceOnInvObjref 1",
83 num_requests => "4",
84 client_expect_num_ex => "4",
85 client_expect_ex_kind => "8",
86 server_raise_ex_kind => "8",
87 servant_calls => "5", # 4 requests + 1 forward
91 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
92 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
94 my $iorbase = "test.ior";
95 my $host = $server->HostName();
96 my $server_iorfile = $server->LocalFile ($iorbase);
97 my $client_iorfile = $client->LocalFile ($iorbase);
99 for $test (@configurations) {
100 print STDERR "\n==== Running $test->{description} \n\n";
102 my $port = $server->RandomPort();
103 $server->DeleteFile($iorbase);
104 $client->DeleteFile($iorbase);
106 $SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level ".
107 "-o $server_iorfile ".
108 "-ORBEndpoint iiop://$host:$port ".
109 "-e $test->{server_raise_ex_kind} ".
110 "-r $test->{servant_calls}");
112 $CL = $client->CreateProcess ("client", "-k corbaloc::$host:$port/Simple_Server -x ".
113 "-e $test->{client_expect_ex_kind} " .
114 "-n $test->{client_expect_num_ex} ".
115 "-i $test->{num_requests} $test->{orb_exception_forward_opt}");
117 print STDERR $SV->CommandLine () . "\n";
118 print STDERR $CL->CommandLine () . "\n";
120 $server_status = $SV->Spawn ();
122 if ($server_status != 0) {
123 print STDERR "ERROR: server returned $server_status\n";
124 exit 1;
127 if ($server->WaitForFileTimed ($iorbase,
128 $server->ProcessStartWaitInterval()) == -1) {
129 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
130 $SV->Kill (); $SV->TimedWait (1);
131 exit 1;
134 if ($server->GetFile ($iorbase) == -1) {
135 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
136 $SV->Kill (); $SV->TimedWait (1);
137 exit 1;
140 if ($client->PutFile ($iorbase) == -1) {
141 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
142 $SV->Kill (); $SV->TimedWait (1);
143 exit 1;
146 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 45);
148 if ($client_status != 0) {
149 print STDERR "ERROR: client returned $client_status\n";
150 $status = 1;
153 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
155 if ($server_status != 0) {
156 print STDERR "ERROR: server returned $server_status\n";
157 $status = 1;
162 $server->DeleteFile($iorbase);
163 $client->DeleteFile($iorbase);
165 exit $status;