~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to tests/runtests.pl

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20
20
# KIND, either express or implied.
21
21
#
22
 
# $Id: runtests.pl,v 1.295 2008-05-01 10:51:16 bagder Exp $
 
22
# $Id: runtests.pl,v 1.315 2008-11-19 21:56:11 bagder Exp $
23
23
###########################################################################
24
24
 
25
25
# Experimental hooks are available to run tests remotely on machines that
45
45
# to do with cookies, those that set environment variables, or those that
46
46
# do more than touch the file system in a <precheck> or <postcheck>
47
47
# section). These can be added to the $TESTCASES line below,
48
 
# e.g. $TESTCASES="!8 !31 !63..."
 
48
# e.g. $TESTCASES="!8 !31 !63 !cookies..."
49
49
#
50
50
# Finally, to properly support -g and -n, checktestcmd needs to change
51
51
# to check the remote system's PATH, and the places in the code where
197
197
my %skipped;    # skipped{reason}=counter, reasons for skip
198
198
my @teststat;   # teststat[testnum]=reason, reasons for skip
199
199
my %disabled_keywords;  # key words of tests to skip
 
200
my %enabled_keywords;   # key words of tests to run
200
201
 
201
202
my $sshdid;      # for socks server, ssh daemon version id
202
203
my $sshdvernum;  # for socks server, ssh daemon version number
387
388
    my @paths=(split(":", $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
388
389
               "/sbin", "/usr/bin", "/usr/local/bin" );
389
390
    for(@paths) {
390
 
        if( -x "$_/$cmd") {
 
391
        if( -x "$_/$cmd" && ! -d "$_/$cmd") {
 
392
            # executable bit but not a directory!
391
393
            return "$_/$cmd";
392
394
        }
393
395
    }
431
433
# Memory allocation test and failure torture testing.
432
434
#
433
435
sub torture {
 
436
    use POSIX "strftime";
434
437
    my $testcmd = shift;
435
438
    my $gdbline = shift;
436
439
 
467
470
            next;
468
471
        }
469
472
 
470
 
        logmsg "Fail alloc no: $limit\r" if($verbose);
 
473
        logmsg "Fail alloc no: $limit @ " . strftime ("%H:%M:%S", localtime) . "\r" if($verbose);
471
474
 
472
475
        # make the memory allocation function number $limit return failure
473
476
        $ENV{'CURL_MEMLIMIT'} = $limit;
484
487
        else {
485
488
            $ret = runclient($testcmd);
486
489
        }
 
490
        #logmsg "$_ Returned " . $ret / 256 . "\n";
487
491
 
488
492
        # Now clear the variable again
489
493
        $ENV{'CURL_MEMLIMIT'} = undef;
583
587
 
584
588
sub verifyhttp {
585
589
    my ($proto, $ip, $port) = @_;
586
 
    my $cmd = "$CURL -m$server_response_maxtime -o log/verifiedserver -ksvg \"$proto://$ip:$port/verifiedserver\" 2>log/verifyhttp";
 
590
    my $cmd = "$CURL --max-time $server_response_maxtime --output $LOGDIR/verifiedserver --insecure --silent --verbose --globoff \"$proto://$ip:$port/verifiedserver\" 2>$LOGDIR/verifyhttp";
587
591
    my $pid;
588
592
 
589
593
    # verify if our/any server is running on this port
594
598
    my $data;
595
599
 
596
600
    if($res && $verbose) {
597
 
        open(ERR, "<log/verifyhttp");
 
601
        open(ERR, "<$LOGDIR/verifyhttp");
598
602
        my @e = <ERR>;
599
603
        close(ERR);
600
604
        logmsg "RUN: curl command returned $res\n";
604
608
            }
605
609
        }
606
610
    }
607
 
    open(FILE, "<log/verifiedserver");
 
611
    open(FILE, "<$LOGDIR/verifiedserver");
608
612
    my @file=<FILE>;
609
613
    close(FILE);
610
614
    $data=$file[0]; # first line
636
640
    my $time=time();
637
641
    my $extra;
638
642
    if($proto eq "ftps") {
639
 
        $extra = "-k --ftp-ssl-control ";
 
643
        $extra = "--insecure --ftp-ssl-control ";
640
644
    }
641
 
    my $cmd="$CURL -m$server_response_maxtime --silent -vg $extra\"$proto://$ip:$port/verifiedserver\" 2>log/verifyftp";
 
645
    my $cmd="$CURL --max-time $server_response_maxtime --silent --verbose --globoff $extra\"$proto://$ip:$port/verifiedserver\" 2>$LOGDIR/verifyftp";
642
646
    # check if this is our server running on this port:
643
647
    my @data=runclientoutput($cmd);
644
648
    logmsg "RUN: $cmd\n" if($verbose);
1538
1542
                # debug is a listed "feature", use that knowledge
1539
1543
                $curl_debug = 1;
1540
1544
                # set the NETRC debug env
1541
 
                $ENV{'CURL_DEBUG_NETRC'} = 'log/netrc';
 
1545
                $ENV{'CURL_DEBUG_NETRC'} = "$LOGDIR/netrc";
1542
1546
            }
1543
1547
            if($feat =~ /SSL/i) {
1544
1548
                # ssl enabled
1818
1822
        last;
1819
1823
    }
1820
1824
 
 
1825
    my $dbghosttype=join(' ', runclientoutput("uname -a"));
 
1826
    if(($dbghosttype =~ /SMP PREEMPT/) && ($dbghosttype =~ /i686 GNU/)) {
 
1827
        if(!$curl_debug) {
 
1828
            if(($testnum != 1)   && ($testnum != 100) &&
 
1829
               ($testnum != 500) && ($testnum != 507) &&
 
1830
               ($testnum != 517) && ($testnum != 534) &&
 
1831
               ($testnum != 558) && ($testnum != 559) &&
 
1832
               ($testnum != 557) && ($testnum != 1013)) {
 
1833
                $why = "debugging icc build";
 
1834
            }
 
1835
        }
 
1836
    }
 
1837
 
1821
1838
    if(!$why) {
1822
1839
        my @keywords = getpart("info", "keywords");
 
1840
        my $match;
1823
1841
        my $k;
1824
1842
        for $k (@keywords) {
1825
1843
            chomp $k;
1826
1844
            if ($disabled_keywords{$k}) {
1827
1845
                $why = "disabled by keyword";
 
1846
            } elsif ($enabled_keywords{$k}) {
 
1847
                $match = 1;
1828
1848
            }
1829
1849
        }
 
1850
 
 
1851
        if(!$why && !$match && %enabled_keywords) {
 
1852
          $why = "disabled by missing keyword";
 
1853
        }
1830
1854
    }
1831
1855
 
1832
1856
    if(!$why) {
1843
1867
            if($o[0]) {
1844
1868
                $why = $o[0];
1845
1869
                chomp $why;
 
1870
            } elsif($?) {
 
1871
                $why = "precheck command error";
1846
1872
            }
1847
1873
            logmsg "prechecked $cmd\n" if($verbose);
1848
1874
        }
2008
2034
 
2009
2035
    my $cmdargs;
2010
2036
    if(!$tool) {
2011
 
        # run curl, add -v for debug information output
2012
 
        $cmdargs ="$out --include -v --trace-time $cmd";
 
2037
        # run curl, add --verbose for debug information output
 
2038
        $cmdargs ="$out --include --verbose --trace-time $cmd";
2013
2039
    }
2014
2040
    else {
2015
2041
        $cmdargs = " $cmd"; # $cmd is the command line for the test file
2040
2066
 
2041
2067
    my $usevalgrind = $valgrind && ((getpart("verify", "valgrind"))[0] !~ /disable/);
2042
2068
    if($usevalgrind) {
2043
 
        $CMDLINE = "$valgrind ".$valgrind_tool."--leak-check=yes --num-callers=16 ${valgrind_logfile}=log/valgrind$testnum $CMDLINE";
 
2069
        $CMDLINE = "$valgrind ".$valgrind_tool."--leak-check=yes --num-callers=16 ${valgrind_logfile}=$LOGDIR/valgrind$testnum $CMDLINE";
2044
2070
    }
2045
2071
 
2046
2072
    $CMDLINE .= "$cmdargs >>$STDOUT 2>>$STDERR";
2071
2097
    }
2072
2098
 
2073
2099
    if($gdbthis) {
2074
 
        open(GDBCMD, ">log/gdbcmd");
 
2100
        my $gdbinit = "$TESTDIR/gdbinit$testnum";
 
2101
        open(GDBCMD, ">$LOGDIR/gdbcmd");
2075
2102
        print GDBCMD "set args $cmdargs\n";
2076
2103
        print GDBCMD "show args\n";
 
2104
        print GDBCMD "source $gdbinit\n" if -e $gdbinit;
2077
2105
        close(GDBCMD);
2078
2106
    }
2079
2107
    # run the command line we built
2080
2108
    if ($torture) {
2081
2109
        $cmdres = torture($CMDLINE,
2082
 
                       "$gdb --directory libtest $DBGCURL -x log/gdbcmd");
 
2110
                       "$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
2083
2111
    }
2084
2112
    elsif($gdbthis) {
2085
 
        runclient("$gdb --directory libtest $DBGCURL -x log/gdbcmd");
 
2113
        runclient("$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
2086
2114
        $cmdres=0; # makes it always continue after a debugged run
2087
2115
    }
2088
2116
    else {
2094
2122
            $cmdres = 1000;
2095
2123
        }
2096
2124
        else {
2097
 
            $cmdres /= 256;
 
2125
            $cmdres >>= 8;
 
2126
            $cmdres = (2000 + $signal_num) if($signal_num && !$cmdres);
2098
2127
        }
2099
2128
    }
2100
2129
    if(!$dumped_core) {
2108
2137
        logmsg "core dumped\n";
2109
2138
        if(0 && $gdb) {
2110
2139
            logmsg "running gdb for post-mortem analysis:\n";
2111
 
            open(GDBCMD, ">log/gdbcmd2");
 
2140
            open(GDBCMD, ">$LOGDIR/gdbcmd2");
2112
2141
            print GDBCMD "bt\n";
2113
2142
            close(GDBCMD);
2114
 
            runclient("$gdb --directory libtest -x log/gdbcmd2 -batch $DBGCURL core ");
2115
 
     #       unlink("log/gdbcmd2");
 
2143
            runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch $DBGCURL core ");
 
2144
     #       unlink("$LOGDIR/gdbcmd2");
2116
2145
        }
2117
2146
    }
2118
2147
 
2423
2452
            if(!$src) {
2424
2453
                $src=".";
2425
2454
            }
2426
 
            my @e = valgrindparse($src, $feature{'SSL'}, "log/$l");
 
2455
            my @e = valgrindparse($src, $feature{'SSL'}, "$LOGDIR/$l");
2427
2456
            if($e[0]) {
2428
2457
                logmsg " valgrind ERROR ";
2429
2458
                logmsg @e;
2481
2510
            }
2482
2511
            $prev = $pid;
2483
2512
        }
 
2513
        delete $run{$server};
2484
2514
    }
2485
2515
    ftpkillslaves($verbose);
2486
2516
}
2698
2728
        chomp $proto;
2699
2729
        if (! grep /^$proto$/, @protocols) {
2700
2730
            if (substr($proto,0,5) ne "socks") {
2701
 
                    return "curl lacks any $proto support";
 
2731
                    return "curl lacks $proto support";
2702
2732
            }
2703
2733
        }
2704
2734
    }
2781
2811
    elsif($ARGV[0] eq "-h") {
2782
2812
        # show help text
2783
2813
        print <<EOHELP
2784
 
Usage: runtests.pl [options] [test number(s)]
 
2814
Usage: runtests.pl [options] [test selection(s)]
2785
2815
  -a       continue even if a test fails
2786
2816
  -bN      use base port number N for test servers (default $base)
2787
2817
  -c path  use this curl executable
2797
2827
  -v       verbose output
2798
2828
  [num]    like "5 6 9" or " 5 to 22 " to run those tests only
2799
2829
  [!num]   like "!5 !6 !9" to disable those tests
2800
 
  [!keyword] like "!cookies !IPv6" to disable tests with those key words
 
2830
  [keyword] like "IPv6" to select only tests containing the key word
 
2831
  [!keyword] like "!cookies" to disable any tests containing the key word
2801
2832
EOHELP
2802
2833
    ;
2803
2834
        exit;
2824
2855
    elsif($ARGV[0] =~ /^!(.+)/) {
2825
2856
        $disabled_keywords{$1}=$1;
2826
2857
    }
 
2858
    elsif($ARGV[0] =~ /^([-[{a-zA-Z].*)/) {
 
2859
        $enabled_keywords{$1}=$1;
 
2860
    }
2827
2861
    else {
2828
2862
        print "Unknown option: $ARGV[0]\n";
2829
2863
        exit;
2940
2974
    for(@cmds) {
2941
2975
        $_ =~ s/[a-z\/\.]*//g;
2942
2976
    }
2943
 
    # the the numbers from low to high
 
2977
    # sort the numbers from low to high
2944
2978
    foreach my $n (sort { $a <=> $b } @cmds) {
2945
2979
        if($disabled{$n}) {
2946
2980
            # skip disabled test cases
2963
2997
#######################################################################
2964
2998
 
2965
2999
# Display the contents of the given file.  Line endings are canonicalized
2966
 
# and excessively long files are truncated
 
3000
# and excessively long files are elided
2967
3001
sub displaylogcontent {
2968
3002
    my ($file)=@_;
2969
3003
    if(open(SINGLE, "<$file")) {
2970
 
        my $lfcount;
2971
3004
        my $linecount = 0;
2972
3005
        my $truncate;
2973
3006
        my @tail;
2975
3008
            $string =~ s/\r\n/\n/g;
2976
3009
            $string =~ s/[\r\f\032]/\n/g;
2977
3010
            $string .= "\n" unless ($string =~ /\n$/);
2978
 
            $lfcount = $string =~ tr/\n//;
2979
 
            if($lfcount == 1) {
2980
 
                $string =~ s/\n//;
2981
 
                $string =~ s/\s*\!$//;
2982
 
                $linecount++;
2983
 
                if ($truncate) {
2984
 
                    push @tail, " $string\n";
2985
 
                } else {
2986
 
                    logmsg " $string\n";
2987
 
                }
2988
 
            }
2989
 
            else {
2990
 
                for my $line (split("\n", $string)) {
2991
 
                    $line =~ s/\s*\!$//;
2992
 
                    $linecount++;
2993
 
                    if ($truncate) {
2994
 
                        push @tail, " $line\n";
2995
 
                    } else {
2996
 
                        logmsg " $line\n";
2997
 
                    }
2998
 
                }
2999
 
            }
3000
 
            $truncate = $linecount > 1000;
 
3011
            $string =~ tr/\n//;
 
3012
            for my $line (split("\n", $string)) {
 
3013
                $line =~ s/\s*\!$//;
 
3014
                if ($truncate) {
 
3015
                    push @tail, " $line\n";
 
3016
                } else {
 
3017
                    logmsg " $line\n";
 
3018
                }
 
3019
                $linecount++;
 
3020
                $truncate = $linecount > 1000;
 
3021
            }
3001
3022
        }
3002
3023
        if (@tail) {
3003
3024
            logmsg "=== File too long: lines here were removed\n";
3015
3036
    my @logs = readdir(DIR);
3016
3037
    closedir(DIR);
3017
3038
 
3018
 
    logmsg "== Contents of files in the log/ dir after test $testnum\n";
 
3039
    logmsg "== Contents of files in the $LOGDIR/ dir after test $testnum\n";
3019
3040
    foreach my $log (sort @logs) {
3020
3041
        if($log =~ /\.(\.|)$/) {
3021
3042
            next; # skip "." and ".."