Newer
Older
#
# Main curl test script, in perl to run on more platforms
#
#######################################################################
# These should be the only variables that might be needed to get edited:
@INC=(@INC, $ENV{'srcdir'}, ".");
require "getpart.pm"; # array functions
Daniel Stenberg
committed
my $srcdir = $ENV{'srcdir'} || '.';
my $HOSTPORT=8999; # bad name, but this is the HTTP server port
my $HTTPSPORT=8433; # this is the HTTPS server port
my $FTPPORT=8921; # this is the FTP server port
my $FTPSPORT=8821; # this is the 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 $SERVERIN="$LOGDIR/server.input"; # what curl sent the 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 $FTPPIDFILE=".ftp.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="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");
Daniel Stenberg
committed
my $ssl_version; # set if libcurl is built with SSL support
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
if($valgrind) {
Daniel Stenberg
committed
# we have found valgrind on the host, use it
# perhaps we should verify that valgrind works before we actually use it?
$CURL="valgrind --leak-check=yes --logfile-fd=3 -q $CURL";
}
#######################################################################
# 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
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'} = 1;
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 {
# start all test servers (http, https, ftp, ftps)
&startservers(("http", "https", "ftp", "ftps"));
my $c;
my @test=('http://%HOSTIP:%HOSTPORT/1',
'ftp://%HOSTIP:%FTPPORT/');
# loop over the different tests commands
for(@test) {
$c++;
if($tortnum && ($tortnum != $c)) {
next;
}
print "We want test $c\n";
my $redir=">log/torture.stdout 2>log/torture.stderr";
subVariables(\$cmdargs);
my $testcmd = "$CURL $cmdargs $redir";
# First get URL from test server, ignore the output/result
system($testcmd);
# Set up gdb-stuff if desired
if($gdbthis) {
open(GDBCMD, ">log/gdbcmd");
print GDBCMD "set args $cmdargs\n";
print GDBCMD "show args\n";
close(GDBCMD);
$testcmd = "gdb $CURL -x log/gdbcmd";
}
print "Torture test $c:\n";
print " CMD: $testcmd\n" if($verbose);
# memanalyze -v is our friend, get the number of allocations made
my $count;
for(@out) {
if(/^Allocations: (\d+)/) {
$count = $1;
last;
}
}
if(!$count) {
# hm, no allocations in this fetch, ignore and get next
print "BEEEP, no allocs found for test $c!!!\n";
next;
}
print " $count allocations to excersize\n";
for ( 1 .. $count ) {
my $limit = $_;
my $fail;
Loading
Loading full blame…