summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Simple_Naming/run_test.pl
blob: 3502343dc7b83a894897469c7cb45dffd5aaa074 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

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

# This is a Perl script that runs the client and all the other servers that
# are needed

unshift @INC, '../../../../bin';
require Process;
require ACEutils;
require Uniqueid;

# amount of delay between running the servers

$sleeptime = 8;

# variables for parameters

$nsmport = 10000 + uniqueid ();
$iorfile = "ns.ior";

sub name_server
{
  my $args = "-ORBnameserviceport $nsmport -o $iorfile";
  my $prog = "..$DIR_SEPARATOR..$DIR_SEPARATOR".
    "Naming_Service".$DIR_SEPARATOR.
      "Naming_Service".$EXE_EXT;

  unlink $iorfile;
  $NS = Process::Create ($prog, $args);

  if (ACE::waitforfile_timed ($iorfile, $sleeptime) == -1) {
    print STDERR "ERROR: cannot find IOR file <$iorfile>\n";
    $NS->Kill (); $NS->TimedWait (1);
    exit 1;
  }
}

sub client
{
  my $args = $_[0]." "."-ORBnameserviceport $nsmport ".
    "-ORBnameserviceior file://$iorfile";
  my $prog = $EXEPREFIX."client".$EXE_EXT;

  $CL = Process::Create ($prog, $args);
}

# Options for all tests recognized by the 'client' program.
@opts = ("-s", "-t", "-i", "-e", "-y");

@comments = ("Simple Test: \n",
             "Tree Test: \n",
             "Iterator Test: \n",
             "Exceptions Test: \n",
             "Destroy Test: \n");

$test_number = 0;

# Run server and client with each option available to the client.
foreach $o (@opts)
{
  name_server ();

  print STDERR "\n";
  print STDERR "          ".$comments[$test_number];

  client ($o);
  $client = $CL->TimedWait (60);
  if ($client == -1) {
    print STDERR "ERROR: client timedout\n";
    $CL->Kill (); $CL->TimedWait (1);
  }


  $NS->Terminate (); $server = $NS->TimedWait (5);
  if ($server == -1) {
    print STDERR "ERROR: server timedout\n";
    $NS->Kill (); $NS->TimedWait (1);
  }
  $test_number++;
}

print STDERR "\n";

print STDERR "          Multithreaded Test:\n";

# Now run the multithreaded test, sending output to the file.
open (OLDOUT, ">&STDOUT");
open (STDOUT, ">test_run.data") or die "can't redirect stdout: $!";
open (OLDERR, ">&STDERR");
open (STDERR, ">&STDOUT") or die "can't redirect stderror: $!";

name_server ();

client ("-m25");

$client = $CL->TimedWait (60);
if ($client == -1) {
  print STDERR "ERROR: client timedout\n";
  $CL->Kill (); $CL->TimedWait (1);
}

close (STDERR);
close (STDOUT);
open (STDOUT, ">&OLDOUT");
open (STDERR, ">&OLDERR");

$NS->Terminate (); $server = $NS->TimedWait (5);
if ($server == -1) {
  print STDERR "ERROR: server timedout\n";
  $NS->Kill (); $NS->TimedWait (1);
}

unlink $iorfile;

$FL = Process::Create ($EXEPREFIX."process-m-output.pl",
                       " test_run.data 25");
$filter = $FL->TimedWait (60);
if ($filter == -1) {
  print STDERR "ERROR: filter timedout\n";
  $FL->Kill (); $FL->TimedWait (1);
}
print STDERR "\n";

# @@ Capture any exit status from the processes.
exit 0;