Newer
Older
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://curl.haxx.se/docs/copyright.html.
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# $Id$
###########################################################################
# These should be the only variables that might be needed to get edited:
@INC=(@INC, $ENV{'srcdir'}, ".");
require "getpart.pm"; # array functions
require "valgrind.pm"; # valgrind report parser
Daniel Stenberg
committed
my $srcdir = $ENV{'srcdir'} || '.';
Daniel Stenberg
committed
my $base = 8990; # base port number
my $HTTPPORT; # HTTP server port
my $HTTP6PORT; # HTTP IPv6 server port
Daniel Stenberg
committed
my $HTTPSPORT; # HTTPS server port
my $FTPPORT; # FTP server port
Daniel Stenberg
committed
my $FTP2PORT; # FTP server 2 port
Daniel Stenberg
committed
my $FTPSPORT; # FTPS server port
my $CURL="../src/curl"; # what curl executable to run on the tests
my $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging
my $TESTDIR="$srcdir/data";
my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
Daniel Stenberg
committed
my $SERVER2IN="$LOGDIR/server2.input"; # what curl sent the second server
my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
# Normally, all test cases should be run, but at times it is handy to
# simply run a particular one:
# To run specific test cases, set them like:
# $TESTCASES="1 2 3 7 8";
#######################################################################
# No variables below this point should need to be modified
#
my $HTTPPIDFILE=".http.pid";
my $HTTP6PIDFILE=".http6.pid";
my $FTPPIDFILE=".ftp.pid";
Daniel Stenberg
committed
my $FTP2PIDFILE=".ftp2.pid";
my $FTPSPIDFILE=".ftps.pid";
# invoke perl like this:
my $perl="perl -I$srcdir";
# this gets set if curl is compiled with debugging:
my $curl_debug=0;
# name of the file that the memory debugging creates:
my $memdump="$LOGDIR/memdump";
# the path to the script that analyzes the memory debug output file:
my $memanalyze="./memanalyze.pl";
my $stunnel = checkcmd("stunnel");
my $valgrind = checkcmd("valgrind");
my $valgrind_tool;
if($valgrind) {
# since valgrind 2.1.x, '--tool' option is mandatory
# use it, if it is supported by the version installed on the system
system("valgrind --help 2>&1 | grep -- --tool > /dev/null 2>&1");
if (($? >> 8)==0) {
$valgrind_tool="--tool=memcheck ";
}
open(C, "<$CURL");
my $l = <C>;
if($l =~ /^\#\!/) {
# The first line starts with "#!" which implies a shell-script.
# This means libcurl is built shared and curl is a wrapper-script
# Disable valgrind in this setup
$valgrind=0;
}
close(C);
Daniel Stenberg
committed
my $gdb = checkcmd("gdb");
Daniel Stenberg
committed
my $ssl_version; # set if libcurl is built with SSL support
my $large_file; # set if libcurl is built with large file support
Daniel Stenberg
committed
my $has_idn; # set if libcurl is built with IDN support
my $http_ipv6; # set if HTTP server has IPv6 support
my $has_ipv6; # set if libcurl is built with IPv6 support
my $has_libz; # set if libcurl is built with libz support
my $has_getrlimit; # set if system has getrlimit()
Daniel Stenberg
committed
my $has_ntlm; # set if libcurl is built with NTLM support
Daniel Stenberg
committed
Daniel Stenberg
committed
my $skipped=0; # number of tests skipped; reported in main loop
my %skipped; # skipped{reason}=counter, reasons for skip
my @teststat; # teststat[testnum]=reason, reasons for skip
#######################################################################
# variables the command line options may set
#
my $short;
my $verbose;
my $debugprotocol;
my $gdbthis; # run test case with gdb debugger
my $keepoutfiles; # keep stdout and stderr files after tests
Daniel Stenberg
committed
my $postmortem; # display detailed info about failed tests
my $pwd; # current working directory
# torture test variables
my $torture;
my $tortnum;
my $tortalloc;
chomp($pwd = `pwd`);
# enable memory debugging if curl is compiled with it
$ENV{'CURL_MEMDEBUG'} = $memdump;
Daniel Stenberg
committed
$ENV{'HOME'}=$pwd;
Daniel Stenberg
committed
##########################################################################
# Clear all possible '*_proxy' environment variables for various protocols
# to prevent them to interfere with our testing!
my $protocol;
foreach $protocol (('ftp', 'http', 'ftps', 'https', 'gopher', 'no')) {
my $proxy = "${protocol}_proxy";
# clear lowercase version
$ENV{$proxy}=undef;
# clear uppercase version
$ENV{uc($proxy)}=undef;
}
Daniel Stenberg
committed
#######################################################################
# Check for a command in the PATH.
#
sub checkcmd {
my ($cmd)=@_;
my @paths=("/usr/sbin", "/usr/local/sbin", "/sbin", "/usr/bin",
"/usr/local/bin", split(":", $ENV{'PATH'}));
for(@paths) {
if( -x "$_/$cmd") {
return "$_/$cmd";
}
}
}
#######################################################################
# Return the pid of the server as found in the given pid file
#
sub serverpid {
open(PFILE, "<$PIDFILE");
Daniel Stenberg
committed
my $PID=0+<PFILE>;
close(PFILE);
return $PID;
}
#######################################################################
# Memory allocation test and failure torture testing.
#
sub torture {
my $testcmd = shift;
my $gdbline = shift;
# remove memdump first to be sure we get a new nice and clean one
unlink($memdump);
# First get URL from test server, ignore the output/result
Loading
Loading full blame…