From ad164eceb3ce6721d34a3418e0dacabd4f4ff904 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 10 Oct 2017 16:56:35 +0200 Subject: memdebug: trace send, recv and socket ... to allow them to be included in torture tests too. closes #1980 --- tests/memanalyze.pl | 30 +++++++++++++++++++++++------- tests/runtests.pl | 14 +++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl index 35d1c7ef7..8ba3f6dd5 100755 --- a/tests/memanalyze.pl +++ b/tests/memanalyze.pl @@ -6,7 +6,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -33,6 +33,9 @@ my $reallocs=0; my $strdups=0; my $wcsdups=0; my $showlimit; +my $sends=0; +my $recvs=0; +my $sockets=0; while(1) { if($ARGV[0] eq "-v") { @@ -258,6 +261,7 @@ while() { $filedes{$1}=1; $getfile{$1}="$source:$linenum"; $openfile++; + $sockets++; # number of socket() calls } elsif($function =~ /socketpair\(\) = (\d*) (\d*)/) { $filedes{$1}=1; @@ -314,6 +318,14 @@ while() { elsif($_ =~ /^GETNAME ([^ ]*):(\d*) (.*)/) { # not much to do } + # SEND url.c:1901 send(83) = 83 + elsif($_ =~ /^SEND ([^ ]*):(\d*) (.*)/) { + $sends++; + } + # RECV url.c:1901 recv(102400) = 256 + elsif($_ =~ /^RECV ([^ ]*):(\d*) (.*)/) { + $recvs++; + } # ADDR url.c:1282 getaddrinfo() = 0x5ddd elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) { @@ -398,12 +410,16 @@ if($addrinfos) { if($verbose) { print "Mallocs: $mallocs\n", - "Reallocs: $reallocs\n", - "Callocs: $callocs\n", - "Strdups: $strdups\n", - "Wcsdups: $wcsdups\n", - "Frees: $frees\n", - "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n"; + "Reallocs: $reallocs\n", + "Callocs: $callocs\n", + "Strdups: $strdups\n", + "Wcsdups: $wcsdups\n", + "Frees: $frees\n", + "Sends: $sends\n", + "Recvs: $recvs\n", + "Sockets: $sockets\n", + "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n", + "Operations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups + $sends + $recvs + $sockets)."\n"; print "Maximum allocated: $maxmem\n"; } diff --git a/tests/runtests.pl b/tests/runtests.pl index 44fd0ae93..39362e0b8 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -576,17 +576,17 @@ sub torture { my $count=0; my @out = `$memanalyze -v $memdump`; for(@out) { - if(/^Allocations: (\d+)/) { + if(/^Operations: (\d+)/) { $count = $1; last; } } if(!$count) { - logmsg " found no allocs to make fail\n"; + logmsg " found no functions to make fail\n"; return 0; } - logmsg " $count allocations to make fail\n"; + logmsg " $count functions to make fail\n"; for ( 1 .. $count ) { my $limit = $_; @@ -601,7 +601,7 @@ sub torture { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()); my $now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec); - logmsg "Fail alloc no: $limit at $now\r"; + logmsg "Fail funcion no: $limit at $now\r"; } # make the memory allocation function number $limit return failure @@ -610,7 +610,7 @@ sub torture { # remove memdump first to be sure we get a new nice and clean one unlink($memdump); - logmsg "*** Alloc number $limit is now set to fail ***\n" if($gdbthis); + logmsg "*** Function number $limit is now set to fail ***\n" if($gdbthis); my $ret = 0; if($gdbthis) { @@ -655,7 +655,7 @@ sub torture { } } if($fail) { - logmsg " Failed on alloc number $limit in test.\n", + logmsg " Failed on function number $limit in test.\n", " invoke with \"-t$limit\" to repeat this single case.\n"; stopservers($verbose); return 1; @@ -5377,7 +5377,7 @@ Usage: runtests.pl [options] [test selection(s)] -rf full run time statistics -s short output -am automake style output PASS/FAIL: [number] [name] - -t[N] torture (simulate memory alloc failures); N means fail Nth alloc + -t[N] torture (simulate function failures); N means fail Nth function -v verbose output -vc path use this curl only to verify the existing servers [num] like "5 6 9" or " 5 to 22 " to run those tests only -- cgit v1.2.3