summaryrefslogtreecommitdiff
path: root/TAO/tests/Param_Test/run_test.pl
blob: 956630b3b12e70c6e8d9bcc805ca29de1bded6a0 (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
#$Id$
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

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

# Get the userid (or ip on NT)

if ($^O eq "MSWin32")
{
  system ("ipconfig | find \"Address\">ipnum");

  open (IPNUM, "ipnum");

  read (IPNUM, $line, 80);

  $ip4 = (split (/: (\d+)\.(\d+)\.(\d+)\.(\d+)/, $line))[4];

  close IPNUM;

  system ("del /q ipnum");

  $uid = $ip4;
}
else
{
  $uid = getpwnam (getlogin ());
}

$port = 30001 + $uid;
$iorfile = "theior";
$invocation = "sii";
$num = 1;
$other = "";
$debug = "";
$type = "";

sub run_test
{
  my $type = shift(@_);

  $SV = Process::Create (".".$DIR_SEPARATOR."server".$Process::EXE_EXT,
                         "$debug -ORBobjrefstyle url -ORBport $port -o ".
			 $iorfile);
  
  sleep (2);     # Give the server a chance to start up
  
  system (".".$DIR_SEPARATOR."client $debug -f $iorfile  -i $invocation -t ".
          "$type -n $num");
  
  # @@
  # Someday, a better way of doing this should be found.  Or at least 
  # something that can tell if a server is still alive.  There is kill -0 on
  # Unix, but on NT ???

  $SV->Kill ();
}

# Parse the arguments

for ($i = 0; $i <= $#ARGV; $i++)
{
  SWITCH: 
  {
    if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?")
    {
      print "Run_Test Perl script for TAO Param Test\n\n";
      print "run_test [-n num] [-d] [-onewin] [-h] [-t type] [-i (dii|sii)]\n";
      print "\n";
      print "-n num              -- runs the client num times\n";
      print "-d                  -- runs each in debug mode\n";
      print "-onewin             -- keeps all tests in one window on NT\n";
      print "-h                  -- prints this information\n";
      print "-t type             -- runs only one type of param test\n";
      print "-i (dii|sii)        -- Changes the type of invocation\n";
      exit;
    }
    if ($ARGV[$i] eq "-n")
    {
      $num = $ARGV[$i + 1];
      $i++;
      last SWITCH;
    }
    if ($ARGV[$i] eq "-d")
    {
      $debug = $debug." -d";
      last SWITCH;
    }
    if ($ARGV[$i] eq "-onewin")
    {
      if ($^O eq "MSWin32")
      {
        $Process::newwindow = "no";
      }
      last SWITCH;
    }
    if ($ARGV[$i] eq "-t")
    {
      $type = $ARGV[$i + 1];
      $i++;
      last SWITCH;
    }
    if ($ARGV[$i] eq "-i")
    {
      $invocation = $ARGV[$i + 1];
      $i++;
      last SWITCH;
    }
    $other .= $ARGV[$i];
  }
}

@types = ("short", "ubstring", "bdstring", "fixed_struct", "strseq", 
          "bounded_strseq", "var_struct", "nested_struct", "struct_seq", 
	  "bounded_struct_seq", "any", "objref", "objref_sequence", 
	  "any_sequence", "short_sequence", "long_sequence", 
	  "bounded_short_sequence", "bounded_long_sequence",
	  "fixed_array", "var_array");

if ($type ne "")
{
  run_test ($type);
}
else
{
  foreach $type (@types)
  {
    run_test ($type);	
  }
}

if ($^O eq "MSWin32")
{
  system ("del ".$iorfile);
}
else
{
  system ("rm ".$iorfile);
}