1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 ###############################################################################
8 use lib
"$ENV{ACE_ROOT}/bin";
9 use PerlACE
::TestTarget
;
16 for (my $i = 0; $i <= $#ARGV; $i++) {
17 if ($ARGV[$i] eq '-debug') {
18 $imr_debug = "-d 10 -ORBDebugLevel 10 -ORBVerboseLogging 1 -ORBLogFile imr_loc.log";
19 $act_debug = "-d 10 -ORBDebugLevel 10 -ORBVerboseLogging 1 -ORBLogFile imr_act.log";
29 #$ENV{ACE_TEST_VERBOSE} = "1";
32 my $imr = PerlACE
::TestTarget
::create_target
(++$tgt_num) || die "Create target $tgt_num failed\n";
33 my $act = PerlACE
::TestTarget
::create_target
(++$tgt_num) || die "Create target $tgt_num failed\n";
34 my $ti = PerlACE
::TestTarget
::create_target
(++$tgt_num) || die "Create target $tgt_num failed\n";
35 my $srv = PerlACE
::TestTarget
::create_target
(++$tgt_num) || die "Create target $tgt_num failed\n";
37 my $refstyle = " -ORBobjrefstyle URL";
41 my $objprefix = "TestObject_0";
42 my $client_wait_time = 10;
44 $imriorfile = "imr_locator.ior";
45 $actiorfile = "imr_activator.ior";
46 $persistxml = "persist.xml";
47 $persistdat = "persist.dat";
49 my $imr_imriorfile = $imr->LocalFile ($imriorfile);
50 my $act_imriorfile = $act->LocalFile ($imriorfile);
51 my $ti_imriorfile = $ti->LocalFile ($imriorfile);
52 my $act_actiorfile = $act->LocalFile ($actiorfile);
53 my $imr_persistxml = $imr->LocalFile ($persistxml);
54 my $imr_persistdat = $imr->LocalFile ($persistdat);
56 $IMR = $imr->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator");
57 $ACT = $act->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_activator");
58 $TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr");
60 # Make sure the files are gone, so we can wait on them.
61 $imr->DeleteFile ($imriorfile);
62 $act->DeleteFile ($imriorfile);
63 $ti->DeleteFile ($imriorfile);
64 $act->DeleteFile ($actiorfile);
65 $imr->DeleteFile ($persistxml);
66 $imr->DeleteFile ($persistdat);
68 my $stdout_file = "test.out";
69 my $stderr_file = "test.err";
70 my $ti_stdout_file = $ti->LocalFile ($stdout_file);
71 my $ti_stderr_file = $ti->LocalFile ($stderr_file);
73 # Clean up after exit call
76 $imr->DeleteFile ($imriorfile);
77 $act->DeleteFile ($imriorfile);
78 $ti->DeleteFile ($imriorfile);
79 $act->DeleteFile ($actiorfile);
80 $imr->DeleteFile ($persistxml);
81 $imr->DeleteFile ($persistdat);
83 $ti->DeleteFile ($stdout_file);
84 $ti->DeleteFile ($stderr_file);
86 # Remove any stray server status files caused by aborting services
92 open(OLDOUT
, ">&", \
*STDOUT
) or die "Can't dup STDOUT: $!";
93 open(OLDERR
, ">&", \
*STDERR
) or die "Can't dup STDERR: $!";
94 open STDERR
, '>', $ti_stderr_file;
95 open STDOUT
, '>', $ti_stdout_file;
100 open(STDERR
, ">&OLDERR") or die "Can't dup OLDERR: $!";
101 open(STDOUT
, ">&OLDOUT") or die "Can't dup OLDOUT: $!";
106 print "initializing activator\n";
108 $ACT->Arguments ("-l -o $act_actiorfile -ORBInitRef ImplRepoService=file://$act_imriorfile $act_debug");
110 $ACT_status = $ACT->Spawn ();
111 if ($ACT_status != 0) {
112 print STDERR
"ERROR: ImR Activator returned $ACT_status\n";
115 if ($act->WaitForFileTimed ($actiorfile,$act->ProcessStartWaitInterval()) == -1) {
116 print STDERR
"ERROR: cannot find file <$act_imriorfile>\n";
117 $ACT->Kill (); $ACT->TimedWait (1);
118 $IMR->Kill (); $IMR->TimedWait (1);
122 my $SRV = $srv->CreateProcess ("server");
123 my $server_cmd = $SRV->Executable();
124 my $srv_server_cmd = $imr->LocalFile ($server_cmd);
126 ##### Add servers to activator #####
127 print "adding server\n";
128 my $status_file_name = $objprefix . ".status";
130 $act->DeleteFile ($status_file_name);
131 $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ".
132 "add $objprefix -c \"$srv_server_cmd -ORBUseIMR 1 ".
133 "-ORBInitRef ImplRepoService=file://$imr_imriorfile\"");
135 $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());
136 if ($TI_status != 0) {
137 print STDERR
"ERROR: tao_imr returned $TI_status\n";
138 $ACT->Kill (); $ACT->TimedWait (1);
139 $IMR->Kill (); $IMR->TimedWait (1);
143 $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ".
146 $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval());
147 if ($TI_status != 0 && $TI_status != 4) {
148 print STDERR
"ERROR: tao_imr returned $TI_status\n";
149 $ACT->Kill (); $ACT->TimedWait (1);
150 $IMR->Kill (); $IMR->TimedWait (1);
156 sub interrupt_ping_test
158 print "Running interrupt ping test.\n";
161 my $start_time = time();
163 $IMR->Arguments ("-i $imr_debug -o $imr_imriorfile -orbendpoint iiop://:$port");
165 ##### Start ImplRepo #####
166 $IMR_status = $IMR->Spawn ();
167 if ($IMR_status != 0) {
168 print STDERR
"ERROR: ImplRepo Service returned $IMR_status\n";
171 if ($imr->WaitForFileTimed ($imriorfile, $imr->ProcessStartWaitInterval()) == -1) {
172 print STDERR
"ERROR: cannot find file <$imr_imriorfile>\n";
173 $IMR->Kill (); $IMR->TimedWait (1);
176 if ($imr->GetFile ($imriorfile) == -1) {
177 print STDERR
"ERROR: cannot retrieve file <$imr_imriorfile>\n";
178 $IMR->Kill (); $IMR->TimedWait (1);
181 if ($act->PutFile ($imriorfile) == -1) {
182 print STDERR
"ERROR: cannot set file <$act_imriorfile>\n";
183 $IMR->Kill (); $IMR->TimedWait (1);
186 if ($ti->PutFile ($imriorfile) == -1) {
187 print STDERR
"ERROR: cannot set file <$ti_imriorfile>\n";
188 $IMR->Kill (); $IMR->TimedWait (1);
191 if ($srv->PutFile ($imriorfile) == -1) {
192 print STDERR
"ERROR: cannot set file <$srv_imriorfile>\n";
193 $IMR->Kill (); $IMR->TimedWait (1);
201 my $ACT_status = $ACT->TerminateWaitKill ($act->ProcessStopWaitInterval());
202 if ($ACT_status != 0) {
203 print STDERR
"ERROR: IMR Activator returned $ACT_status\n";
207 my $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval());
208 if ($IMR_status != 0) {
209 print STDERR
"ERROR: IMR returned $IMR_status\n";
213 my $test_time = time() - $start_time;
215 print "\nFinished. The test took $test_time seconds.\n";
221 print "Usage: run_test.pl [-debug]\n";
224 ###############################################################################
225 ###############################################################################
227 my $ret = interrupt_ping_test
();