File: test-wrapper

package info (click to toggle)
globus-ftp-client 9.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,320 kB
  • sloc: ansic: 35,236; sh: 4,292; perl: 2,723; makefile: 271
file content (89 lines) | stat: -rwxr-xr-x 2,373 bytes parent folder | download | duplicates (4)
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
#! /usr/bin/perl

# 
# Copyright 1999-2006 University of Chicago
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 

use strict;
use Cwd;
use File::Basename;
use Getopt::Long;
use lib dirname($0);
use FtpTestLib;

require 5.8.0;
use vars qw(@tests);

$ENV{GLOBUS_USAGE_OPTOUT} = "1";
$ENV{FTP_TEST_FORCE_LOCAL} = "1";
my $server_pid;
my $server_prog = $ENV{GRIDFTP_SERVER_EXE} || "globus-gridftp-server";
my $server_host = "localhost";
my $subject;

my $server_args = "-no-chdir -no-exit -d 0 -auth-level 4 -p 0";
if ($< != 0)
{
    $server_args = "-no-fork $server_args";
}

$subject = `openssl x509 -subject -noout -in \${X509_USER_CERT:-testcred.cert} -nameopt sep_multiline | sed -e '/^subject=/d' -e 's!^\\s*!/!' | tr -d '\\n'`;

print STDERR "#Subject is $subject\n";
print STDERR "#PATH is $ENV{PATH}\n";
print STDERR "#executing $server_prog $server_args\n";
#$server_pid = open(SERVER, "../libtool --mode=execute valgrind --log-file=valgrind.log.%p       --trace-children=yes $server_prog $server_args |");
$server_pid = open(SERVER, "$server_prog $server_args |");
 
if($server_pid == -1)
{
    print "Unable to start server\n";
    exit 99;
}

select((select(SERVER), $| = 1)[0]);
my $server_port = <SERVER>;
$server_port =~ s/Server listening at .*?:(\d+)/\1/;
$server_port =~ s/\s*$//;

if($server_port !~ /\d+/)
{
    print "Unable to start server: $server_port\n";
    exit 1;
}

print "Started server at port $server_port\n";

# sleep a second, some hosts are slow....

sleep 5;

$ENV{GLOBUS_FTP_CLIENT_TEST_SUBJECT} = $subject;
$ENV{FTP_TEST_SOURCE_HOST} = "$server_host:$server_port";
$ENV{FTP_TEST_DEST_HOST} = "$server_host:$server_port";   

my $rc = system(@ARGV);
print "Test exited with $rc\n";

kill 'INT', $server_pid;

if (kill 0, $server_pid) {
    sleep(1);
    if (kill 0, $server_pid) {
        kill 'KILL', $server_pid;
    }
}

exit ($rc>>8);