Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / AMH / Sink_Server / run_test.pl
blob334f690d2fc5458d58e0ccda214597ffb6a48d0a
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 # Amount of delay (in microseconds) that the sink-server delays a client reply.
14 $delay_time = 11000;
16 # Number of calls a client makes to the AMH server
17 $iterations = 100;
19 $conf = $PerlACE::svcconf_ext;
21 foreach $i (@ARGV) {
22 if ($i eq '-debug') {
23 $debug_level = '10';
27 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
28 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
31 # File used to pass AMH server ior to its clients.
32 my $iorbase = "amh.ior";
33 my $server_iorfile = $server->LocalFile ($iorbase);
34 my $client_iorfile = $client->LocalFile ($iorbase);
35 $server->DeleteFile($iorbase);
36 $client->DeleteFile($iorbase);
38 my $server_conf = $server->LocalFile ("st_server" . $conf);
40 $SV = $server->CreateProcess ("st_server",
41 "-ORBdebuglevel $debug_level " .
42 "-ORBsvcconf $server_conf " .
43 "-o $server_iorfile " .
44 "-s $delay_time");
46 $CL = $client->CreateProcess ("client",
47 "-k file://$client_iorfile " .
48 "-n $iterations");
51 print STDERR "\n Starting AMH Sink Server with $delay_time microseconds delayed response: \n\n";
53 $server_status = $SV->Spawn ();
55 if ($server_status != 0) {
56 print STDERR "ERROR: server returned $server_status\n";
57 exit 1;
60 if ($server->WaitForFileTimed ($iorbase,
61 $server->ProcessStartWaitInterval()) == -1) {
62 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
63 $SV->Kill (); $SV->TimedWait (1);
64 exit 1;
67 if ($server->GetFile ($iorbase) == -1) {
68 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
69 $SV->Kill (); $SV->TimedWait (1);
70 exit 1;
72 if ($client->PutFile ($iorbase) == -1) {
73 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
74 $SV->Kill (); $SV->TimedWait (1);
75 exit 1;
78 # Run client.
79 print STDERR "\n Client making $iterations calls to server: \n";
80 $evt_per_sec = 1000/$delay_time/1000;
81 print STDERR "\n(Expect less than $evt_per_sec Events/sec) \n\n";
83 $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 60);
85 if ($client_status != 0) {
86 print STDERR "ERROR: client returned $client_status\n";
87 $status = 1;
90 $server_status = $SV->TerminateWaitKill ($server->ProcessStopWaitInterval());
92 if ($server_status != 0) {
93 print STDERR "ERROR: server returned $server_status\n";
94 $status = 1;
97 $server->DeleteFile($iorbase);
98 $client->DeleteFile($iorbase);
100 exit $status;