-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.pl
executable file
·3047 lines (2738 loc) · 99.2 KB
/
runtests.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# For documentation, run `man ./runtests.1` and see README.md.
# Experimental hooks are available to run tests remotely on machines that
# are able to run curl but are unable to run the test harness.
# The following sections need to be modified:
#
# $HOSTIP, $HOST6IP - Set to the address of the host running the test suite
# $CLIENTIP, $CLIENT6IP - Set to the address of the host running curl
# runclient, runclientoutput - Modify to copy all the files in the log/
# directory to the system running curl, run the given command remotely
# and save the return code or returned stdout (respectively), then
# copy all the files from the remote system's log/ directory back to
# the host running the test suite. This can be done a few ways, such
# as using scp & ssh, rsync & telnet, or using a NFS shared directory
# and ssh.
#
# 'make && make test' needs to be done on both machines before making the
# above changes and running runtests.pl manually. In the shared NFS case,
# the contents of the tests/server/ directory must be from the host
# running the test suite, while the rest must be from the host running curl.
#
# Note that even with these changes a number of tests will still fail (mainly
# to do with cookies, those that set environment variables, or those that
# do more than touch the file system in a <precheck> or <postcheck>
# section). These can be added to the $TESTCASES line below,
# e.g. $TESTCASES="!8 !31 !63 !cookies..."
#
# Finally, to properly support -g and -n, checktestcmd needs to change
# to check the remote system's PATH, and the places in the code where
# the curl binary is read directly to determine its type also need to be
# fixed. As long as the -g option is never given, and the -n is always
# given, this won't be a problem.
use strict;
# Promote all warnings to fatal
use warnings FATAL => 'all';
use 5.006;
# These should be the only variables that might be needed to get edited:
BEGIN {
# Define srcdir to the location of the tests source directory. This is
# usually set by the Makefile, but for out-of-tree builds with direct
# invocation of runtests.pl, it may not be set.
if(!defined $ENV{'srcdir'}) {
use File::Basename;
$ENV{'srcdir'} = dirname(__FILE__);
}
push(@INC, $ENV{'srcdir'});
# run time statistics needs Time::HiRes
eval {
no warnings "all";
require Time::HiRes;
import Time::HiRes qw( time );
}
}
use Digest::MD5 qw(md5);
use List::Util 'sum';
use pathhelp qw(
exe_ext
sys_native_current_path
);
use processhelp qw(
portable_sleep
);
use appveyor;
use azure;
use getpart; # array functions
use servers;
use valgrind; # valgrind report parser
use globalconfig;
use runner;
use testutil;
my %custom_skip_reasons;
my $ACURL=$VCURL; # what curl binary to use to talk to APIs (relevant for CI)
# ACURL is handy to set to the system one for reliability
my $CURLCONFIG="../curl-config"; # curl-config from current build
# Normally, all test cases should be run, but at times it is handy to
# simply run a particular one:
my $TESTCASES="all";
# 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 $libtool;
my $repeat = 0;
my $start; # time at which testing started
my $uname_release = `uname -r`;
my $is_wsl = $uname_release =~ /Microsoft$/;
my $http_ipv6; # set if HTTP server has IPv6 support
my $http_unix; # set if HTTP server has Unix sockets support
my $ftp_ipv6; # set if FTP server has IPv6 support
my $resolver; # name of the resolver backend (for human presentation)
my $has_textaware; # set if running on a system that has a text mode concept
# on files. Windows for example
my %skipped; # skipped{reason}=counter, reasons for skip
my @teststat; # teststat[testnum]=reason, reasons for skip
my %disabled_keywords; # key words of tests to skip
my %ignored_keywords; # key words of tests to ignore results
my %enabled_keywords; # key words of tests to run
my %disabled; # disabled test cases
my %ignored; # ignored results of test cases
my %ignoretestcodes; # if test results are to be ignored
my $timestats; # time stamping and stats generation
my $fullstats; # show time stats for every single test
my %timeprepini; # timestamp for each test preparation start
my %timesrvrini; # timestamp for each test required servers verification start
my %timesrvrend; # timestamp for each test required servers verification end
my %timetoolini; # timestamp for each test command run starting
my %timetoolend; # timestamp for each test command run stopping
my %timesrvrlog; # timestamp for each test server logs lock removal
my %timevrfyend; # timestamp for each test result verification end
my $globalabort; # flag signalling program abort
# values for $singletest_state
use constant {
ST_INIT => 0,
ST_CLEARLOCKS => 1,
ST_INITED => 2,
ST_PREPROCESS => 3,
ST_RUN => 4,
};
my %singletest_state; # current state of singletest() by runner ID
my %singletest_logs; # log messages while in singletest array ref by runner
my $singletest_bufferedrunner; # runner ID which is buffering logs
my %runnerids; # runner IDs by number
my @runnersidle; # runner IDs idle and ready to execute a test
my %countforrunner; # test count by runner ID
my %runnersrunning; # tests currently running by runner ID
#######################################################################
# variables that command line options may set
#
my $short;
my $no_debuginfod;
my $keepoutfiles; # keep stdout and stderr files after tests
my $clearlocks; # force removal of files by killing locking processes
my $postmortem; # display detailed info about failed tests
my $run_disabled; # run the specific tests even if listed in DISABLED
my $scrambleorder;
my $jobs = 0;
# Azure Pipelines specific variables
my $AZURE_RUN_ID = 0;
my $AZURE_RESULT_ID = 0;
#######################################################################
# logmsg is our general message logging subroutine.
#
sub logmsg {
if($singletest_bufferedrunner) {
# Logs are currently being buffered
return singletest_logmsg(@_);
}
for(@_) {
my $line = $_;
if(!$line) {
next;
}
if ($is_wsl) {
# use \r\n for WSL shell
$line =~ s/\r?\n$/\r\n/g;
}
print "$line";
}
}
#######################################################################
# enable logmsg buffering for the given runner ID
#
sub logmsg_bufferfortest {
my ($runnerid)=@_;
if($jobs) {
# Only enable buffering in multiprocess mode
$singletest_bufferedrunner = $runnerid;
}
}
#######################################################################
# Store a log message in a buffer for this test
# The messages can then be displayed all at once at the end of the test
# which prevents messages from different tests from being interleaved.
sub singletest_logmsg {
if(!exists $singletest_logs{$singletest_bufferedrunner}) {
# initialize to a reference to an empty anonymous array
$singletest_logs{$singletest_bufferedrunner} = [];
}
my $logsref = $singletest_logs{$singletest_bufferedrunner};
push @$logsref, @_;
}
#######################################################################
# Stop buffering log messages, but don't touch them
sub singletest_unbufferlogs {
undef $singletest_bufferedrunner;
}
#######################################################################
# Clear the buffered log messages & stop buffering after returning them
sub singletest_dumplogs {
if(!defined $singletest_bufferedrunner) {
# probably not multiprocess mode and logs weren't buffered
return undef;
}
my $logsref = $singletest_logs{$singletest_bufferedrunner};
my $msg = join("", @$logsref);
delete $singletest_logs{$singletest_bufferedrunner};
singletest_unbufferlogs();
return $msg;
}
sub catch_zap {
my $signame = shift;
print "runtests.pl received SIG$signame, exiting\r\n";
$globalabort = 1;
}
$SIG{INT} = \&catch_zap;
$SIG{TERM} = \&catch_zap;
sub catch_usr1 {
print "runtests.pl internal state:\r\n";
print scalar(%runnersrunning) . " busy test runner(s) of " . scalar(keys %runnerids) . "\r\n";
foreach my $rid (sort(keys(%runnersrunning))) {
my $runnernum = "unknown";
foreach my $rnum (keys %runnerids) {
if($runnerids{$rnum} == $rid) {
$runnernum = $rnum;
last;
}
}
print "Runner $runnernum (id $rid) running test $runnersrunning{$rid} in state $singletest_state{$rid}\r\n";
}
}
eval {
# some msys2 perl versions don't define SIGUSR1
$SIG{USR1} = \&catch_usr1;
};
$SIG{PIPE} = 'IGNORE'; # these errors are captured in the read/write calls
##########################################################################
# Clear all possible '*_proxy' environment variables for various protocols
# to prevent them to interfere with our testing!
foreach my $protocol (('ftp', 'http', 'ftps', 'https', 'no', 'all')) {
my $proxy = "${protocol}_proxy";
# clear lowercase version
delete $ENV{$proxy} if($ENV{$proxy});
# clear uppercase version
delete $ENV{uc($proxy)} if($ENV{uc($proxy)});
}
# make sure we don't get affected by other variables that control our
# behavior
delete $ENV{'SSL_CERT_DIR'} if($ENV{'SSL_CERT_DIR'});
delete $ENV{'SSL_CERT_PATH'} if($ENV{'SSL_CERT_PATH'});
delete $ENV{'CURL_CA_BUNDLE'} if($ENV{'CURL_CA_BUNDLE'});
# provide defaults from our config file for ENV vars not explicitly
# set by the caller
if (open(my $fd, "<", "config")) {
while(my $line = <$fd>) {
next if ($line =~ /^#/);
chomp $line;
my ($name, $val) = split(/\s*:\s*/, $line, 2);
$ENV{$name} = $val if(!$ENV{$name});
}
close($fd);
}
# Check if we have nghttpx available and if it talks http/3
my $nghttpx_h3 = 0;
if (!$ENV{"NGHTTPX"}) {
$ENV{"NGHTTPX"} = checktestcmd("nghttpx");
}
if ($ENV{"NGHTTPX"}) {
my $nghttpx_version=join(' ', `"$ENV{'NGHTTPX'}" -v 2>/dev/null`);
$nghttpx_h3 = $nghttpx_version =~ /nghttp3\//;
chomp $nghttpx_h3;
}
#######################################################################
# Get the list of tests that the tests/data/Makefile.am knows about!
#
my $disttests = "";
sub get_disttests {
# If a non-default $TESTDIR is being used there may not be any
# Makefile.inc in which case there's nothing to do.
open(my $dh, "<", "$TESTDIR/Makefile.inc") or return;
while(<$dh>) {
chomp $_;
if(($_ =~ /^#/) ||($_ !~ /test/)) {
next;
}
$disttests .= $_;
}
close($dh);
}
#######################################################################
# Remove all files in the specified directory
#
sub cleardir {
my $dir = $_[0];
my $done = 1; # success
my $file;
# Get all files
opendir(my $dh, $dir) ||
return 0; # can't open dir
while($file = readdir($dh)) {
# Don't clear the $PIDDIR or $LOCKDIR since those need to live beyond
# one test
if(($file !~ /^(\.|\.\.)\z/) &&
"$file" ne $PIDDIR && "$file" ne $LOCKDIR) {
if(-d "$dir/$file") {
if(!cleardir("$dir/$file")) {
$done = 0;
}
if(!rmdir("$dir/$file")) {
$done = 0;
}
}
else {
# Ignore stunnel since we cannot do anything about its locks
if(!unlink("$dir/$file") && "$file" !~ /_stunnel\.log$/) {
$done = 0;
}
}
}
}
closedir $dh;
return $done;
}
#######################################################################
# Given two array references, this function will store them in two temporary
# files, run 'diff' on them, store the result and return the diff output!
sub showdiff {
my ($logdir, $firstref, $secondref)=@_;
my $file1="$logdir/check-generated";
my $file2="$logdir/check-expected";
open(my $temp, ">", "$file1") || die "Failure writing diff file";
for(@$firstref) {
my $l = $_;
$l =~ s/\r/[CR]/g;
$l =~ s/\n/[LF]/g;
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
print $temp $l;
print $temp "\n";
}
close($temp) || die "Failure writing diff file";
open($temp, ">", "$file2") || die "Failure writing diff file";
for(@$secondref) {
my $l = $_;
$l =~ s/\r/[CR]/g;
$l =~ s/\n/[LF]/g;
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
print $temp $l;
print $temp "\n";
}
close($temp) || die "Failure writing diff file";
my @out = `diff -u $file2 $file1 2>/dev/null`;
if(!$out[0]) {
@out = `diff -c $file2 $file1 2>/dev/null`;
}
return @out;
}
#######################################################################
# compare test results with the expected output, we might filter off
# some pattern that is allowed to differ, output test results
#
sub compare {
my ($runnerid, $testnum, $testname, $subject, $firstref, $secondref)=@_;
my $result = compareparts($firstref, $secondref);
if($result) {
# timestamp test result verification end
$timevrfyend{$testnum} = Time::HiRes::time();
if(!$short) {
logmsg "\n $testnum: $subject FAILED:\n";
my $logdir = getrunnerlogdir($runnerid);
logmsg showdiff($logdir, $firstref, $secondref);
}
elsif(!$automakestyle) {
logmsg "FAILED\n";
}
else {
# automakestyle
logmsg "FAIL: $testnum - $testname - $subject\n";
}
}
return $result;
}
#######################################################################
# Parse and store the protocols in curl's Protocols: line
sub parseprotocols {
my ($line)=@_;
@protocols = split(' ', lc($line));
# Generate a "proto-ipv6" version of each protocol to match the
# IPv6 <server> name and a "proto-unix" to match the variant which
# uses Unix domain sockets. This works even if support isn't
# compiled in because the <features> test will fail.
push @protocols, map(("$_-ipv6", "$_-unix"), @protocols);
# 'http-proxy' is used in test cases to do CONNECT through
push @protocols, 'http-proxy';
# 'none' is used in test cases to mean no server
push @protocols, 'none';
}
#######################################################################
# Check & display information about curl and the host the test suite runs on.
# Information to do with servers is displayed in displayserverfeatures, after
# the server initialization is performed.
sub checksystemfeatures {
my $feat;
my $curl;
my $libcurl;
my $versretval;
my $versnoexec;
my @version=();
my @disabled;
my $dis = "";
my $curlverout="$LOGDIR/curlverout.log";
my $curlvererr="$LOGDIR/curlvererr.log";
my $versioncmd=shell_quote($CURL) . " --version 1>$curlverout 2>$curlvererr";
unlink($curlverout);
unlink($curlvererr);
$versretval = runclient($versioncmd);
$versnoexec = $!;
open(my $versout, "<", "$curlverout");
@version = <$versout>;
close($versout);
open(my $disabledh, "-|", "server/disabled".exe_ext('TOOL'));
@disabled = <$disabledh>;
close($disabledh);
if($disabled[0]) {
s/[\r\n]//g for @disabled;
$dis = join(", ", @disabled);
}
$resolver="stock";
for(@version) {
chomp;
if($_ =~ /^curl ([^ ]*)/) {
$curl = $_;
$CURLVERSION = $1;
$curl =~ s/^(.*)(libcurl.*)/$1/g || die "Failure determining curl binary version";
$libcurl = $2;
if($curl =~ /linux|bsd|solaris/) {
# system support LD_PRELOAD; may be disabled later
$feature{"ld_preload"} = 1;
}
if($curl =~ /win32|Windows|mingw(32|64)/) {
# This is a Windows MinGW build or native build, we need to use
# Win32-style path.
$pwd = sys_native_current_path();
$has_textaware = 1;
$feature{"win32"} = 1;
# set if built with MinGW (as opposed to MinGW-w64)
$feature{"MinGW"} = 1 if ($curl =~ /-pc-mingw32/);
}
if ($libcurl =~ /\s(winssl|schannel)\b/i) {
$feature{"Schannel"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\sopenssl\b/i) {
$feature{"OpenSSL"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\sgnutls\b/i) {
$feature{"GnuTLS"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\srustls-ffi\b/i) {
$feature{"rustls"} = 1;
}
elsif ($libcurl =~ /\swolfssl\b/i) {
$feature{"wolfssl"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\sbearssl\b/i) {
$feature{"bearssl"} = 1;
}
elsif ($libcurl =~ /\ssecuretransport\b/i) {
$feature{"sectransp"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\sBoringSSL\b/i) {
# OpenSSL compatible API
$feature{"OpenSSL"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\slibressl\b/i) {
# OpenSSL compatible API
$feature{"OpenSSL"} = 1;
$feature{"SSLpinning"} = 1;
}
elsif ($libcurl =~ /\smbedTLS\b/i) {
$feature{"mbedtls"} = 1;
$feature{"SSLpinning"} = 1;
}
if ($libcurl =~ /ares/i) {
$feature{"c-ares"} = 1;
$resolver="c-ares";
}
if ($libcurl =~ /Hyper/i) {
$feature{"hyper"} = 1;
}
if ($libcurl =~ /nghttp2/i) {
# nghttp2 supports h2c, hyper does not
$feature{"h2c"} = 1;
}
if ($libcurl =~ /libssh2/i) {
$feature{"libssh2"} = 1;
}
if ($libcurl =~ /libssh\/([0-9.]*)\//i) {
$feature{"libssh"} = 1;
if($1 =~ /(\d+)\.(\d+).(\d+)/) {
my $v = $1 * 100 + $2 * 10 + $3;
if($v < 94) {
# before 0.9.4
$feature{"oldlibssh"} = 1;
}
}
}
if ($libcurl =~ /wolfssh/i) {
$feature{"wolfssh"} = 1;
}
}
elsif($_ =~ /^Protocols: (.*)/i) {
# these are the protocols compiled in to this libcurl
parseprotocols($1);
}
elsif($_ =~ /^Features: (.*)/i) {
$feat = $1;
# built with memory tracking support (--enable-curldebug); may be disabled later
$feature{"TrackMemory"} = $feat =~ /TrackMemory/i;
# curl was built with --enable-debug
$feature{"debug"} = $feat =~ /debug/i;
# ssl enabled
$feature{"SSL"} = $feat =~ /SSL/i;
# multiple ssl backends available.
$feature{"MultiSSL"} = $feat =~ /MultiSSL/i;
# large file support
$feature{"large_file"} = $feat =~ /Largefile/i;
# IDN support
$feature{"idn"} = $feat =~ /IDN/i;
# IPv6 support
$feature{"ipv6"} = $feat =~ /IPv6/i;
# Unix sockets support
$feature{"unix-sockets"} = $feat =~ /UnixSockets/i;
# libz compression
$feature{"libz"} = $feat =~ /libz/i;
# Brotli compression
$feature{"brotli"} = $feat =~ /brotli/i;
# Zstd compression
$feature{"zstd"} = $feat =~ /zstd/i;
# NTLM enabled
$feature{"NTLM"} = $feat =~ /NTLM/i;
# NTLM delegation to winbind daemon ntlm_auth helper enabled
$feature{"NTLM_WB"} = $feat =~ /NTLM_WB/i;
# SSPI enabled
$feature{"SSPI"} = $feat =~ /SSPI/i;
# GSS-API enabled
$feature{"GSS-API"} = $feat =~ /GSS-API/i;
# Kerberos enabled
$feature{"Kerberos"} = $feat =~ /Kerberos/i;
# SPNEGO enabled
$feature{"SPNEGO"} = $feat =~ /SPNEGO/i;
# CharConv enabled
$feature{"CharConv"} = $feat =~ /CharConv/i;
# TLS-SRP enabled
$feature{"TLS-SRP"} = $feat =~ /TLS-SRP/i;
# PSL enabled
$feature{"PSL"} = $feat =~ /PSL/i;
# alt-svc enabled
$feature{"alt-svc"} = $feat =~ /alt-svc/i;
# HSTS support
$feature{"HSTS"} = $feat =~ /HSTS/i;
if($feat =~ /AsynchDNS/i) {
if(!$feature{"c-ares"}) {
# this means threaded resolver
$feature{"threaded-resolver"} = 1;
$resolver="threaded";
}
}
# http2 enabled
$feature{"http/2"} = $feat =~ /HTTP2/;
if($feature{"http/2"}) {
push @protocols, 'http/2';
}
# http3 enabled
$feature{"http/3"} = $feat =~ /HTTP3/;
if($feature{"http/3"}) {
push @protocols, 'http/3';
}
# https proxy support
$feature{"https-proxy"} = $feat =~ /HTTPS-proxy/;
if($feature{"https-proxy"}) {
# 'https-proxy' is used as "server" so consider it a protocol
push @protocols, 'https-proxy';
}
# UNICODE support
$feature{"Unicode"} = $feat =~ /Unicode/i;
# Thread-safe init
$feature{"threadsafe"} = $feat =~ /threadsafe/i;
}
#
# Test harness currently uses a non-stunnel server in order to
# run HTTP TLS-SRP tests required when curl is built with https
# protocol support and TLS-SRP feature enabled. For convenience
# 'httptls' may be included in the test harness protocols array
# to differentiate this from classic stunnel based 'https' test
# harness server.
#
if($feature{"TLS-SRP"}) {
my $add_httptls;
for(@protocols) {
if($_ =~ /^https(-ipv6|)$/) {
$add_httptls=1;
last;
}
}
if($add_httptls && (! grep /^httptls$/, @protocols)) {
push @protocols, 'httptls';
push @protocols, 'httptls-ipv6';
}
}
}
if(!$curl) {
logmsg "unable to get curl's version, further details are:\n";
logmsg "issued command: \n";
logmsg "$versioncmd \n";
if ($versretval == -1) {
logmsg "command failed with: \n";
logmsg "$versnoexec \n";
}
elsif ($versretval & 127) {
logmsg sprintf("command died with signal %d, and %s coredump.\n",
($versretval & 127), ($versretval & 128)?"a":"no");
}
else {
logmsg sprintf("command exited with value %d \n", $versretval >> 8);
}
logmsg "contents of $curlverout: \n";
displaylogcontent("$curlverout");
logmsg "contents of $curlvererr: \n";
displaylogcontent("$curlvererr");
die "couldn't get curl's version";
}
if(-r "../lib/curl_config.h") {
open(my $conf, "<", "../lib/curl_config.h");
while(<$conf>) {
if($_ =~ /^\#define HAVE_GETRLIMIT/) {
# set if system has getrlimit()
$feature{"getrlimit"} = 1;
}
}
close($conf);
}
# allow this feature only if debug mode is disabled
$feature{"ld_preload"} = $feature{"ld_preload"} && !$feature{"debug"};
if($feature{"ipv6"}) {
# client has IPv6 support
# check if the HTTP server has it!
my $cmd = "server/sws".exe_ext('SRV')." --version";
my @sws = `$cmd`;
if($sws[0] =~ /IPv6/) {
# HTTP server has IPv6 support!
$http_ipv6 = 1;
}
# check if the FTP server has it!
$cmd = "server/sockfilt".exe_ext('SRV')." --version";
@sws = `$cmd`;
if($sws[0] =~ /IPv6/) {
# FTP server has IPv6 support!
$ftp_ipv6 = 1;
}
}
if($feature{"unix-sockets"}) {
# client has Unix sockets support, check whether the HTTP server has it
my $cmd = "server/sws".exe_ext('SRV')." --version";
my @sws = `$cmd`;
$http_unix = 1 if($sws[0] =~ /unix/);
}
open(my $manh, "-|", shell_quote($CURL) . " -M 2>&1");
while(my $s = <$manh>) {
if($s =~ /built-in manual was disabled at build-time/) {
$feature{"manual"} = 0;
last;
}
$feature{"manual"} = 1;
last;
}
close($manh);
$feature{"unittest"} = $feature{"debug"};
$feature{"nghttpx"} = !!$ENV{'NGHTTPX'};
$feature{"nghttpx-h3"} = !!$nghttpx_h3;
#
# strings that must exactly match the names used in server/disabled.c
#
$feature{"cookies"} = 1;
# Use this as a proxy for any cryptographic authentication
$feature{"crypto"} = $feature{"NTLM"} || $feature{"Kerberos"} || $feature{"SPNEGO"};
$feature{"DoH"} = 1;
$feature{"HTTP-auth"} = 1;
$feature{"Mime"} = 1;
$feature{"form-api"} = 1;
$feature{"netrc"} = 1;
$feature{"parsedate"} = 1;
$feature{"proxy"} = 1;
$feature{"shuffle-dns"} = 1;
$feature{"typecheck"} = 1;
$feature{"verbose-strings"} = 1;
$feature{"wakeup"} = 1;
$feature{"headers-api"} = 1;
$feature{"xattr"} = 1;
$feature{"large-time"} = 1;
$feature{"sha512-256"} = 1;
# make each protocol an enabled "feature"
for my $p (@protocols) {
$feature{$p} = 1;
}
# 'socks' was once here but is now removed
$has_shared = `sh $CURLCONFIG --built-shared`;
chomp $has_shared;
$has_shared = $has_shared eq "yes";
if(!$feature{"TrackMemory"} && $torture) {
die "can't run torture tests since curl was built without ".
"TrackMemory feature (--enable-curldebug)";
}
my $hostname=join(' ', runclientoutput("hostname"));
my $hosttype=join(' ', runclientoutput("uname -a"));
my $hostos=$^O;
# display summary information about curl and the test host
logmsg ("********* System characteristics ******** \n",
"* $curl\n",
"* $libcurl\n",
"* Features: $feat\n",
"* Disabled: $dis\n",
"* Host: $hostname",
"* System: $hosttype",
"* OS: $hostos\n");
if($jobs) {
# Only show if not the default for now
logmsg "* Jobs: $jobs\n";
}
if($feature{"TrackMemory"} && $feature{"threaded-resolver"}) {
logmsg("*\n",
"*** DISABLES memory tracking when using threaded resolver\n",
"*\n");
}
logmsg sprintf("* Env: %s%s%s", $valgrind?"Valgrind ":"",
$run_event_based?"event-based ":"",
$nghttpx_h3);
logmsg sprintf("%s\n", $libtool?"Libtool ":"");
logmsg ("* Seed: $randseed\n");
# Disable memory tracking when using threaded resolver
$feature{"TrackMemory"} = $feature{"TrackMemory"} && !$feature{"threaded-resolver"};
# toggle off the features that were disabled in the build
for my $d(@disabled) {
$feature{$d} = 0;
}
}
#######################################################################
# display information about server features
#
sub displayserverfeatures {
logmsg sprintf("* Servers: %s", $stunnel?"SSL ":"");
logmsg sprintf("%s", $http_ipv6?"HTTP-IPv6 ":"");
logmsg sprintf("%s", $http_unix?"HTTP-unix ":"");
logmsg sprintf("%s\n", $ftp_ipv6?"FTP-IPv6 ":"");
logmsg "***************************************** \n";
}
#######################################################################
# Provide time stamps for single test skipped events
#
sub timestampskippedevents {
my $testnum = $_[0];
return if((not defined($testnum)) || ($testnum < 1));
if($timestats) {
if($timevrfyend{$testnum}) {
return;
}
elsif($timesrvrlog{$testnum}) {
$timevrfyend{$testnum} = $timesrvrlog{$testnum};
return;
}
elsif($timetoolend{$testnum}) {
$timevrfyend{$testnum} = $timetoolend{$testnum};
$timesrvrlog{$testnum} = $timetoolend{$testnum};
}
elsif($timetoolini{$testnum}) {
$timevrfyend{$testnum} = $timetoolini{$testnum};
$timesrvrlog{$testnum} = $timetoolini{$testnum};
$timetoolend{$testnum} = $timetoolini{$testnum};
}
elsif($timesrvrend{$testnum}) {
$timevrfyend{$testnum} = $timesrvrend{$testnum};
$timesrvrlog{$testnum} = $timesrvrend{$testnum};
$timetoolend{$testnum} = $timesrvrend{$testnum};
$timetoolini{$testnum} = $timesrvrend{$testnum};
}
elsif($timesrvrini{$testnum}) {
$timevrfyend{$testnum} = $timesrvrini{$testnum};
$timesrvrlog{$testnum} = $timesrvrini{$testnum};
$timetoolend{$testnum} = $timesrvrini{$testnum};
$timetoolini{$testnum} = $timesrvrini{$testnum};
$timesrvrend{$testnum} = $timesrvrini{$testnum};
}
elsif($timeprepini{$testnum}) {
$timevrfyend{$testnum} = $timeprepini{$testnum};
$timesrvrlog{$testnum} = $timeprepini{$testnum};
$timetoolend{$testnum} = $timeprepini{$testnum};
$timetoolini{$testnum} = $timeprepini{$testnum};
$timesrvrend{$testnum} = $timeprepini{$testnum};
$timesrvrini{$testnum} = $timeprepini{$testnum};
}
}
}
# Setup CI Test Run
sub citest_starttestrun {
if(azure_check_environment()) {
$AZURE_RUN_ID = azure_create_test_run($ACURL);
logmsg "Azure Run ID: $AZURE_RUN_ID\n" if ($verbose);
}
# Appveyor doesn't require anything here
}
# Register the test case with the CI runner
sub citest_starttest {
my $testnum = $_[0];
# get the name of the test early
my $testname= (getpart("client", "name"))[0];
chomp $testname;
# create test result in CI services
if(azure_check_environment() && $AZURE_RUN_ID) {
$AZURE_RESULT_ID = azure_create_test_result($ACURL, $AZURE_RUN_ID, $testnum, $testname);
}
elsif(appveyor_check_environment()) {
appveyor_create_test_result($ACURL, $testnum, $testname);
}
}
# Submit the test case result with the CI runner
sub citest_finishtest {
my ($testnum, $error) = @_;
# update test result in CI services
if(azure_check_environment() && $AZURE_RUN_ID && $AZURE_RESULT_ID) {
$AZURE_RESULT_ID = azure_update_test_result($ACURL, $AZURE_RUN_ID, $AZURE_RESULT_ID, $testnum, $error,
$timeprepini{$testnum}, $timevrfyend{$testnum});
}
elsif(appveyor_check_environment()) {
appveyor_update_test_result($ACURL, $testnum, $error, $timeprepini{$testnum}, $timevrfyend{$testnum});
}
}
# Complete CI test run
sub citest_finishtestrun {
if(azure_check_environment() && $AZURE_RUN_ID) {
$AZURE_RUN_ID = azure_update_test_run($ACURL, $AZURE_RUN_ID);
}
# Appveyor doesn't require anything here
}
# add one set of test timings from the runner to global set
sub updatetesttimings {
my ($testnum, %testtimings)=@_;
if(defined $testtimings{"timeprepini"}) {
$timeprepini{$testnum} = $testtimings{"timeprepini"};
}
if(defined $testtimings{"timesrvrini"}) {
$timesrvrini{$testnum} = $testtimings{"timesrvrini"};
}
if(defined $testtimings{"timesrvrend"}) {
$timesrvrend{$testnum} = $testtimings{"timesrvrend"};
}
if(defined $testtimings{"timetoolini"}) {
$timetoolini{$testnum} = $testtimings{"timetoolini"};
}
if(defined $testtimings{"timetoolend"}) {
$timetoolend{$testnum} = $testtimings{"timetoolend"};
}
if(defined $testtimings{"timesrvrlog"}) {
$timesrvrlog{$testnum} = $testtimings{"timesrvrlog"};
}
}
#######################################################################
# Return the log directory for the given test runner
sub getrunnernumlogdir {
my $runnernum = $_[0];
return $jobs > 1 ? "$LOGDIR/$runnernum" : $LOGDIR;
}
#######################################################################
# Return the log directory for the given test runner ID