Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / examples / Simple / time-date / run_test.pl
blob83e39f2e7ba459a2bca0f7fd226a80e6cdcf4421
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 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
22 my $iorbase = "ior"; # please note that conf file is defined in *.conf file
23 my $client_conffile = $client->LocalFile ("client"."$PerlACE::svcconf_ext");
24 my $server_iorfile = $server->LocalFile ($iorbase);
25 my $client_iorfile = $client->LocalFile ($iorbase);
26 $server->DeleteFile($iorbase);
27 $client->DeleteFile($iorbase);
29 # Generate svc.conf file for server
30 my $server_conf = "svc.conf";
31 $server->LocalFile ($server_conf);
33 die "Error: Cannot create svc.conf file" if not open(FH, ">$server_conf");
34 print FH "# Define a special Reactor for single-threaded configurations. " .
35 " Refer to README for details. \n";
36 print FH "dynamic Resource_Factory Service_Object * Time_Date:_make_My_Resource_Factory()\n";
37 print FH "# Dynamically configure the ORB into the application process.\n";
38 print FH "dynamic ORB Service_Object * Time_Date:_make_DLL_ORB() \"dummy\"\n";
39 print FH "# Once the ORB is configured, dynamically configure the Time_Date service.\n";
40 print FH "dynamic Time_Date_Servant Service_Object * Time_Date:_make_Time_Date_Servant() " .
41 "\"dummy -n ORB -o $server_iorfile\"\n";
42 close(FH);
44 if ($server->PutFile ($server_conf) == -1) {
45 print STDERR "ERROR: cannot set file <$server_conf\n";
46 exit 1;
49 $SV = $server->CreateProcess ("server", "");
50 $CL = $client->CreateProcess ("client", "-f $client_iorfile -x -ORBSvcConf $client_conffile");
51 $server_status = $SV->Spawn ();
53 if ($server_status != 0) {
54 print STDERR "ERROR: server returned $server_status\n";
55 exit 1;
58 if ($server->WaitForFileTimed ($iorbase,
59 $server->ProcessStartWaitInterval()) == -1) {
60 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
61 $SV->Kill (); $SV->TimedWait (1);
62 exit 1;
65 if ($server->GetFile ($iorbase) == -1) {
66 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
67 $SV->Kill (); $SV->TimedWait (1);
68 exit 1;
71 if ($client->PutFile ($iorbase) == -1) {
72 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
73 $SV->Kill (); $SV->TimedWait (1);
74 exit 1;
77 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 45);
79 if ($client_status != 0) {
80 print STDERR "ERROR: client returned $client_status\n";
81 $status = 1;
84 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
86 if ($server_status != 0) {
87 print STDERR "ERROR: server returned $server_status\n";
88 $status = 1;
91 $server->DeleteFile ($server_conf);
92 $server->DeleteFile($iorbase);
93 $client->DeleteFile($iorbase);
95 exit $status;