curl-library
Test patches
Date: Fri, 7 May 2004 16:00:29 +0100
Using
./configure --disable-shared --disable-ipv6 --enable-ares --enable-debug --without-ssl
all the tests fail with
** MEMORY FAILURE
FREE ERROR: No memory allocated: MEM ares_destroy.c:30 free(0x808e00c)
The problem is that on my machine, channel->domains is allocated using
malloc(0) (ares_init.c:523), and memanalyze.pl doesn't treat this as a valid
malloc(). Unless there is a reason you prefer to avoid malloc(0), this patch
fixes it:
diff -d -u -3 -w -r1.10 memanalyze.pl
--- memanalyze.pl 29 Apr 2004 14:33:19 -0000 1.10
+++ memanalyze.pl 7 May 2004 13:00:14 -0000
@@ -88,7 +88,7 @@
if($function =~ /free\(0x([0-9a-f]*)/) {
$addr = $1;
- if($sizeataddr{$addr} == 0) {
+ if(!exists $sizeataddr{$addr}) {
print "FREE ERROR: No memory allocated: $line\n";
}
elsif(-1 == $sizeataddr{$addr}) {
______________________________________________________________________________
This hack at runtests.pl lets the "torture" test be run on any test-case,
instead of just curl with a fixed list of URLs. This shows some leaks for me.
I'll have a look if I can fix some later.
diff -d -u -3 -w -r1.124 runtests.pl
--- runtests.pl 5 May 2004 20:12:59 -0000 1.124
+++ runtests.pl 7 May 2004 13:00:15 -0000
@@ -155,44 +155,14 @@
# 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/1',
- 'http://%HOSTIP:%HOSTPORT/3 -d "poo"');
-
- # loop over the different tests commands
- for(@test) {
- my $cmdargs = "$_";
-
- $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 = shift;
- my $testcmd = "$CURL $cmdargs $redir";
+ # 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
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
@@ -206,10 +176,10 @@
}
if(!$count) {
# hm, no allocations in this fetch, ignore and get next
- print "BEEEP, no allocs found for test $c!!!\n";
+ print "BEEEP, no allocs found!!!\n";
next;
}
- print " $count allocations to excersize\n";
+ print " $count allocations to exercise\n";
for ( 1 .. $count ) {
my $limit = $_;
@@ -255,16 +225,13 @@
}
}
if($fail) {
- print " Failed on alloc number $limit in test $c.\n",
- " invoke with -t$c,$limit to repeat this single case.\n";
+ print " Failed on alloc number $limit in test.\n",
+ " invoke with -t1,$limit to repeat this single case.\n";
stopservers();
exit 1;
}
}
- print "\n torture test $c did GOOD\n";
- # all is well, now test a different kind of URL
- }
stopservers();
exit; # for now, we stop after these tests
}
@@ -1060,6 +1027,9 @@
system("gdb --directory libtest $DBGCURL -x log/gdbcmd");
$cmdres=0; # makes it always continue after a debugged run
}
+ elsif ($torture) {
+ torture($CMDLINE);
+ }
else {
$cmdres = system("$CMDLINE");
my $signal_num = $cmdres & 127;
@@ -1584,11 +1554,6 @@
print "can't log command lines to $CURLLOG\n";
#######################################################################
-# Torture the memory allocation system and checks
-#
-if($torture) {
- &torture();
-}
sub displaylogcontent {
my ($file)=@_;
Received on 2004-05-07