summaryrefslogtreecommitdiff
path: root/TAO/tests/Portable_Interceptors/Processing_Mode_Policy/Remote/run_test.pl
blob: b04af3c2968ce59356b6e905c8d07b19a19adc39 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

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

use lib '../../../../../bin';
use PerlACE::Run_Test;

sub get_test_modes
{
  my $testid = shift;

  my $client_mode = "LOCAL_AND_REMOTE";
  my $server_mode = "LOCAL_AND_REMOTE";

  # There are Nine Permutations.
  if ($testid == 1)
  {
    $client_mode = "LOCAL_AND_REMOTE";
    $server_mode = "LOCAL_AND_REMOTE";
  }
  elsif ($testid == 2)
  {
    $client_mode = "LOCAL_AND_REMOTE";
    $server_mode = "LOCAL_ONLY";
  }
  elsif ($testid == 3)
  {
    $client_mode = "LOCAL_AND_REMOTE";
    $server_mode = "REMOTE_ONLY";
  }
  elsif ($testid == 4)
  {
    $client_mode = "LOCAL_ONLY";
    $server_mode = "LOCAL_AND_REMOTE";
  }
  elsif ($testid == 5)
  {
    $client_mode = "LOCAL_ONLY";
    $server_mode = "LOCAL_ONLY";
  }
  elsif ($testid == 6)
  {
    $client_mode = "LOCAL_ONLY";
    $server_mode = "REMOTE_ONLY";
  }
  elsif ($testid == 7)
  {
    $client_mode = "REMOTE_ONLY";
    $server_mode = "LOCAL_AND_REMOTE";
  }
  elsif ($testid == 8)
  {
    $client_mode = "REMOTE_ONLY";
    $server_mode = "LOCAL_ONLY";
  }
  elsif ($testid == 9)
  {
    $client_mode = "REMOTE_ONLY";
    $server_mode = "REMOTE_ONLY";
  }
  else
  {
    print STDERR "ERROR: invalid testid: $testid\n";
    exit 1;
  }

  return ($client_mode, $server_mode);
}

my $status = 0;
my $file = PerlACE::LocalFile ("test.ior");

my $testid;

for ($testid = 1; $testid <= 9; ++$testid)
{
  unlink $file;

  my $client_mode;
  my $server_mode;

  ($client_mode, $server_mode) = get_test_modes($testid);

  my $SV;
  if (PerlACE::is_vxworks_test()) {
    $SV = new PerlACE::ProcessVX ("PI_ProcMode_Remote_TestServer",
                                  "-p $server_mode " .
                                  "-ORBobjrefstyle url");
  }
  else {
    $SV = new PerlACE::Process ("PI_ProcMode_Remote_TestServer",
                                "-p $server_mode " .
                                "-ORBobjrefstyle url");
  }

  print STDERR "\n\n==== Starting test variant #$testid\n\n";

  $server = $SV->Spawn ();

  if ($server != 0) {
      print STDERR "ERROR: server returned $server\n";
      exit 1;
  }

  if (PerlACE::waitforfile_timed ($file, 15) == -1) {
      print STDERR "ERROR: cannot find file <$file>\n";
      $SV->Kill ();
      exit 1;
  }

  my $CLIENT;
  $CLIENT = new PerlACE::Process ("PI_ProcMode_Remote_TestClient",
                                  "-p $client_mode " .
                                  "-ORBobjrefstyle url");

  my $client_status = $CLIENT->SpawnWaitKill (5);

  if ($client_status != 0) {
      print STDERR "ERROR: PI_ProcMode_TestClient returned $client_status\n";
      print STDERR "ERROR: For client-side mode [$client_mode],\n";
      print STDERR "ERROR: and server-side mode [$server_mode].\n";
      $status = 1;
  }

  my $server_status = $SV->WaitKill (5);

  if ($server_status != 0) {
      print STDERR "ERROR: PI_ProcMode_TestServer returned $server_status\n";
      print STDERR "ERROR: For client-side mode [$client_mode],\n";
      print STDERR "ERROR: and server-side mode [$server_mode].\n";
      $status = 1;
  }

  if (($server_status == 0) && ($client_status == 0)) {
      print STDERR "\n==== Test variant #$testid (of 9) passed!\n";
  }
  else {
      print STDERR "\n==== Test variant #$testid (of 9) failed!\n";
  }
}

unlink $file;

if ($status == 0) {
    print STDERR "\n==== All 9 test variants were successful!\n";
}
else {
    print STDERR "\n==== One or more of the 9 test variants failed!\n";
}

exit $status;