Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / Security / SecurityUnawareApp / run_test.pl
blob82696ad67e59125288bb33aaeccaf6138e794781
2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
4 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 $srv = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
19 my $cli = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $cli1 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $cli2 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 $srviorfile = "Messenger.ior";
24 $srvconf = "server.conf";
25 $cliconf = "client.conf";
26 $cli1conf = "client1.conf";
28 my $srv_srviorfile = $srv->LocalFile ($srviorfile);
29 my $cli_srviorfile = $cli->LocalFile ($srviorfile);
30 my $cli1_srviorfile = $cli1->LocalFile ($srviorfile);
31 my $cli2_srviorfile = $cli2->LocalFile ($srviorfile);
32 my $srv_srvconf = $srv->LocalFile ($srvconf);
33 my $cli_cliconf = $srv->LocalFile ($cliconf);
34 my $cli_cli1conf = $srv->LocalFile ($cli1conf);
35 $srv->DeleteFile ($srviorfile);
36 $cli->DeleteFile ($srviorfile);
37 $cli1->DeleteFile ($srviorfile);
38 $cli2->DeleteFile ($srviorfile);
40 $ENV{'SSL_CERT_FILE'} = 'cacert.pem';
42 $SRV = $srv->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
43 "-o $srv_srviorfile ".
44 "-ORBSvcConf $srv_srvconf");
45 $CLI = $cli->CreateProcess ("MessengerClient", "-k file://$cli_srviorfile ");
46 $CLI1 = $cli1->CreateProcess ("MessengerClient", "-k file://$cli_srviorfile ".
47 "-ORBSvcConf $cli_cliconf");
48 $CLI2 = $cli2->CreateProcess ("MessengerClient", "-k file://$cli1_srviorfile ".
49 "-ORBSvcConf $cli_cli1conf");
51 # start MessengerServer
52 print STDERR "\n\nSecurity Unaware Application Examples\n";
53 print STDERR "-------------------------------------\n";
54 print STDERR "Starting Messenger Server...\n\n";
56 $SRV_status = $SRV->Spawn ();
58 if ($SRV_status != 0) {
59 print STDERR "ERROR: Server returned $SRV_status\n";
60 exit 1;
63 if ($srv->WaitForFileTimed ($srviorfile,$srv->ProcessStartWaitInterval()) == -1) {
64 print STDERR "ERROR: cannot find file <$srv_srviorfile>\n";
65 $SRV->Kill (); $SRV->TimedWait (1);
66 exit 1;
69 if ($srv->GetFile ($srviorfile) == -1) {
70 print STDERR "ERROR: cannot retrieve file <$srv_srviorfile>\n";
71 $SRV->Kill (); $SRV->TimedWait (1);
72 exit 1;
74 if ($cli->PutFile ($srviorfile) == -1) {
75 print STDERR "ERROR: cannot set file <$cli_srviorfile>\n";
76 $SRV->Kill (); $SRV->TimedWait (1);
77 exit 1;
79 if ($cli1->PutFile ($srviorfile) == -1) {
80 print STDERR "ERROR: cannot set file <$cli1_srviorfile>\n";
81 $SRV->Kill (); $SRV->TimedWait (1);
82 exit 1;
84 if ($cli2->PutFile ($srviorfile) == -1) {
85 print STDERR "ERROR: cannot set file <$cli2_srviorfile>\n";
86 $SRV->Kill (); $SRV->TimedWait (1);
87 exit 1;
90 # start MessengerClient
92 print STDERR "\nStarting MessengerClient, example 1...\n\n";
93 $CLI_status = $CLI->SpawnWaitKill ($cli->ProcessStartWaitInterval());
95 if ($CLI_status == 0) {
96 print STDERR "ERROR: Messenger Client returned $CLI_status\n";
97 $SRV->Kill (); $SRV->TimedWait (1);
98 $status = 1;
101 print STDERR "\nStarting MessengerClient, example 2...\n\n";
102 $CLI1_status = $CLI1->SpawnWaitKill ($cli1->ProcessStartWaitInterval());
104 if ($CLI1_status != 0) {
105 print STDERR "ERROR: Messenger Client1 returned $CLI1_status\n";
106 $SRV->Kill (); $SRV->TimedWait (1);
107 $status = 1;
110 $ENV{'SSL_CERT_FILE'} = '';
112 print STDERR "\nStarting MessengerClient, example 3...\n\n";
113 $CLI2_status = $CLI2->SpawnWaitKill ($cli2->ProcessStartWaitInterval());
115 if ($CLI2_status != 0) {
116 print STDERR "ERROR: Messenger Client2 returned $CLI2_status\n";
117 $SRV->Kill (); $SRV->TimedWait (1);
118 $status = 1;
121 # clean-up
122 $SRV_status = $SRV->TerminateWaitKill ($srv->ProcessStopWaitInterval());
124 if ($SRV_status != 0) {
125 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
126 exit 1;
129 $srv->DeleteFile ($srviorfile);
130 $cli->DeleteFile ($srviorfile);
131 $cli1->DeleteFile ($srviorfile);
132 $cli2->DeleteFile ($srviorfile);
134 exit $status;