Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / ImplRepo / Bug_2604_Regression / run_test.pl
blob64e838ea3c155094ab8cfbe84d36f9368f65ee29
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
6 use lib "$ENV{ACE_ROOT}/bin";
7 use PerlACE::TestTarget;
9 $status = 0;
10 $debug_level = '0';
12 foreach $i (@ARGV) {
13 if ($i eq '-debug') {
14 $debug_level = '10';
18 my $imr = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
19 my $act = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $ti = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $srv = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
22 my $cli = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $DEBUG_LEVEL = 2;
25 my $OBJ_REF_STYLE = "-ORBObjRefStyle url";
27 my $implrepo_server =
28 "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator";
29 my $imr_activator = "$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_activator";
30 my $tao_imr = "$ENV{ACE_ROOT}/bin/tao_imr";
32 my $imriorfile = "imr.ior";
33 my $actiorfile = "activator.ior";
34 my $srviorfile = "messenger.ior";
36 my $imr_imriorfile = $imr->LocalFile ($imriorfile);
37 my $act_imriorfile = $act->LocalFile ($imriorfile);
38 my $ti_imriorfile = $ti->LocalFile ($imriorfile);
39 my $srv_imriorfile = $srv->LocalFile ($imriorfile);
40 my $act_actiorfile = $act->LocalFile ($actiorfile);
41 my $srv_srviorfile = $srv->LocalFile ($srviorfile);
42 my $cli_srviorfile = $cli->LocalFile ($srviorfile);
45 $IMR = $imr->CreateProcess ($implrepo_server, "-d $DEBUG_LEVEL ".
46 "$OBJ_REF_STYLE ".
47 "-t 30 ".
48 "-v 100 ".
49 "-o $imr_imriorfile");
50 $ACT = $act->CreateProcess ($imr_activator, "-d $DEBUG_LEVEL ".
51 "$OBJ_REF_STYLE ".
52 "-o $act_actiorfile ".
53 "-ORBInitRef ImplRepoService=file://$act_imriorfile");
54 $TI = $ti->CreateProcess ("$tao_imr");
55 $SRV = $srv->CreateProcess ("MessengerServer", "-orbuseimr 1 ".
56 "$OBJ_REF_STYLE ".
57 "-o $srv_srviorfile ".
58 "-ORBInitRef ImplRepoService=file://$srv_imriorfile");
59 $CLI = $cli->CreateProcess ("MessengerClient");
61 my $server_cmd = $SRV->Executable();
62 my $srv_server_cmd = $imr->LocalFile ($server_cmd);
64 sub CleanupOutput {
65 $imr->DeleteFile ($imriorfile);
66 $act->DeleteFile ($imriorfile);
67 $ti->DeleteFile ($imriorfile);
68 $srv->DeleteFile ($imriorfile);
69 $act->DeleteFile ($actiorfile);
70 $srv->DeleteFile ($srviorfile);
71 $cli->DeleteFile ($srviorfile);
74 sub SpawnWait {
75 my $process = shift;
76 my $file = shift;
77 my $target = shift;
78 my $timeout = shift;
80 if (!defined $timeout) {
81 $timeout = $target->ProcessStartWaitInterval();
84 print ">>> " . $process->CommandLine () . "\n\ttimeout = $timeout\n";
85 my $status = $process->Spawn ();
86 if ($status != 0) {
87 print STDERR "ERROR: Process returned $status\n";
88 return 1;
90 my $ret = $target->WaitForFileTimed ($file,$timeout);
91 if ($ret == -1) {
92 print STDERR "ERROR: Cannot find file <$file>\n";
94 return $ret;
97 # We want the tao_imr executable to be found exactly in the path
98 # given, without being modified by the value of -ExeSubDir.
99 # So, we tell its Process object to ignore the setting of -ExeSubDir.
100 $TI->IgnoreExeSubDir(1);
102 sub RunImRUtil {
103 my $cmd = shift;
105 print ">>> " . $TI->CommandLine() . "\n";
106 $TI->Arguments("-ORBInitRef ImplRepoService=file://$ti_imriorfile $cmd");
107 return $TI->SpawnWaitKill($ti->ProcessStartWaitInterval());
110 CleanupOutput();
112 if (SpawnWait($IMR, $imriorfile, $imr) != 0) {
113 $ImR->Kill (); $ImR->TimedWait (1);
114 exit 1;
116 if ($imr->GetFile ($imriorfile) == -1) {
117 print STDERR "ERROR: cannot retrieve file <$imr_imriorfile>\n";
118 $IMR->Kill (); $IMR->TimedWait (1);
119 exit 1;
121 if ($ti->PutFile ($imriorfile) == -1) {
122 print STDERR "ERROR: cannot set file <$ti_imriorfile>\n";
123 $IMR->Kill (); $IMR->TimedWait (1);
124 exit 1;
126 if ($act->PutFile ($imriorfile) == -1) {
127 print STDERR "ERROR: cannot set file <$act_imriorfile>\n";
128 $IMR->Kill (); $IMR->TimedWait (1);
129 exit 1;
131 if ($srv->PutFile ($imriorfile) == -1) {
132 print STDERR "ERROR: cannot set file <$srv_imriorfile>\n";
133 $IMR->Kill (); $IMR->TimedWait (1);
134 exit 1;
137 if (SpawnWait($ACT, $actiorfile, $act) != 0) {
138 $ACT->Kill (); $ACT->TimedWait (1);
139 $IMR->Kill (); $IMR->TimedWait (1);
140 exit 1;
143 my $actname = $act->HostName ();
144 RunImRUtil("add MessengerService -a per_client -r 1 -l $actname -c \""
145 . "$srv_server_cmd $OBJ_REF_STYLE "
146 . "-ORBEndpoint iiop://:8923/portspan=3\"");
147 RunImRUtil("list -v");
149 #start the server manually twice
151 if (SpawnWait($SRV, $srviorfile, $srv, 30) != 0) {
152 $SRV->Kill (); $SRV->TimedWait (1);
153 $ACT->Kill (); $ACT->TimedWait (1);
154 $IMR->Kill (); $IMR->TimedWait (1);
155 exit 1;
158 $SRV->Kill (); $SRV->TimedWait (1);
159 $srv->DeleteFile ($srviorfile);
161 if (SpawnWait($SRV, $srviorfile, $srv, 30) != 0) {
162 $SRV->Kill (); $SRV->TimedWait (1);
163 $ACT->Kill (); $ACT->TimedWait (1);
164 $IMR->Kill (); $IMR->TimedWait (1);
165 exit 1;
167 $SRV->Kill (); $SRV->TimedWait (1);
168 if ($srv->GetFile ($srviorfile) == -1) {
169 print STDERR "ERROR: cannot retrieve file <$srv_srviorfile>\n";
170 exit 1;
172 if ($cli->PutFile ($srviorfile) == -1) {
173 print STDERR "ERROR: cannot set file <$cli_srviorfile>\n";
174 exit 1;
177 $CLI_status = $CLI->SpawnWaitKill ($cli->ProcessStartWaitInterval()+985);
178 if ($CLI_status != 0) {
179 print STDERR "Error : Client failed to run correctly with error $CLI_status.";
180 $status = 1;
183 $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval());
184 if ($ACT_status != 0) {
185 print STDERR "ERROR: Activator returned $ACT_status\n";
186 $status = 1;
189 $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval());
190 if ($IMR_status != 0) {
191 print STDERR "ERROR: ImplRepo Service returned $IMR_status\n";
192 $status = 1;
195 CleanupOutput();
197 exit $status;