summaryrefslogtreecommitdiff
path: root/trunk/TAO/examples/Advanced/ch_18/run_test.pl
blob: 6ccc991c9b432a755800ee07461edb7142f7f4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# -*- perl -*-

use lib "$ENV{ACE_ROOT}/bin";

require ACEutils;
require Process;

$status = 0;

# amount of delay between starting servers and client
$sleeptime = 5;



sub name_server
{
  my $prog = "..$DIR_SEPARATOR".
             "..$DIR_SEPARATOR".
             "..$DIR_SEPARATOR".
             "orbsvcs$DIR_SEPARATOR".
             "Naming_Service$DIR_SEPARATOR".
             "Naming_Service$EXE_EXT";
  $NS = Process::Create ($prog,"");
}



# create naming service, server, client
name_server ();
sleep $sleeptime;

$server = Process::Create ($EXEPREFIX."server".$EXE_EXT, "");
sleep $sleeptime;

$client = Process::Create($EXEPREFIX."client".$EXE_EXT, "");



# wait for client to finish
if ($client->TimedWait (60) == -1) {
  print STDERR "ERROR: client timedout\n";
  $status = 1;
  $client->Kill (); $client->TimedWait (1);
}


# gracefully kill the server
$server->Terminate (); 
if ($server->TimedWait (5) == -1) {
  print STDERR "ERROR: cannot terminate the server\n";
  $server->Kill (); $server->TimedWait (1);
  $status = 1;
}

# gracefully kill the Naming Service
$NS->Terminate (); 
if ($NS->TimedWait (5) == -1) {
  print STDERR "ERROR: cannot terminate the server\n";
  $NS->Kill (); $server->TimedWait (1);
  $status = 1;
}

exit $status;