File: http-header-test.pl

package info (click to toggle)
globus-xio 6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 8,128 kB
  • sloc: ansic: 46,711; sh: 11,139; perl: 1,598; makefile: 289
file content (74 lines) | stat: -rwxr-xr-x 1,955 bytes parent folder | download | duplicates (5)
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
#! /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 warnings;
use Test::More;
use IPC::Open2 qw(open2);

my @tests;
my $test_exec="./http_header_test";
my $data_dir=$ENV{TEST_DATA_DIR};

if (! -d $data_dir && -r 'headers')
{
    $data_dir = '';
}
elsif (! -r "${data_dir}headers")
{
    print STDERR "Can't find data.\n";
    exit(99);
}

push(@tests, "${data_dir}headers");
push(@tests, "${data_dir}long-headers");
push(@tests, "${data_dir}multi-line-header");
push(@tests, "${data_dir}multi-headers");

plan tests => scalar(@tests);
foreach my $test_name (@tests)
{
    my $result;
    my ($client_in, $client_out, $server_in, $server_out);
    my ($client_pid, $server_pid);
    $client_pid = open2($client_out, $client_in, $test_exec, '-c', '-f',
            $test_name);
    $server_pid = open2($server_out, $server_in, $test_exec, '-s', '-f',
            $test_name);
    my $input = <$server_out>;
    close($server_in);
    close($server_out);
    if (!$input) {
        ok(0, $_->[2]);
        close($client_in);
        close($client_out);
        waitpid($server_pid, 0);
        waitpid($client_pid, 0);
        next;
    }
    print $client_in $input;
    close($client_in);
    local ($/);
    waitpid($server_pid, 0);
    waitpid($client_pid, 0);
    $result = <$client_out>;
    $result =~ s/\s*$//;
    close($client_out);

    ok($result eq 'Success', $_);
}