Merge pull request #2306 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / Security / PolicyControllingApp / run_test.pl
blobae944a224e68f07cee9e6e66b8fe1d2c04434e68
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 $srv1 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $cli1 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 $srviorfile = "Messenger.ior";
24 $srvconf = "server.conf";
25 $srv1conf = "server1.conf";
26 $cliconf = "client.conf";
27 $cli1conf = "client1.conf";
29 my $srv_srviorfile = $srv->LocalFile ($srviorfile);
30 my $cli_srviorfile = $cli->LocalFile ($srviorfile);
31 my $srv1_srviorfile = $srv1->LocalFile ($srviorfile);
32 my $cli1_srviorfile = $cli1->LocalFile ($srviorfile);
33 my $srv_srvconf = $srv->LocalFile ($srvconf);
34 my $srv_srv1conf = $srv->LocalFile ($srv1conf);
35 my $cli_cliconf = $srv->LocalFile ($cliconf);
36 my $cli_cli1conf = $srv->LocalFile ($cli1conf);
37 $srv->DeleteFile ($srviorfile);
38 $cli->DeleteFile ($srviorfile);
39 $srv1->DeleteFile ($srviorfile);
40 $cli1->DeleteFile ($srviorfile);
42 $ENV{'SSL_CERT_FILE'} = 'cacert.pem';
44 $SRV = $srv->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
45 "-o $srv_srviorfile ".
46 "-ORBSvcConf $srv_srvconf");
47 $SRV1 = $srv1->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level ".
48 "-o $srv1_srviorfile ".
49 "-ORBSvcConf $srv_srv1conf");
50 $CLI = $cli->CreateProcess ("MessengerClient", "-e 1 ".
51 "-k file://$cli_srviorfile ".
52 "-ORBSvcConf $cli_cliconf");
53 $CLI1 = $cli1->CreateProcess ("MessengerClient", "-e 2 ".
54 "-k file://$cli1_srviorfile ".
55 "-ORBSvcConf $cli_cli1conf");
58 # start MessengerServer
59 print STDERR "\n\nSecurity Policy Controlling Application Examples\n";
60 print STDERR "------------------------------------------------\n";
62 print STDERR "Starting Messenger Server, example 1...\n\n";
63 $SRV_status = $SRV->Spawn ();
65 if ($SRV_status != 0) {
66 print STDERR "ERROR: Server returned $SRV_status\n";
67 exit 1;
70 if ($srv->WaitForFileTimed ($srviorfile,$srv->ProcessStartWaitInterval()) == -1) {
71 print STDERR "ERROR: cannot find file <$srv_srviorfile>\n";
72 $SRV->Kill (); $SRV->TimedWait (1);
73 exit 1;
76 if ($srv->GetFile ($srviorfile) == -1) {
77 print STDERR "ERROR: cannot retrieve file <$srv_srviorfile>\n";
78 $SRV->Kill (); $SRV->TimedWait (1);
79 exit 1;
81 if ($cli->PutFile ($srviorfile) == -1) {
82 print STDERR "ERROR: cannot set file <$cli_srviorfile>\n";
83 $SRV->Kill (); $SRV->TimedWait (1);
84 exit 1;
87 print STDERR "\nStarting MessengerClient, example 1...\n\n";
88 $CLI_status = $CLI->SpawnWaitKill ($cli->ProcessStartWaitInterval());
90 if ($CLI_status != 0) {
91 print STDERR "ERROR: Messenger Client returned $CLI_status\n";
92 $SRV->Kill (); $SRV->TimedWait (1);
93 exit 1;
96 $SRV_status = $SRV->TerminateWaitKill ($srv->ProcessStopWaitInterval());
98 if ($SRV_status != 0) {
99 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
100 exit 1;
103 $srv->DeleteFile ($srviorfile);
104 $cli->DeleteFile ($srviorfile);
107 print STDERR "\nStarting Messenger Server, example 2...\n\n";
108 $SRV_status = $SRV1->Spawn ();
110 if ($SRV_status != 0) {
111 print STDERR "ERROR: Server returned $SRV_status\n";
112 exit 1;
115 if ($srv1->WaitForFileTimed ($srviorfile,$srv1->ProcessStartWaitInterval()) == -1) {
116 print STDERR "ERROR: cannot find file <$srv1_srviorfile>\n";
117 $SRV1->Kill (); $SRV1->TimedWait (1);
118 exit 1;
121 if ($srv1->GetFile ($srviorfile) == -1) {
122 print STDERR "ERROR: cannot retrieve file <$srv1_srviorfile>\n";
123 $SRV1->Kill (); $SRV1->TimedWait (1);
124 exit 1;
126 if ($cli1->PutFile ($srviorfile) == -1) {
127 print STDERR "ERROR: cannot set file <$cli1_srviorfile>\n";
128 $SRV1->Kill (); $SRV1->TimedWait (1);
129 exit 1;
132 print STDERR "\nStarting MessengerClient, example 2...\n\n";
133 $CLI_status = $CLI1->SpawnWaitKill ($cli1->ProcessStartWaitInterval());
135 if ($CLI_status != 0) {
136 print STDERR "ERROR: Messenger Client returned $CLI_status\n";
137 $SRV1->Kill (); $SRV1->TimedWait (1);
138 $status = 1;
141 $SRV_status = $SRV1->TerminateWaitKill ($srv1->ProcessStopWaitInterval());
143 if ($SRV_status != 0) {
144 print STDERR "ERROR: Messenger Server returned $SRV_status\n";
145 $status = 1;
148 $srv1->DeleteFile ($srviorfile);
149 $cli1->DeleteFile ($srviorfile);
151 exit $status;