1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

moved two functions to ftp.pm, made some more changes on stopping servers

and fixed the textmode attribute thing for windows a bit
This commit is contained in:
Daniel Stenberg 2005-04-28 21:04:58 +00:00
parent 913c370c25
commit c6aae9b1d7

View File

@ -123,6 +123,8 @@ my $has_getrlimit; # set if system has getrlimit()
my $has_ntlm; # set if libcurl is built with NTLM support my $has_ntlm; # set if libcurl is built with NTLM support
my $has_openssl; # set if libcurl is built with OpenSSL my $has_openssl; # set if libcurl is built with OpenSSL
my $has_gnutls; # set if libcurl is built with GnuTLS my $has_gnutls; # set if libcurl is built with GnuTLS
my $has_textaware; # set if running on a system that has a text mode concept
# on files. Windows for example
my $skipped=0; # number of tests skipped; reported in main loop my $skipped=0; # number of tests skipped; reported in main loop
my %skipped; # skipped{reason}=counter, reasons for skip my %skipped; # skipped{reason}=counter, reasons for skip
@ -158,8 +160,8 @@ $ENV{'HOME'}=$pwd;
sub catch_zap { sub catch_zap {
my $signame = shift; my $signame = shift;
print STDERR "received SIG$signame, exiting\n"; print STDERR "runtests.pl received SIG$signame, exiting\n";
stopservers(); stopservers(1);
die "Somebody sent me a SIG$signame"; die "Somebody sent me a SIG$signame";
} }
$SIG{INT} = \&catch_zap; $SIG{INT} = \&catch_zap;
@ -192,17 +194,6 @@ sub checkcmd {
} }
} }
#######################################################################
# Return the pid of the server as found in the given pid file
#
sub serverpid {
my $PIDFILE = $_[0];
open(PFILE, "<$PIDFILE");
my $PID=0+<PFILE>;
close(PFILE);
return $PID;
}
####################################################################### #######################################################################
# Memory allocation test and failure torture testing. # Memory allocation test and failure torture testing.
# #
@ -297,7 +288,7 @@ sub torture {
if($fail) { if($fail) {
print " Failed on alloc number $limit in test.\n", print " Failed on alloc number $limit in test.\n",
" invoke with -t$limit to repeat this single case.\n"; " invoke with -t$limit to repeat this single case.\n";
stopservers(); stopservers($verbose);
exit 1; exit 1;
} }
} }
@ -331,26 +322,6 @@ sub stopserver {
} }
} }
#######################################################################
# check the given test server if it is still alive
#
sub checkserver {
my ($pidfile)=@_;
my $pid=0;
# check for pidfile
if ( -f $pidfile ) {
$pid=serverpid($pidfile);
if ($pid ne "" && kill(0, $pid)) {
return $pid;
}
else {
return -$pid; # negative means dead process
}
}
return 0;
}
####################################################################### #######################################################################
# start the http server, or if it already runs, verify that it is our # start the http server, or if it already runs, verify that it is our
# test server on the test-port! # test server on the test-port!
@ -420,7 +391,7 @@ sub runhttpserver {
if(!$res) { if(!$res) {
print "RUN: Failed to kill test HTTP$nameext server, do it ", print "RUN: Failed to kill test HTTP$nameext server, do it ",
"manually and restart the tests.\n"; "manually and restart the tests.\n";
stopservers(); stopservers($verbose);
exit; exit;
} }
sleep(1); sleep(1);
@ -719,7 +690,7 @@ sub compare {
####################################################################### #######################################################################
# display information about curl and the host the test suite runs on # display information about curl and the host the test suite runs on
# #
sub checkcurl { sub checksystem {
unlink($memdump); # remove this if there was one left unlink($memdump); # remove this if there was one left
@ -907,6 +878,8 @@ sub checkcurl {
$has_gnutls?"GnuTLS":($has_openssl?"OpenSSL":"<unknown>")); $has_gnutls?"GnuTLS":($has_openssl?"OpenSSL":"<unknown>"));
} }
$has_textaware = ($^O eq 'MSWin32') || ($^O eq 'msys');
print "***************************************** \n"; print "***************************************** \n";
} }
@ -1236,7 +1209,7 @@ sub singletest {
if($@) { if($@) {
print "perl: $code\n"; print "perl: $code\n";
print "precommand: $@"; print "precommand: $@";
stopservers(); stopservers($verbose);
exit; exit;
} }
} }
@ -1409,7 +1382,7 @@ sub singletest {
my $filename=$hash{'name'}; my $filename=$hash{'name'};
if(!$filename) { if(!$filename) {
print "ERROR: section verify=>file has no name attribute!\n"; print "ERROR: section verify=>file has no name attribute!\n";
stopservers(); stopservers($verbose);
exit; exit;
} }
my $filemode=$hash{'mode'}; my $filemode=$hash{'mode'};
@ -1419,7 +1392,7 @@ sub singletest {
# what parts to cut off from the file # what parts to cut off from the file
my @stripfile = getpart("verify", "stripfile"); my @stripfile = getpart("verify", "stripfile");
if(($filemode eq "text") && ($^O eq 'MSWin32')) { if(($filemode eq "text") && $has_textaware) {
# text mode when running on windows means adding an extra # text mode when running on windows means adding an extra
# strip expression # strip expression
push @stripfile, "s/\r\n/\n/"; push @stripfile, "s/\r\n/\n/";
@ -1571,6 +1544,7 @@ sub singletest {
####################################################################### #######################################################################
# Stop all running test servers # Stop all running test servers
sub stopservers { sub stopservers {
my ($verbose)=@_;
for(keys %run) { for(keys %run) {
printf ("* kill pid for %-5s => %-5d\n", $_, $run{$_}) if($verbose); printf ("* kill pid for %-5s => %-5d\n", $_, $run{$_}) if($verbose);
stopserver($run{$_}); # the pid file is in the hash table stopserver($run{$_}); # the pid file is in the hash table
@ -1839,7 +1813,7 @@ $FTP6PORT = $base + 6; # FTP IPv6 port
# #
if(!$listonly) { if(!$listonly) {
checkcurl(); checksystem();
} }
####################################################################### #######################################################################
@ -1963,7 +1937,7 @@ foreach $testnum (@at) {
close(CMDLOG); close(CMDLOG);
# Tests done, stop the servers # Tests done, stop the servers
stopservers(); stopservers($verbose);
my $all = $total + $skipped; my $all = $total + $skipped;