runtests.pl 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. # Experimental hooks are available to run tests remotely on machines that
  26. # are able to run curl but are unable to run the test harness.
  27. # The following sections need to be modified:
  28. #
  29. # $HOSTIP, $HOST6IP - Set to the address of the host running the test suite
  30. # $CLIENTIP, $CLIENT6IP - Set to the address of the host running curl
  31. # runclient, runclientoutput - Modify to copy all the files in the log/
  32. # directory to the system running curl, run the given command remotely
  33. # and save the return code or returned stdout (respectively), then
  34. # copy all the files from the remote system's log/ directory back to
  35. # the host running the test suite. This can be done a few ways, such
  36. # as using scp & ssh, rsync & telnet, or using a NFS shared directory
  37. # and ssh.
  38. #
  39. # 'make && make test' needs to be done on both machines before making the
  40. # above changes and running runtests.pl manually. In the shared NFS case,
  41. # the contents of the tests/server/ directory must be from the host
  42. # running the test suite, while the rest must be from the host running curl.
  43. #
  44. # Note that even with these changes a number of tests will still fail (mainly
  45. # to do with cookies, those that set environment variables, or those that
  46. # do more than touch the file system in a <precheck> or <postcheck>
  47. # section). These can be added to the $TESTCASES line below,
  48. # e.g. $TESTCASES="!8 !31 !63 !cookies..."
  49. #
  50. # Finally, to properly support -g and -n, checktestcmd needs to change
  51. # to check the remote system's PATH, and the places in the code where
  52. # the curl binary is read directly to determine its type also need to be
  53. # fixed. As long as the -g option is never given, and the -n is always
  54. # given, this won't be a problem.
  55. use strict;
  56. # Promote all warnings to fatal
  57. use warnings FATAL => 'all';
  58. use 5.006;
  59. # These should be the only variables that might be needed to get edited:
  60. BEGIN {
  61. # Define srcdir to the location of the tests source directory. This is
  62. # usually set by the Makefile, but for out-of-tree builds with direct
  63. # invocation of runtests.pl, it may not be set.
  64. if(!defined $ENV{'srcdir'}) {
  65. use File::Basename;
  66. $ENV{'srcdir'} = dirname(__FILE__);
  67. }
  68. push(@INC, $ENV{'srcdir'});
  69. # run time statistics needs Time::HiRes
  70. eval {
  71. no warnings "all";
  72. require Time::HiRes;
  73. import Time::HiRes qw( time );
  74. }
  75. }
  76. use Digest::MD5 qw(md5);
  77. use List::Util 'sum';
  78. use pathhelp qw(
  79. exe_ext
  80. sys_native_current_path
  81. );
  82. use processhelp qw(
  83. portable_sleep
  84. );
  85. use appveyor;
  86. use azure;
  87. use getpart; # array functions
  88. use servers;
  89. use valgrind; # valgrind report parser
  90. use globalconfig;
  91. use runner;
  92. use testutil;
  93. my %custom_skip_reasons;
  94. my $ACURL=$VCURL; # what curl binary to use to talk to APIs (relevant for CI)
  95. # ACURL is handy to set to the system one for reliability
  96. my $CURLCONFIG="../curl-config"; # curl-config from current build
  97. # Normally, all test cases should be run, but at times it is handy to
  98. # simply run a particular one:
  99. my $TESTCASES="all";
  100. # To run specific test cases, set them like:
  101. # $TESTCASES="1 2 3 7 8";
  102. #######################################################################
  103. # No variables below this point should need to be modified
  104. #
  105. my $libtool;
  106. my $repeat = 0;
  107. my $start; # time at which testing started
  108. my $uname_release = `uname -r`;
  109. my $is_wsl = $uname_release =~ /Microsoft$/;
  110. my $http_ipv6; # set if HTTP server has IPv6 support
  111. my $http_unix; # set if HTTP server has Unix sockets support
  112. my $ftp_ipv6; # set if FTP server has IPv6 support
  113. my $resolver; # name of the resolver backend (for human presentation)
  114. my $has_textaware; # set if running on a system that has a text mode concept
  115. # on files. Windows for example
  116. my %skipped; # skipped{reason}=counter, reasons for skip
  117. my @teststat; # teststat[testnum]=reason, reasons for skip
  118. my %disabled_keywords; # key words of tests to skip
  119. my %ignored_keywords; # key words of tests to ignore results
  120. my %enabled_keywords; # key words of tests to run
  121. my %disabled; # disabled test cases
  122. my %ignored; # ignored results of test cases
  123. my $timestats; # time stamping and stats generation
  124. my $fullstats; # show time stats for every single test
  125. my %timeprepini; # timestamp for each test preparation start
  126. #######################################################################
  127. # variables that command line options may set
  128. #
  129. my $short;
  130. my $no_debuginfod;
  131. my $keepoutfiles; # keep stdout and stderr files after tests
  132. my $clearlocks; # force removal of files by killing locking processes
  133. my $postmortem; # display detailed info about failed tests
  134. my $run_disabled; # run the specific tests even if listed in DISABLED
  135. my $scrambleorder;
  136. my $randseed = 0;
  137. # Azure Pipelines specific variables
  138. my $AZURE_RUN_ID = 0;
  139. my $AZURE_RESULT_ID = 0;
  140. #######################################################################
  141. # logmsg is our general message logging subroutine.
  142. #
  143. sub logmsg {
  144. for(@_) {
  145. my $line = $_;
  146. if ($is_wsl) {
  147. # use \r\n for WSL shell
  148. $line =~ s/\r?\n$/\r\n/g;
  149. }
  150. print "$line";
  151. }
  152. }
  153. # enable memory debugging if curl is compiled with it
  154. $ENV{'CURL_MEMDEBUG'} = $memdump;
  155. $ENV{'CURL_ENTROPY'}="12345678";
  156. $ENV{'CURL_FORCETIME'}=1; # for debug NTLM magic
  157. $ENV{'CURL_GLOBAL_INIT'}=1; # debug curl_global_init/cleanup use
  158. $ENV{'HOME'}=$pwd;
  159. $ENV{'CURL_HOME'}=$ENV{'HOME'};
  160. $ENV{'XDG_CONFIG_HOME'}=$ENV{'HOME'};
  161. $ENV{'COLUMNS'}=79; # screen width!
  162. sub catch_zap {
  163. my $signame = shift;
  164. logmsg "runtests.pl received SIG$signame, exiting\n";
  165. stopservers($verbose);
  166. die "Somebody sent me a SIG$signame";
  167. }
  168. $SIG{INT} = \&catch_zap;
  169. $SIG{TERM} = \&catch_zap;
  170. ##########################################################################
  171. # Clear all possible '*_proxy' environment variables for various protocols
  172. # to prevent them to interfere with our testing!
  173. foreach my $protocol (('ftp', 'http', 'ftps', 'https', 'no', 'all')) {
  174. my $proxy = "${protocol}_proxy";
  175. # clear lowercase version
  176. delete $ENV{$proxy} if($ENV{$proxy});
  177. # clear uppercase version
  178. delete $ENV{uc($proxy)} if($ENV{uc($proxy)});
  179. }
  180. # make sure we don't get affected by other variables that control our
  181. # behavior
  182. delete $ENV{'SSL_CERT_DIR'} if($ENV{'SSL_CERT_DIR'});
  183. delete $ENV{'SSL_CERT_PATH'} if($ENV{'SSL_CERT_PATH'});
  184. delete $ENV{'CURL_CA_BUNDLE'} if($ENV{'CURL_CA_BUNDLE'});
  185. # provide defaults from our config file for ENV vars not explicitly
  186. # set by the caller
  187. if (open(my $fd, "<", "config")) {
  188. while(my $line = <$fd>) {
  189. next if ($line =~ /^#/);
  190. chomp $line;
  191. my ($name, $val) = split(/\s*:\s*/, $line, 2);
  192. $ENV{$name} = $val if(!$ENV{$name});
  193. }
  194. close($fd);
  195. }
  196. # Check if we have nghttpx available and if it talks http/3
  197. my $nghttpx_h3 = 0;
  198. if (!$ENV{"NGHTTPX"}) {
  199. $ENV{"NGHTTPX"} = checktestcmd("nghttpx");
  200. }
  201. if ($ENV{"NGHTTPX"}) {
  202. my $nghttpx_version=join(' ', `"$ENV{'NGHTTPX'} -v 2>/dev/null"`);
  203. $nghttpx_h3 = $nghttpx_version =~ /nghttp3\//;
  204. chomp $nghttpx_h3;
  205. }
  206. #######################################################################
  207. # Get the list of tests that the tests/data/Makefile.am knows about!
  208. #
  209. my $disttests = "";
  210. sub get_disttests {
  211. # If a non-default $TESTDIR is being used there may not be any
  212. # Makefile.inc in which case there's nothing to do.
  213. open(my $dh, "<", "$TESTDIR/Makefile.inc") or return;
  214. while(<$dh>) {
  215. chomp $_;
  216. if(($_ =~ /^#/) ||($_ !~ /test/)) {
  217. next;
  218. }
  219. $disttests .= $_;
  220. }
  221. close($dh);
  222. }
  223. #######################################################################
  224. # Remove all files in the specified directory
  225. #
  226. sub cleardir {
  227. my $dir = $_[0];
  228. my $done = 1; # success
  229. my $file;
  230. # Get all files
  231. opendir(my $dh, $dir) ||
  232. return 0; # can't open dir
  233. while($file = readdir($dh)) {
  234. # Don't clear the $PIDDIR since those need to live beyond one test
  235. if(($file !~ /^(\.|\.\.)\z/) && "$dir/$file" ne $PIDDIR) {
  236. if(-d "$dir/$file") {
  237. if(!cleardir("$dir/$file")) {
  238. $done = 0;
  239. }
  240. if(!rmdir("$dir/$file")) {
  241. $done = 0;
  242. }
  243. }
  244. else {
  245. # Ignore stunnel since we cannot do anything about its locks
  246. if(!unlink("$dir/$file") && "$file" !~ /_stunnel\.log$/) {
  247. $done = 0;
  248. }
  249. }
  250. }
  251. }
  252. closedir $dh;
  253. return $done;
  254. }
  255. #######################################################################
  256. # compare test results with the expected output, we might filter off
  257. # some pattern that is allowed to differ, output test results
  258. #
  259. sub compare {
  260. my ($testnum, $testname, $subject, $firstref, $secondref)=@_;
  261. my $result = compareparts($firstref, $secondref);
  262. if($result) {
  263. # timestamp test result verification end
  264. $timevrfyend{$testnum} = Time::HiRes::time();
  265. if(!$short) {
  266. logmsg "\n $testnum: $subject FAILED:\n";
  267. logmsg showdiff($LOGDIR, $firstref, $secondref);
  268. }
  269. elsif(!$automakestyle) {
  270. logmsg "FAILED\n";
  271. }
  272. else {
  273. # automakestyle
  274. logmsg "FAIL: $testnum - $testname - $subject\n";
  275. }
  276. }
  277. return $result;
  278. }
  279. #######################################################################
  280. # Check & display information about curl and the host the test suite runs on.
  281. # Information to do with servers is displayed in displayserverfeatures, after
  282. # the server initialization is performed.
  283. sub checksystemfeatures {
  284. my $feat;
  285. my $curl;
  286. my $libcurl;
  287. my $versretval;
  288. my $versnoexec;
  289. my @version=();
  290. my @disabled;
  291. my $dis = "";
  292. my $curlverout="$LOGDIR/curlverout.log";
  293. my $curlvererr="$LOGDIR/curlvererr.log";
  294. my $versioncmd="$CURL --version 1>$curlverout 2>$curlvererr";
  295. unlink($curlverout);
  296. unlink($curlvererr);
  297. $versretval = runclient($versioncmd);
  298. $versnoexec = $!;
  299. open(my $versout, "<", "$curlverout");
  300. @version = <$versout>;
  301. close($versout);
  302. open(my $disabledh, "-|", "server/disabled".exe_ext('TOOL'));
  303. @disabled = <$disabledh>;
  304. close($disabledh);
  305. if($disabled[0]) {
  306. s/[\r\n]//g for @disabled;
  307. $dis = join(", ", @disabled);
  308. }
  309. $resolver="stock";
  310. for(@version) {
  311. chomp;
  312. if($_ =~ /^curl ([^ ]*)/) {
  313. $curl = $_;
  314. $CURLVERSION = $1;
  315. $curl =~ s/^(.*)(libcurl.*)/$1/g || die "Failure determining curl binary version";
  316. $libcurl = $2;
  317. if($curl =~ /linux|bsd|solaris/) {
  318. # system support LD_PRELOAD; may be disabled later
  319. $feature{"ld_preload"} = 1;
  320. }
  321. if($curl =~ /win32|Windows|mingw(32|64)/) {
  322. # This is a Windows MinGW build or native build, we need to use
  323. # Win32-style path.
  324. $pwd = sys_native_current_path();
  325. $has_textaware = 1;
  326. $feature{"win32"} = 1;
  327. # set if built with MinGW (as opposed to MinGW-w64)
  328. $feature{"MinGW"} = 1 if ($curl =~ /-pc-mingw32/);
  329. }
  330. if ($libcurl =~ /\s(winssl|schannel)\b/i) {
  331. $feature{"Schannel"} = 1;
  332. $feature{"SSLpinning"} = 1;
  333. }
  334. elsif ($libcurl =~ /\sopenssl\b/i) {
  335. $feature{"OpenSSL"} = 1;
  336. $feature{"SSLpinning"} = 1;
  337. }
  338. elsif ($libcurl =~ /\sgnutls\b/i) {
  339. $feature{"GnuTLS"} = 1;
  340. $feature{"SSLpinning"} = 1;
  341. }
  342. elsif ($libcurl =~ /\srustls-ffi\b/i) {
  343. $feature{"rustls"} = 1;
  344. }
  345. elsif ($libcurl =~ /\snss\b/i) {
  346. $feature{"NSS"} = 1;
  347. $feature{"SSLpinning"} = 1;
  348. }
  349. elsif ($libcurl =~ /\swolfssl\b/i) {
  350. $feature{"wolfssl"} = 1;
  351. $feature{"SSLpinning"} = 1;
  352. }
  353. elsif ($libcurl =~ /\sbearssl\b/i) {
  354. $feature{"bearssl"} = 1;
  355. }
  356. elsif ($libcurl =~ /\ssecuretransport\b/i) {
  357. $feature{"sectransp"} = 1;
  358. $feature{"SSLpinning"} = 1;
  359. }
  360. elsif ($libcurl =~ /\sBoringSSL\b/i) {
  361. # OpenSSL compatible API
  362. $feature{"OpenSSL"} = 1;
  363. $feature{"SSLpinning"} = 1;
  364. }
  365. elsif ($libcurl =~ /\slibressl\b/i) {
  366. # OpenSSL compatible API
  367. $feature{"OpenSSL"} = 1;
  368. $feature{"SSLpinning"} = 1;
  369. }
  370. elsif ($libcurl =~ /\smbedTLS\b/i) {
  371. $feature{"mbedtls"} = 1;
  372. $feature{"SSLpinning"} = 1;
  373. }
  374. if ($libcurl =~ /ares/i) {
  375. $feature{"c-ares"} = 1;
  376. $resolver="c-ares";
  377. }
  378. if ($libcurl =~ /Hyper/i) {
  379. $feature{"hyper"} = 1;
  380. }
  381. if ($libcurl =~ /nghttp2/i) {
  382. # nghttp2 supports h2c, hyper does not
  383. $feature{"h2c"} = 1;
  384. }
  385. if ($libcurl =~ /libssh2/i) {
  386. $feature{"libssh2"} = 1;
  387. }
  388. if ($libcurl =~ /libssh\/([0-9.]*)\//i) {
  389. $feature{"libssh"} = 1;
  390. if($1 =~ /(\d+)\.(\d+).(\d+)/) {
  391. my $v = $1 * 100 + $2 * 10 + $3;
  392. if($v < 94) {
  393. # before 0.9.4
  394. $feature{"oldlibssh"} = 1;
  395. }
  396. }
  397. }
  398. if ($libcurl =~ /wolfssh/i) {
  399. $feature{"wolfssh"} = 1;
  400. }
  401. }
  402. elsif($_ =~ /^Protocols: (.*)/i) {
  403. # these are the protocols compiled in to this libcurl
  404. @protocols = split(' ', lc($1));
  405. # Generate a "proto-ipv6" version of each protocol to match the
  406. # IPv6 <server> name and a "proto-unix" to match the variant which
  407. # uses Unix domain sockets. This works even if support isn't
  408. # compiled in because the <features> test will fail.
  409. push @protocols, map(("$_-ipv6", "$_-unix"), @protocols);
  410. # 'http-proxy' is used in test cases to do CONNECT through
  411. push @protocols, 'http-proxy';
  412. # 'none' is used in test cases to mean no server
  413. push @protocols, 'none';
  414. }
  415. elsif($_ =~ /^Features: (.*)/i) {
  416. $feat = $1;
  417. # built with memory tracking support (--enable-curldebug); may be disabled later
  418. $feature{"TrackMemory"} = $feat =~ /TrackMemory/i;
  419. # curl was built with --enable-debug
  420. $feature{"debug"} = $feat =~ /debug/i;
  421. # ssl enabled
  422. $feature{"SSL"} = $feat =~ /SSL/i;
  423. # multiple ssl backends available.
  424. $feature{"MultiSSL"} = $feat =~ /MultiSSL/i;
  425. # large file support
  426. $feature{"large_file"} = $feat =~ /Largefile/i;
  427. # IDN support
  428. $feature{"idn"} = $feat =~ /IDN/i;
  429. # IPv6 support
  430. $feature{"ipv6"} = $feat =~ /IPv6/i;
  431. # Unix sockets support
  432. $feature{"unix-sockets"} = $feat =~ /UnixSockets/i;
  433. # libz compression
  434. $feature{"libz"} = $feat =~ /libz/i;
  435. # Brotli compression
  436. $feature{"brotli"} = $feat =~ /brotli/i;
  437. # Zstd compression
  438. $feature{"zstd"} = $feat =~ /zstd/i;
  439. # NTLM enabled
  440. $feature{"NTLM"} = $feat =~ /NTLM/i;
  441. # NTLM delegation to winbind daemon ntlm_auth helper enabled
  442. $feature{"NTLM_WB"} = $feat =~ /NTLM_WB/i;
  443. # SSPI enabled
  444. $feature{"SSPI"} = $feat =~ /SSPI/i;
  445. # GSS-API enabled
  446. $feature{"GSS-API"} = $feat =~ /GSS-API/i;
  447. # Kerberos enabled
  448. $feature{"Kerberos"} = $feat =~ /Kerberos/i;
  449. # SPNEGO enabled
  450. $feature{"SPNEGO"} = $feat =~ /SPNEGO/i;
  451. # CharConv enabled
  452. $feature{"CharConv"} = $feat =~ /CharConv/i;
  453. # TLS-SRP enabled
  454. $feature{"TLS-SRP"} = $feat =~ /TLS-SRP/i;
  455. # PSL enabled
  456. $feature{"PSL"} = $feat =~ /PSL/i;
  457. # alt-svc enabled
  458. $feature{"alt-svc"} = $feat =~ /alt-svc/i;
  459. # HSTS support
  460. $feature{"HSTS"} = $feat =~ /HSTS/i;
  461. if($feat =~ /AsynchDNS/i) {
  462. if(!$feature{"c-ares"}) {
  463. # this means threaded resolver
  464. $feature{"threaded-resolver"} = 1;
  465. $resolver="threaded";
  466. }
  467. }
  468. # http2 enabled
  469. $feature{"http/2"} = $feat =~ /HTTP2/;
  470. if($feature{"http/2"}) {
  471. push @protocols, 'http/2';
  472. }
  473. # http3 enabled
  474. $feature{"http/3"} = $feat =~ /HTTP3/;
  475. if($feature{"http/3"}) {
  476. push @protocols, 'http/3';
  477. }
  478. # https proxy support
  479. $feature{"https-proxy"} = $feat =~ /HTTPS-proxy/;
  480. if($feature{"https-proxy"}) {
  481. # 'https-proxy' is used as "server" so consider it a protocol
  482. push @protocols, 'https-proxy';
  483. }
  484. # UNICODE support
  485. $feature{"Unicode"} = $feat =~ /Unicode/i;
  486. # Thread-safe init
  487. $feature{"threadsafe"} = $feat =~ /threadsafe/i;
  488. }
  489. #
  490. # Test harness currently uses a non-stunnel server in order to
  491. # run HTTP TLS-SRP tests required when curl is built with https
  492. # protocol support and TLS-SRP feature enabled. For convenience
  493. # 'httptls' may be included in the test harness protocols array
  494. # to differentiate this from classic stunnel based 'https' test
  495. # harness server.
  496. #
  497. if($feature{"TLS-SRP"}) {
  498. my $add_httptls;
  499. for(@protocols) {
  500. if($_ =~ /^https(-ipv6|)$/) {
  501. $add_httptls=1;
  502. last;
  503. }
  504. }
  505. if($add_httptls && (! grep /^httptls$/, @protocols)) {
  506. push @protocols, 'httptls';
  507. push @protocols, 'httptls-ipv6';
  508. }
  509. }
  510. }
  511. if(!$curl) {
  512. logmsg "unable to get curl's version, further details are:\n";
  513. logmsg "issued command: \n";
  514. logmsg "$versioncmd \n";
  515. if ($versretval == -1) {
  516. logmsg "command failed with: \n";
  517. logmsg "$versnoexec \n";
  518. }
  519. elsif ($versretval & 127) {
  520. logmsg sprintf("command died with signal %d, and %s coredump.\n",
  521. ($versretval & 127), ($versretval & 128)?"a":"no");
  522. }
  523. else {
  524. logmsg sprintf("command exited with value %d \n", $versretval >> 8);
  525. }
  526. logmsg "contents of $curlverout: \n";
  527. displaylogcontent("$curlverout");
  528. logmsg "contents of $curlvererr: \n";
  529. displaylogcontent("$curlvererr");
  530. die "couldn't get curl's version";
  531. }
  532. if(-r "../lib/curl_config.h") {
  533. open(my $conf, "<", "../lib/curl_config.h");
  534. while(<$conf>) {
  535. if($_ =~ /^\#define HAVE_GETRLIMIT/) {
  536. # set if system has getrlimit()
  537. $feature{"getrlimit"} = 1;
  538. }
  539. }
  540. close($conf);
  541. }
  542. # allow this feature only if debug mode is disabled
  543. $feature{"ld_preload"} = $feature{"ld_preload"} && !$feature{"debug"};
  544. if($feature{"ipv6"}) {
  545. # client has IPv6 support
  546. # check if the HTTP server has it!
  547. my $cmd = "server/sws".exe_ext('SRV')." --version";
  548. my @sws = `$cmd`;
  549. if($sws[0] =~ /IPv6/) {
  550. # HTTP server has IPv6 support!
  551. $http_ipv6 = 1;
  552. }
  553. # check if the FTP server has it!
  554. $cmd = "server/sockfilt".exe_ext('SRV')." --version";
  555. @sws = `$cmd`;
  556. if($sws[0] =~ /IPv6/) {
  557. # FTP server has IPv6 support!
  558. $ftp_ipv6 = 1;
  559. }
  560. }
  561. if($feature{"unix-sockets"}) {
  562. # client has Unix sockets support, check whether the HTTP server has it
  563. my $cmd = "server/sws".exe_ext('SRV')." --version";
  564. my @sws = `$cmd`;
  565. $http_unix = 1 if($sws[0] =~ /unix/);
  566. }
  567. open(my $manh, "-|", "$CURL -M 2>&1");
  568. while(my $s = <$manh>) {
  569. if($s =~ /built-in manual was disabled at build-time/) {
  570. $feature{"manual"} = 0;
  571. last;
  572. }
  573. $feature{"manual"} = 1;
  574. last;
  575. }
  576. close($manh);
  577. $feature{"unittest"} = $feature{"debug"};
  578. $feature{"nghttpx"} = !!$ENV{'NGHTTPX'};
  579. $feature{"nghttpx-h3"} = !!$nghttpx_h3;
  580. #
  581. # strings that must exactly match the names used in server/disabled.c
  582. #
  583. $feature{"cookies"} = 1;
  584. # Use this as a proxy for any cryptographic authentication
  585. $feature{"crypto"} = $feature{"NTLM"} || $feature{"Kerberos"} || $feature{"SPNEGO"};
  586. $feature{"DoH"} = 1;
  587. $feature{"HTTP-auth"} = 1;
  588. $feature{"Mime"} = 1;
  589. $feature{"netrc"} = 1;
  590. $feature{"parsedate"} = 1;
  591. $feature{"proxy"} = 1;
  592. $feature{"shuffle-dns"} = 1;
  593. $feature{"typecheck"} = 1;
  594. $feature{"verbose-strings"} = 1;
  595. $feature{"wakeup"} = 1;
  596. $feature{"headers-api"} = 1;
  597. $feature{"xattr"} = 1;
  598. # make each protocol an enabled "feature"
  599. for my $p (@protocols) {
  600. $feature{$p} = 1;
  601. }
  602. # 'socks' was once here but is now removed
  603. $has_shared = `sh $CURLCONFIG --built-shared`;
  604. chomp $has_shared;
  605. $has_shared = $has_shared eq "yes";
  606. if(!$feature{"TrackMemory"} && $torture) {
  607. die "can't run torture tests since curl was built without ".
  608. "TrackMemory feature (--enable-curldebug)";
  609. }
  610. my $hostname=join(' ', runclientoutput("hostname"));
  611. my $hosttype=join(' ', runclientoutput("uname -a"));
  612. my $hostos=$^O;
  613. # display summary information about curl and the test host
  614. logmsg ("********* System characteristics ******** \n",
  615. "* $curl\n",
  616. "* $libcurl\n",
  617. "* Features: $feat\n",
  618. "* Disabled: $dis\n",
  619. "* Host: $hostname",
  620. "* System: $hosttype",
  621. "* OS: $hostos\n");
  622. if($feature{"TrackMemory"} && $feature{"threaded-resolver"}) {
  623. logmsg("*\n",
  624. "*** DISABLES memory tracking when using threaded resolver\n",
  625. "*\n");
  626. }
  627. logmsg sprintf("* Env: %s%s%s", $valgrind?"Valgrind ":"",
  628. $run_event_based?"event-based ":"",
  629. $nghttpx_h3);
  630. logmsg sprintf("%s\n", $libtool?"Libtool ":"");
  631. logmsg ("* Seed: $randseed\n");
  632. # Disable memory tracking when using threaded resolver
  633. $feature{"TrackMemory"} = $feature{"TrackMemory"} && !$feature{"threaded-resolver"};
  634. # toggle off the features that were disabled in the build
  635. for my $d(@disabled) {
  636. $feature{$d} = 0;
  637. }
  638. }
  639. #######################################################################
  640. # display information about server features
  641. #
  642. sub displayserverfeatures {
  643. logmsg sprintf("* Servers: %s", $stunnel?"SSL ":"");
  644. logmsg sprintf("%s", $http_ipv6?"HTTP-IPv6 ":"");
  645. logmsg sprintf("%s", $http_unix?"HTTP-unix ":"");
  646. logmsg sprintf("%s\n", $ftp_ipv6?"FTP-IPv6 ":"");
  647. if($verbose) {
  648. if($feature{"unix-sockets"}) {
  649. logmsg "* Unix socket paths:\n";
  650. if($http_unix) {
  651. logmsg sprintf("* HTTP-Unix:%s\n", $HTTPUNIXPATH);
  652. logmsg sprintf("* Socks-Unix:%s\n", $SOCKSUNIXPATH);
  653. }
  654. }
  655. }
  656. logmsg "***************************************** \n";
  657. }
  658. #######################################################################
  659. # Provide time stamps for single test skipped events
  660. #
  661. sub timestampskippedevents {
  662. my $testnum = $_[0];
  663. return if((not defined($testnum)) || ($testnum < 1));
  664. if($timestats) {
  665. if($timevrfyend{$testnum}) {
  666. return;
  667. }
  668. elsif($timesrvrlog{$testnum}) {
  669. $timevrfyend{$testnum} = $timesrvrlog{$testnum};
  670. return;
  671. }
  672. elsif($timetoolend{$testnum}) {
  673. $timevrfyend{$testnum} = $timetoolend{$testnum};
  674. $timesrvrlog{$testnum} = $timetoolend{$testnum};
  675. }
  676. elsif($timetoolini{$testnum}) {
  677. $timevrfyend{$testnum} = $timetoolini{$testnum};
  678. $timesrvrlog{$testnum} = $timetoolini{$testnum};
  679. $timetoolend{$testnum} = $timetoolini{$testnum};
  680. }
  681. elsif($timesrvrend{$testnum}) {
  682. $timevrfyend{$testnum} = $timesrvrend{$testnum};
  683. $timesrvrlog{$testnum} = $timesrvrend{$testnum};
  684. $timetoolend{$testnum} = $timesrvrend{$testnum};
  685. $timetoolini{$testnum} = $timesrvrend{$testnum};
  686. }
  687. elsif($timesrvrini{$testnum}) {
  688. $timevrfyend{$testnum} = $timesrvrini{$testnum};
  689. $timesrvrlog{$testnum} = $timesrvrini{$testnum};
  690. $timetoolend{$testnum} = $timesrvrini{$testnum};
  691. $timetoolini{$testnum} = $timesrvrini{$testnum};
  692. $timesrvrend{$testnum} = $timesrvrini{$testnum};
  693. }
  694. elsif($timeprepini{$testnum}) {
  695. $timevrfyend{$testnum} = $timeprepini{$testnum};
  696. $timesrvrlog{$testnum} = $timeprepini{$testnum};
  697. $timetoolend{$testnum} = $timeprepini{$testnum};
  698. $timetoolini{$testnum} = $timeprepini{$testnum};
  699. $timesrvrend{$testnum} = $timeprepini{$testnum};
  700. $timesrvrini{$testnum} = $timeprepini{$testnum};
  701. }
  702. }
  703. }
  704. # Setup CI Test Run
  705. sub citest_starttestrun {
  706. if(azure_check_environment()) {
  707. $AZURE_RUN_ID = azure_create_test_run($ACURL);
  708. logmsg "Azure Run ID: $AZURE_RUN_ID\n" if ($verbose);
  709. }
  710. # Appveyor doesn't require anything here
  711. }
  712. # Register the test case with the CI runner
  713. sub citest_starttest {
  714. my $testnum = $_[0];
  715. # get the name of the test early
  716. my $testname= (getpart("client", "name"))[0];
  717. chomp $testname;
  718. # create test result in CI services
  719. if(azure_check_environment() && $AZURE_RUN_ID) {
  720. $AZURE_RESULT_ID = azure_create_test_result($ACURL, $AZURE_RUN_ID, $testnum, $testname);
  721. }
  722. elsif(appveyor_check_environment()) {
  723. appveyor_create_test_result($ACURL, $testnum, $testname);
  724. }
  725. }
  726. # Submit the test case result with the CI runner
  727. sub citest_finishtest {
  728. my ($testnum, $error) = @_;
  729. # update test result in CI services
  730. if(azure_check_environment() && $AZURE_RUN_ID && $AZURE_RESULT_ID) {
  731. $AZURE_RESULT_ID = azure_update_test_result($ACURL, $AZURE_RUN_ID, $AZURE_RESULT_ID, $testnum, $error,
  732. $timeprepini{$testnum}, $timevrfyend{$testnum});
  733. }
  734. elsif(appveyor_check_environment()) {
  735. appveyor_update_test_result($ACURL, $testnum, $error, $timeprepini{$testnum}, $timevrfyend{$testnum});
  736. }
  737. }
  738. # Complete CI test run
  739. sub citest_finishtestrun {
  740. if(azure_check_environment() && $AZURE_RUN_ID) {
  741. $AZURE_RUN_ID = azure_update_test_run($ACURL, $AZURE_RUN_ID);
  742. }
  743. # Appveyor doesn't require anything here
  744. }
  745. #######################################################################
  746. # Verify that this test case should be run
  747. sub singletest_shouldrun {
  748. my $testnum = $_[0];
  749. my $why; # why the test won't be run
  750. my $errorreturncode = 1; # 1 means normal error, 2 means ignored error
  751. my @what; # what features are needed
  752. # first, remove all lingering log files
  753. if(!cleardir($LOGDIR) && $clearlocks) {
  754. clearlocks($LOGDIR);
  755. cleardir($LOGDIR);
  756. }
  757. # timestamp test preparation start
  758. $timeprepini{$testnum} = Time::HiRes::time();
  759. if($disttests !~ /test$testnum(\W|\z)/ ) {
  760. logmsg "Warning: test$testnum not present in tests/data/Makefile.inc\n";
  761. }
  762. if($disabled{$testnum}) {
  763. if(!$run_disabled) {
  764. $why = "listed in DISABLED";
  765. }
  766. else {
  767. logmsg "Warning: test$testnum is explicitly disabled\n";
  768. }
  769. }
  770. if($ignored{$testnum}) {
  771. logmsg "Warning: test$testnum result is ignored\n";
  772. $errorreturncode = 2;
  773. }
  774. # load the test case file definition
  775. if(loadtest("${TESTDIR}/test${testnum}")) {
  776. if($verbose) {
  777. # this is not a test
  778. logmsg "RUN: $testnum doesn't look like a test case\n";
  779. }
  780. $why = "no test";
  781. }
  782. else {
  783. @what = getpart("client", "features");
  784. }
  785. # We require a feature to be present
  786. for(@what) {
  787. my $f = $_;
  788. $f =~ s/\s//g;
  789. if($f =~ /^([^!].*)$/) {
  790. if($feature{$1}) {
  791. next;
  792. }
  793. $why = "curl lacks $1 support";
  794. last;
  795. }
  796. }
  797. # We require a feature to not be present
  798. if(!$why) {
  799. for(@what) {
  800. my $f = $_;
  801. $f =~ s/\s//g;
  802. if($f =~ /^!(.*)$/) {
  803. if(!$feature{$1}) {
  804. next;
  805. }
  806. }
  807. else {
  808. next;
  809. }
  810. $why = "curl has $1 support";
  811. last;
  812. }
  813. }
  814. my @info_keywords;
  815. if(!$why) {
  816. @info_keywords = getpart("info", "keywords");
  817. # Clear the list of keywords from the last test
  818. %keywords = ();
  819. if(!$info_keywords[0]) {
  820. $why = "missing the <keywords> section!";
  821. }
  822. my $match;
  823. for my $k (@info_keywords) {
  824. chomp $k;
  825. if ($disabled_keywords{lc($k)}) {
  826. $why = "disabled by keyword";
  827. }
  828. elsif ($enabled_keywords{lc($k)}) {
  829. $match = 1;
  830. }
  831. if ($ignored_keywords{lc($k)}) {
  832. logmsg "Warning: test$testnum result is ignored due to $k\n";
  833. $errorreturncode = 2;
  834. }
  835. $keywords{$k} = 1;
  836. }
  837. if(!$why && !$match && %enabled_keywords) {
  838. $why = "disabled by missing keyword";
  839. }
  840. }
  841. if (!$why && defined $custom_skip_reasons{test}{$testnum}) {
  842. $why = $custom_skip_reasons{test}{$testnum};
  843. }
  844. if (!$why && defined $custom_skip_reasons{tool}) {
  845. foreach my $tool (getpart("client", "tool")) {
  846. foreach my $tool_skip_pattern (keys %{$custom_skip_reasons{tool}}) {
  847. if ($tool =~ /$tool_skip_pattern/i) {
  848. $why = $custom_skip_reasons{tool}{$tool_skip_pattern};
  849. }
  850. }
  851. }
  852. }
  853. if (!$why && defined $custom_skip_reasons{keyword}) {
  854. foreach my $keyword (@info_keywords) {
  855. foreach my $keyword_skip_pattern (keys %{$custom_skip_reasons{keyword}}) {
  856. if ($keyword =~ /$keyword_skip_pattern/i) {
  857. $why = $custom_skip_reasons{keyword}{$keyword_skip_pattern};
  858. }
  859. }
  860. }
  861. }
  862. return ($why, $errorreturncode);
  863. }
  864. #######################################################################
  865. # Print the test name and count tests
  866. sub singletest_count {
  867. my ($testnum, $why) = @_;
  868. if($why && !$listonly) {
  869. # there's a problem, count it as "skipped"
  870. $skipped{$why}++;
  871. $teststat[$testnum]=$why; # store reason for this test case
  872. if(!$short) {
  873. if($skipped{$why} <= 3) {
  874. # show only the first three skips for each reason
  875. logmsg sprintf("test %04d SKIPPED: $why\n", $testnum);
  876. }
  877. }
  878. timestampskippedevents($testnum);
  879. return -1;
  880. }
  881. # At this point we've committed to run this test
  882. logmsg sprintf("test %04d...", $testnum) if(!$automakestyle);
  883. # name of the test
  884. my $testname= (getpart("client", "name"))[0];
  885. chomp $testname;
  886. logmsg "[$testname]\n" if(!$short);
  887. if($listonly) {
  888. timestampskippedevents($testnum);
  889. }
  890. return 0;
  891. }
  892. #######################################################################
  893. # Verify test succeeded
  894. sub singletest_check {
  895. my ($testnum, $cmdres, $CURLOUT, $tool, $disablevalgrind)=@_;
  896. # Skip all the verification on torture tests
  897. if ($torture) {
  898. # timestamp test result verification end
  899. $timevrfyend{$testnum} = Time::HiRes::time();
  900. return -2;
  901. }
  902. my @err = getpart("verify", "errorcode");
  903. my $errorcode = $err[0] || "0";
  904. my $ok="";
  905. my $res;
  906. chomp $errorcode;
  907. my $testname= (getpart("client", "name"))[0];
  908. chomp $testname;
  909. # what parts to cut off from stdout/stderr
  910. my @stripfile = getpart("verify", "stripfile");
  911. my @validstdout = getpart("verify", "stdout");
  912. if (@validstdout) {
  913. # verify redirected stdout
  914. my @actual = loadarray($STDOUT);
  915. foreach my $strip (@stripfile) {
  916. chomp $strip;
  917. my @newgen;
  918. for(@actual) {
  919. eval $strip;
  920. if($_) {
  921. push @newgen, $_;
  922. }
  923. }
  924. # this is to get rid of array entries that vanished (zero
  925. # length) because of replacements
  926. @actual = @newgen;
  927. }
  928. # get all attributes
  929. my %hash = getpartattr("verify", "stdout");
  930. # get the mode attribute
  931. my $filemode=$hash{'mode'};
  932. if($filemode && ($filemode eq "text") && $has_textaware) {
  933. # text mode when running on windows: fix line endings
  934. s/\r\n/\n/g for @validstdout;
  935. s/\n/\r\n/g for @validstdout;
  936. }
  937. if($hash{'nonewline'}) {
  938. # Yes, we must cut off the final newline from the final line
  939. # of the protocol data
  940. chomp($validstdout[-1]);
  941. }
  942. if($hash{'crlf'} ||
  943. ($feature{"hyper"} && ($keywords{"HTTP"}
  944. || $keywords{"HTTPS"}))) {
  945. subnewlines(0, \$_) for @validstdout;
  946. }
  947. $res = compare($testnum, $testname, "stdout", \@actual, \@validstdout);
  948. if($res) {
  949. return -1;
  950. }
  951. $ok .= "s";
  952. }
  953. else {
  954. $ok .= "-"; # stdout not checked
  955. }
  956. my @validstderr = getpart("verify", "stderr");
  957. if (@validstderr) {
  958. # verify redirected stderr
  959. my @actual = loadarray($STDERR);
  960. foreach my $strip (@stripfile) {
  961. chomp $strip;
  962. my @newgen;
  963. for(@actual) {
  964. eval $strip;
  965. if($_) {
  966. push @newgen, $_;
  967. }
  968. }
  969. # this is to get rid of array entries that vanished (zero
  970. # length) because of replacements
  971. @actual = @newgen;
  972. }
  973. # get all attributes
  974. my %hash = getpartattr("verify", "stderr");
  975. # get the mode attribute
  976. my $filemode=$hash{'mode'};
  977. if($filemode && ($filemode eq "text") && $feature{"hyper"}) {
  978. # text mode check in hyper-mode. Sometimes necessary if the stderr
  979. # data *looks* like HTTP and thus has gotten CRLF newlines
  980. # mistakenly
  981. s/\r\n/\n/g for @validstderr;
  982. }
  983. if($filemode && ($filemode eq "text") && $has_textaware) {
  984. # text mode when running on windows: fix line endings
  985. s/\r\n/\n/g for @validstderr;
  986. s/\n/\r\n/g for @validstderr;
  987. }
  988. if($hash{'nonewline'}) {
  989. # Yes, we must cut off the final newline from the final line
  990. # of the protocol data
  991. chomp($validstderr[-1]);
  992. }
  993. $res = compare($testnum, $testname, "stderr", \@actual, \@validstderr);
  994. if($res) {
  995. return -1;
  996. }
  997. $ok .= "r";
  998. }
  999. else {
  1000. $ok .= "-"; # stderr not checked
  1001. }
  1002. # what to cut off from the live protocol sent by curl
  1003. my @strip = getpart("verify", "strip");
  1004. # what parts to cut off from the protocol & upload
  1005. my @strippart = getpart("verify", "strippart");
  1006. # this is the valid protocol blurb curl should generate
  1007. my @protocol= getpart("verify", "protocol");
  1008. if(@protocol) {
  1009. # Verify the sent request
  1010. my @out = loadarray($SERVERIN);
  1011. # check if there's any attributes on the verify/protocol section
  1012. my %hash = getpartattr("verify", "protocol");
  1013. if($hash{'nonewline'}) {
  1014. # Yes, we must cut off the final newline from the final line
  1015. # of the protocol data
  1016. chomp($protocol[-1]);
  1017. }
  1018. for(@strip) {
  1019. # strip off all lines that match the patterns from both arrays
  1020. chomp $_;
  1021. @out = striparray( $_, \@out);
  1022. @protocol= striparray( $_, \@protocol);
  1023. }
  1024. for my $strip (@strippart) {
  1025. chomp $strip;
  1026. for(@out) {
  1027. eval $strip;
  1028. }
  1029. }
  1030. if($hash{'crlf'}) {
  1031. subnewlines(1, \$_) for @protocol;
  1032. }
  1033. if((!$out[0] || ($out[0] eq "")) && $protocol[0]) {
  1034. logmsg "\n $testnum: protocol FAILED!\n".
  1035. " There was no content at all in the file $SERVERIN.\n".
  1036. " Server glitch? Total curl failure? Returned: $cmdres\n";
  1037. # timestamp test result verification end
  1038. $timevrfyend{$testnum} = Time::HiRes::time();
  1039. return -1;
  1040. }
  1041. $res = compare($testnum, $testname, "protocol", \@out, \@protocol);
  1042. if($res) {
  1043. return -1;
  1044. }
  1045. $ok .= "p";
  1046. }
  1047. else {
  1048. $ok .= "-"; # protocol not checked
  1049. }
  1050. my %replyattr = getpartattr("reply", "data");
  1051. my @reply;
  1052. if (partexists("reply", "datacheck")) {
  1053. for my $partsuffix (('', '1', '2', '3', '4')) {
  1054. my @replycheckpart = getpart("reply", "datacheck".$partsuffix);
  1055. if(@replycheckpart) {
  1056. my %replycheckpartattr = getpartattr("reply", "datacheck".$partsuffix);
  1057. # get the mode attribute
  1058. my $filemode=$replycheckpartattr{'mode'};
  1059. if($filemode && ($filemode eq "text") && $has_textaware) {
  1060. # text mode when running on windows: fix line endings
  1061. s/\r\n/\n/g for @replycheckpart;
  1062. s/\n/\r\n/g for @replycheckpart;
  1063. }
  1064. if($replycheckpartattr{'nonewline'}) {
  1065. # Yes, we must cut off the final newline from the final line
  1066. # of the datacheck
  1067. chomp($replycheckpart[-1]);
  1068. }
  1069. if($replycheckpartattr{'crlf'} ||
  1070. ($feature{"hyper"} && ($keywords{"HTTP"}
  1071. || $keywords{"HTTPS"}))) {
  1072. subnewlines(0, \$_) for @replycheckpart;
  1073. }
  1074. push(@reply, @replycheckpart);
  1075. }
  1076. }
  1077. }
  1078. else {
  1079. # check against the data section
  1080. @reply = getpart("reply", "data");
  1081. if(@reply) {
  1082. if($replyattr{'nonewline'}) {
  1083. # cut off the final newline from the final line of the data
  1084. chomp($reply[-1]);
  1085. }
  1086. }
  1087. # get the mode attribute
  1088. my $filemode=$replyattr{'mode'};
  1089. if($filemode && ($filemode eq "text") && $has_textaware) {
  1090. # text mode when running on windows: fix line endings
  1091. s/\r\n/\n/g for @reply;
  1092. s/\n/\r\n/g for @reply;
  1093. }
  1094. if($replyattr{'crlf'} ||
  1095. ($feature{"hyper"} && ($keywords{"HTTP"}
  1096. || $keywords{"HTTPS"}))) {
  1097. subnewlines(0, \$_) for @reply;
  1098. }
  1099. }
  1100. if(!$replyattr{'nocheck'} && (@reply || $replyattr{'sendzero'})) {
  1101. # verify the received data
  1102. my @out = loadarray($CURLOUT);
  1103. $res = compare($testnum, $testname, "data", \@out, \@reply);
  1104. if ($res) {
  1105. return -1;
  1106. }
  1107. $ok .= "d";
  1108. }
  1109. else {
  1110. $ok .= "-"; # data not checked
  1111. }
  1112. # if this section exists, we verify upload
  1113. my @upload = getpart("verify", "upload");
  1114. if(@upload) {
  1115. my %hash = getpartattr("verify", "upload");
  1116. if($hash{'nonewline'}) {
  1117. # cut off the final newline from the final line of the upload data
  1118. chomp($upload[-1]);
  1119. }
  1120. # verify uploaded data
  1121. my @out = loadarray("$LOGDIR/upload.$testnum");
  1122. for my $strip (@strippart) {
  1123. chomp $strip;
  1124. for(@out) {
  1125. eval $strip;
  1126. }
  1127. }
  1128. $res = compare($testnum, $testname, "upload", \@out, \@upload);
  1129. if ($res) {
  1130. return -1;
  1131. }
  1132. $ok .= "u";
  1133. }
  1134. else {
  1135. $ok .= "-"; # upload not checked
  1136. }
  1137. # this is the valid protocol blurb curl should generate to a proxy
  1138. my @proxyprot = getpart("verify", "proxy");
  1139. if(@proxyprot) {
  1140. # Verify the sent proxy request
  1141. # check if there's any attributes on the verify/protocol section
  1142. my %hash = getpartattr("verify", "proxy");
  1143. if($hash{'nonewline'}) {
  1144. # Yes, we must cut off the final newline from the final line
  1145. # of the protocol data
  1146. chomp($proxyprot[-1]);
  1147. }
  1148. my @out = loadarray($PROXYIN);
  1149. for(@strip) {
  1150. # strip off all lines that match the patterns from both arrays
  1151. chomp $_;
  1152. @out = striparray( $_, \@out);
  1153. @proxyprot= striparray( $_, \@proxyprot);
  1154. }
  1155. for my $strip (@strippart) {
  1156. chomp $strip;
  1157. for(@out) {
  1158. eval $strip;
  1159. }
  1160. }
  1161. if($hash{'crlf'} ||
  1162. ($feature{"hyper"} && ($keywords{"HTTP"} || $keywords{"HTTPS"}))) {
  1163. subnewlines(0, \$_) for @proxyprot;
  1164. }
  1165. $res = compare($testnum, $testname, "proxy", \@out, \@proxyprot);
  1166. if($res) {
  1167. return -1;
  1168. }
  1169. $ok .= "P";
  1170. }
  1171. else {
  1172. $ok .= "-"; # protocol not checked
  1173. }
  1174. my $outputok;
  1175. for my $partsuffix (('', '1', '2', '3', '4')) {
  1176. my @outfile=getpart("verify", "file".$partsuffix);
  1177. if(@outfile || partexists("verify", "file".$partsuffix) ) {
  1178. # we're supposed to verify a dynamically generated file!
  1179. my %hash = getpartattr("verify", "file".$partsuffix);
  1180. my $filename=$hash{'name'};
  1181. if(!$filename) {
  1182. logmsg "ERROR: section verify=>file$partsuffix ".
  1183. "has no name attribute\n";
  1184. stopservers($verbose);
  1185. # timestamp test result verification end
  1186. $timevrfyend{$testnum} = Time::HiRes::time();
  1187. return -1;
  1188. }
  1189. my @generated=loadarray($filename);
  1190. # what parts to cut off from the file
  1191. my @stripfilepar = getpart("verify", "stripfile".$partsuffix);
  1192. my $filemode=$hash{'mode'};
  1193. if($filemode && ($filemode eq "text") && $has_textaware) {
  1194. # text mode when running on windows: fix line endings
  1195. s/\r\n/\n/g for @outfile;
  1196. s/\n/\r\n/g for @outfile;
  1197. }
  1198. if($hash{'crlf'} ||
  1199. ($feature{"hyper"} && ($keywords{"HTTP"}
  1200. || $keywords{"HTTPS"}))) {
  1201. subnewlines(0, \$_) for @outfile;
  1202. }
  1203. for my $strip (@stripfilepar) {
  1204. chomp $strip;
  1205. my @newgen;
  1206. for(@generated) {
  1207. eval $strip;
  1208. if($_) {
  1209. push @newgen, $_;
  1210. }
  1211. }
  1212. # this is to get rid of array entries that vanished (zero
  1213. # length) because of replacements
  1214. @generated = @newgen;
  1215. }
  1216. $res = compare($testnum, $testname, "output ($filename)",
  1217. \@generated, \@outfile);
  1218. if($res) {
  1219. return -1;
  1220. }
  1221. $outputok = 1; # output checked
  1222. }
  1223. }
  1224. $ok .= ($outputok) ? "o" : "-"; # output checked or not
  1225. # verify SOCKS proxy details
  1226. my @socksprot = getpart("verify", "socks");
  1227. if(@socksprot) {
  1228. # Verify the sent SOCKS proxy details
  1229. my @out = loadarray($SOCKSIN);
  1230. $res = compare($testnum, $testname, "socks", \@out, \@socksprot);
  1231. if($res) {
  1232. return -1;
  1233. }
  1234. }
  1235. # accept multiple comma-separated error codes
  1236. my @splerr = split(/ *, */, $errorcode);
  1237. my $errok;
  1238. foreach my $e (@splerr) {
  1239. if($e == $cmdres) {
  1240. # a fine error code
  1241. $errok = 1;
  1242. last;
  1243. }
  1244. }
  1245. if($errok) {
  1246. $ok .= "e";
  1247. }
  1248. else {
  1249. if(!$short) {
  1250. logmsg sprintf("\n%s returned $cmdres, when expecting %s\n",
  1251. (!$tool)?"curl":$tool, $errorcode);
  1252. }
  1253. logmsg " exit FAILED\n";
  1254. # timestamp test result verification end
  1255. $timevrfyend{$testnum} = Time::HiRes::time();
  1256. return -1;
  1257. }
  1258. if($feature{"TrackMemory"}) {
  1259. if(! -f $memdump) {
  1260. my %cmdhash = getpartattr("client", "command");
  1261. my $cmdtype = $cmdhash{'type'} || "default";
  1262. logmsg "\n** ALERT! memory tracking with no output file?\n"
  1263. if(!$cmdtype eq "perl");
  1264. }
  1265. else {
  1266. my @memdata=`$memanalyze $memdump`;
  1267. my $leak=0;
  1268. for(@memdata) {
  1269. if($_ ne "") {
  1270. # well it could be other memory problems as well, but
  1271. # we call it leak for short here
  1272. $leak=1;
  1273. }
  1274. }
  1275. if($leak) {
  1276. logmsg "\n** MEMORY FAILURE\n";
  1277. logmsg @memdata;
  1278. # timestamp test result verification end
  1279. $timevrfyend{$testnum} = Time::HiRes::time();
  1280. return -1;
  1281. }
  1282. else {
  1283. $ok .= "m";
  1284. }
  1285. }
  1286. }
  1287. else {
  1288. $ok .= "-"; # memory not checked
  1289. }
  1290. if($valgrind) {
  1291. if(use_valgrind() && !$disablevalgrind) {
  1292. if(!opendir(DIR, "$LOGDIR")) {
  1293. logmsg "ERROR: unable to read $LOGDIR\n";
  1294. # timestamp test result verification end
  1295. $timevrfyend{$testnum} = Time::HiRes::time();
  1296. return -1;
  1297. }
  1298. my @files = readdir(DIR);
  1299. closedir(DIR);
  1300. my $vgfile;
  1301. foreach my $file (@files) {
  1302. if($file =~ /^valgrind$testnum(\..*|)$/) {
  1303. $vgfile = $file;
  1304. last;
  1305. }
  1306. }
  1307. if(!$vgfile) {
  1308. logmsg "ERROR: valgrind log file missing for test $testnum\n";
  1309. # timestamp test result verification end
  1310. $timevrfyend{$testnum} = Time::HiRes::time();
  1311. return -1;
  1312. }
  1313. my @e = valgrindparse("$LOGDIR/$vgfile");
  1314. if(@e && $e[0]) {
  1315. if($automakestyle) {
  1316. logmsg "FAIL: $testnum - $testname - valgrind\n";
  1317. }
  1318. else {
  1319. logmsg " valgrind ERROR ";
  1320. logmsg @e;
  1321. }
  1322. # timestamp test result verification end
  1323. $timevrfyend{$testnum} = Time::HiRes::time();
  1324. return -1;
  1325. }
  1326. $ok .= "v";
  1327. }
  1328. else {
  1329. if($verbose && !$disablevalgrind) {
  1330. logmsg " valgrind SKIPPED\n";
  1331. }
  1332. $ok .= "-"; # skipped
  1333. }
  1334. }
  1335. else {
  1336. $ok .= "-"; # valgrind not checked
  1337. }
  1338. # add 'E' for event-based
  1339. $ok .= $run_event_based ? "E" : "-";
  1340. logmsg "$ok " if(!$short);
  1341. # timestamp test result verification end
  1342. $timevrfyend{$testnum} = Time::HiRes::time();
  1343. return 0;
  1344. }
  1345. #######################################################################
  1346. # Report a successful test
  1347. sub singletest_success {
  1348. my ($testnum, $count, $total, $errorreturncode)=@_;
  1349. my $sofar= time()-$start;
  1350. my $esttotal = $sofar/$count * $total;
  1351. my $estleft = $esttotal - $sofar;
  1352. my $timeleft=sprintf("remaining: %02d:%02d",
  1353. $estleft/60,
  1354. $estleft%60);
  1355. my $took = $timevrfyend{$testnum} - $timeprepini{$testnum};
  1356. my $duration = sprintf("duration: %02d:%02d",
  1357. $sofar/60, $sofar%60);
  1358. if(!$automakestyle) {
  1359. logmsg sprintf("OK (%-3d out of %-3d, %s, took %.3fs, %s)\n",
  1360. $count, $total, $timeleft, $took, $duration);
  1361. }
  1362. else {
  1363. my $testname= (getpart("client", "name"))[0];
  1364. chomp $testname;
  1365. logmsg "PASS: $testnum - $testname\n";
  1366. }
  1367. if($errorreturncode==2) {
  1368. logmsg "Warning: test$testnum result is ignored, but passed!\n";
  1369. }
  1370. }
  1371. #######################################################################
  1372. # Run a single specified test case
  1373. #
  1374. sub singletest {
  1375. my ($testnum, $count, $total)=@_;
  1376. #######################################################################
  1377. # Verify that the test should be run
  1378. my ($why, $errorreturncode) = singletest_shouldrun($testnum);
  1379. #######################################################################
  1380. # Restore environment variables that were modified in a previous run.
  1381. # Test definition may instruct to (un)set environment vars.
  1382. # This is done this early so that leftover variables don't affect starting
  1383. # servers or CI registration.
  1384. restore_test_env(1);
  1385. #######################################################################
  1386. # Register the test case with the CI environment
  1387. citest_starttest($testnum);
  1388. if(!$why) {
  1389. $why = runner_test_preprocess($testnum);
  1390. } else {
  1391. # set zero servers verification time when they aren't started
  1392. $timesrvrini{$testnum} = $timesrvrend{$testnum} = Time::HiRes::time();
  1393. }
  1394. #######################################################################
  1395. # Print the test name and count tests
  1396. my $error;
  1397. $error = singletest_count($testnum, $why);
  1398. if($error || $listonly) {
  1399. return $error;
  1400. }
  1401. #######################################################################
  1402. # Execute this test number
  1403. my $cmdres;
  1404. my $CURLOUT;
  1405. my $tool;
  1406. my $disablevalgrind;
  1407. ($error, $cmdres, $CURLOUT, $tool, $disablevalgrind) = runner_test_run($testnum);
  1408. if($error == -1) {
  1409. # return a test failure, either to be reported or to be ignored
  1410. return $errorreturncode;
  1411. }
  1412. elsif($error == -2) {
  1413. timestampskippedevents($testnum);
  1414. return $error;
  1415. }
  1416. elsif($error > 0) {
  1417. return $error;
  1418. }
  1419. #######################################################################
  1420. # Verify that the test succeeded
  1421. $error = singletest_check($testnum, $cmdres, $CURLOUT, $tool, $disablevalgrind);
  1422. if($error == -1) {
  1423. # return a test failure, either to be reported or to be ignored
  1424. return $errorreturncode;
  1425. }
  1426. elsif($error == -2) {
  1427. # torture test; there is no verification, so the run result holds the
  1428. # test success code
  1429. return $cmdres;
  1430. }
  1431. #######################################################################
  1432. # Report a successful test
  1433. singletest_success($testnum, $count, $total, $errorreturncode);
  1434. return 0;
  1435. }
  1436. #######################################################################
  1437. # runtimestats displays test-suite run time statistics
  1438. #
  1439. sub runtimestats {
  1440. my $lasttest = $_[0];
  1441. return if(not $timestats);
  1442. logmsg "\nTest suite total running time breakdown per task...\n\n";
  1443. my @timesrvr;
  1444. my @timeprep;
  1445. my @timetool;
  1446. my @timelock;
  1447. my @timevrfy;
  1448. my @timetest;
  1449. my $timesrvrtot = 0.0;
  1450. my $timepreptot = 0.0;
  1451. my $timetooltot = 0.0;
  1452. my $timelocktot = 0.0;
  1453. my $timevrfytot = 0.0;
  1454. my $timetesttot = 0.0;
  1455. my $counter;
  1456. for my $testnum (1 .. $lasttest) {
  1457. if($timesrvrini{$testnum}) {
  1458. $timesrvrtot += $timesrvrend{$testnum} - $timesrvrini{$testnum};
  1459. $timepreptot +=
  1460. (($timetoolini{$testnum} - $timeprepini{$testnum}) -
  1461. ($timesrvrend{$testnum} - $timesrvrini{$testnum}));
  1462. $timetooltot += $timetoolend{$testnum} - $timetoolini{$testnum};
  1463. $timelocktot += $timesrvrlog{$testnum} - $timetoolend{$testnum};
  1464. $timevrfytot += $timevrfyend{$testnum} - $timesrvrlog{$testnum};
  1465. $timetesttot += $timevrfyend{$testnum} - $timeprepini{$testnum};
  1466. push @timesrvr, sprintf("%06.3f %04d",
  1467. $timesrvrend{$testnum} - $timesrvrini{$testnum}, $testnum);
  1468. push @timeprep, sprintf("%06.3f %04d",
  1469. ($timetoolini{$testnum} - $timeprepini{$testnum}) -
  1470. ($timesrvrend{$testnum} - $timesrvrini{$testnum}), $testnum);
  1471. push @timetool, sprintf("%06.3f %04d",
  1472. $timetoolend{$testnum} - $timetoolini{$testnum}, $testnum);
  1473. push @timelock, sprintf("%06.3f %04d",
  1474. $timesrvrlog{$testnum} - $timetoolend{$testnum}, $testnum);
  1475. push @timevrfy, sprintf("%06.3f %04d",
  1476. $timevrfyend{$testnum} - $timesrvrlog{$testnum}, $testnum);
  1477. push @timetest, sprintf("%06.3f %04d",
  1478. $timevrfyend{$testnum} - $timeprepini{$testnum}, $testnum);
  1479. }
  1480. }
  1481. {
  1482. no warnings 'numeric';
  1483. @timesrvr = sort { $b <=> $a } @timesrvr;
  1484. @timeprep = sort { $b <=> $a } @timeprep;
  1485. @timetool = sort { $b <=> $a } @timetool;
  1486. @timelock = sort { $b <=> $a } @timelock;
  1487. @timevrfy = sort { $b <=> $a } @timevrfy;
  1488. @timetest = sort { $b <=> $a } @timetest;
  1489. }
  1490. logmsg "Spent ". sprintf("%08.3f ", $timesrvrtot) .
  1491. "seconds starting and verifying test harness servers.\n";
  1492. logmsg "Spent ". sprintf("%08.3f ", $timepreptot) .
  1493. "seconds reading definitions and doing test preparations.\n";
  1494. logmsg "Spent ". sprintf("%08.3f ", $timetooltot) .
  1495. "seconds actually running test tools.\n";
  1496. logmsg "Spent ". sprintf("%08.3f ", $timelocktot) .
  1497. "seconds awaiting server logs lock removal.\n";
  1498. logmsg "Spent ". sprintf("%08.3f ", $timevrfytot) .
  1499. "seconds verifying test results.\n";
  1500. logmsg "Spent ". sprintf("%08.3f ", $timetesttot) .
  1501. "seconds doing all of the above.\n";
  1502. $counter = 25;
  1503. logmsg "\nTest server starting and verification time per test ".
  1504. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1505. logmsg "-time- test\n";
  1506. logmsg "------ ----\n";
  1507. foreach my $txt (@timesrvr) {
  1508. last if((not $fullstats) && (not $counter--));
  1509. logmsg "$txt\n";
  1510. }
  1511. $counter = 10;
  1512. logmsg "\nTest definition reading and preparation time per test ".
  1513. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1514. logmsg "-time- test\n";
  1515. logmsg "------ ----\n";
  1516. foreach my $txt (@timeprep) {
  1517. last if((not $fullstats) && (not $counter--));
  1518. logmsg "$txt\n";
  1519. }
  1520. $counter = 25;
  1521. logmsg "\nTest tool execution time per test ".
  1522. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1523. logmsg "-time- test\n";
  1524. logmsg "------ ----\n";
  1525. foreach my $txt (@timetool) {
  1526. last if((not $fullstats) && (not $counter--));
  1527. logmsg "$txt\n";
  1528. }
  1529. $counter = 15;
  1530. logmsg "\nTest server logs lock removal time per test ".
  1531. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1532. logmsg "-time- test\n";
  1533. logmsg "------ ----\n";
  1534. foreach my $txt (@timelock) {
  1535. last if((not $fullstats) && (not $counter--));
  1536. logmsg "$txt\n";
  1537. }
  1538. $counter = 10;
  1539. logmsg "\nTest results verification time per test ".
  1540. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1541. logmsg "-time- test\n";
  1542. logmsg "------ ----\n";
  1543. foreach my $txt (@timevrfy) {
  1544. last if((not $fullstats) && (not $counter--));
  1545. logmsg "$txt\n";
  1546. }
  1547. $counter = 50;
  1548. logmsg "\nTotal time per test ".
  1549. sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full");
  1550. logmsg "-time- test\n";
  1551. logmsg "------ ----\n";
  1552. foreach my $txt (@timetest) {
  1553. last if((not $fullstats) && (not $counter--));
  1554. logmsg "$txt\n";
  1555. }
  1556. logmsg "\n";
  1557. }
  1558. #######################################################################
  1559. # Check options to this test program
  1560. #
  1561. # Special case for CMake: replace '$TFLAGS' by the contents of the
  1562. # environment variable (if any).
  1563. if(@ARGV && $ARGV[-1] eq '$TFLAGS') {
  1564. pop @ARGV;
  1565. push(@ARGV, split(' ', $ENV{'TFLAGS'})) if defined($ENV{'TFLAGS'});
  1566. }
  1567. $valgrind = checktestcmd("valgrind");
  1568. my $number=0;
  1569. my $fromnum=-1;
  1570. my @testthis;
  1571. while(@ARGV) {
  1572. if ($ARGV[0] eq "-v") {
  1573. # verbose output
  1574. $verbose=1;
  1575. }
  1576. elsif ($ARGV[0] eq "-c") {
  1577. # use this path to curl instead of default
  1578. $DBGCURL=$CURL="\"$ARGV[1]\"";
  1579. shift @ARGV;
  1580. }
  1581. elsif ($ARGV[0] eq "-vc") {
  1582. # use this path to a curl used to verify servers
  1583. # Particularly useful when you introduce a crashing bug somewhere in
  1584. # the development version as then it won't be able to run any tests
  1585. # since it can't verify the servers!
  1586. $VCURL="\"$ARGV[1]\"";
  1587. shift @ARGV;
  1588. }
  1589. elsif ($ARGV[0] eq "-ac") {
  1590. # use this curl only to talk to APIs (currently only CI test APIs)
  1591. $ACURL="\"$ARGV[1]\"";
  1592. shift @ARGV;
  1593. }
  1594. elsif ($ARGV[0] eq "-d") {
  1595. # have the servers display protocol output
  1596. $debugprotocol=1;
  1597. }
  1598. elsif($ARGV[0] eq "-e") {
  1599. # run the tests cases event based if possible
  1600. $run_event_based=1;
  1601. }
  1602. elsif($ARGV[0] eq "-f") {
  1603. # force - run the test case even if listed in DISABLED
  1604. $run_disabled=1;
  1605. }
  1606. elsif($ARGV[0] eq "-E") {
  1607. # load additional reasons to skip tests
  1608. shift @ARGV;
  1609. my $exclude_file = $ARGV[0];
  1610. open(my $fd, "<", $exclude_file) or die "Couldn't open '$exclude_file': $!";
  1611. while(my $line = <$fd>) {
  1612. next if ($line =~ /^#/);
  1613. chomp $line;
  1614. my ($type, $patterns, $skip_reason) = split(/\s*:\s*/, $line, 3);
  1615. die "Unsupported type: $type\n" if($type !~ /^keyword|test|tool$/);
  1616. foreach my $pattern (split(/,/, $patterns)) {
  1617. if($type eq "test") {
  1618. # Strip leading zeros in the test number
  1619. $pattern = int($pattern);
  1620. }
  1621. $custom_skip_reasons{$type}{$pattern} = $skip_reason;
  1622. }
  1623. }
  1624. close($fd);
  1625. }
  1626. elsif ($ARGV[0] eq "-g") {
  1627. # run this test with gdb
  1628. $gdbthis=1;
  1629. }
  1630. elsif ($ARGV[0] eq "-gw") {
  1631. # run this test with windowed gdb
  1632. $gdbthis=1;
  1633. $gdbxwin=1;
  1634. }
  1635. elsif($ARGV[0] eq "-s") {
  1636. # short output
  1637. $short=1;
  1638. }
  1639. elsif($ARGV[0] eq "-am") {
  1640. # automake-style output
  1641. $short=1;
  1642. $automakestyle=1;
  1643. }
  1644. elsif($ARGV[0] eq "-n") {
  1645. # no valgrind
  1646. undef $valgrind;
  1647. }
  1648. elsif($ARGV[0] eq "--no-debuginfod") {
  1649. # disable the valgrind debuginfod functionality
  1650. $no_debuginfod = 1;
  1651. }
  1652. elsif ($ARGV[0] eq "-R") {
  1653. # execute in scrambled order
  1654. $scrambleorder=1;
  1655. }
  1656. elsif($ARGV[0] =~ /^-t(.*)/) {
  1657. # torture
  1658. $torture=1;
  1659. my $xtra = $1;
  1660. if($xtra =~ s/(\d+)$//) {
  1661. $tortalloc = $1;
  1662. }
  1663. }
  1664. elsif($ARGV[0] =~ /--shallow=(\d+)/) {
  1665. # Fail no more than this amount per tests when running
  1666. # torture.
  1667. my ($num)=($1);
  1668. $shallow=$num;
  1669. }
  1670. elsif($ARGV[0] =~ /--repeat=(\d+)/) {
  1671. # Repeat-run the given tests this many times
  1672. $repeat = $1;
  1673. }
  1674. elsif($ARGV[0] =~ /--seed=(\d+)/) {
  1675. # Set a fixed random seed (used for -R and --shallow)
  1676. $randseed = $1;
  1677. }
  1678. elsif($ARGV[0] eq "-a") {
  1679. # continue anyway, even if a test fail
  1680. $anyway=1;
  1681. }
  1682. elsif($ARGV[0] eq "-o") {
  1683. shift @ARGV;
  1684. if ($ARGV[0] =~ /^(\w+)=([\w.:\/\[\]-]+)$/) {
  1685. my ($variable, $value) = ($1, $2);
  1686. eval "\$$variable='$value'" or die "Failed to set \$$variable to $value: $@";
  1687. } else {
  1688. die "Failed to parse '-o $ARGV[0]'. May contain unexpected characters.\n";
  1689. }
  1690. }
  1691. elsif($ARGV[0] eq "-p") {
  1692. $postmortem=1;
  1693. }
  1694. elsif($ARGV[0] eq "-P") {
  1695. shift @ARGV;
  1696. $proxy_address=$ARGV[0];
  1697. }
  1698. elsif($ARGV[0] eq "-L") {
  1699. # require additional library file
  1700. shift @ARGV;
  1701. require $ARGV[0];
  1702. }
  1703. elsif($ARGV[0] eq "-l") {
  1704. # lists the test case names only
  1705. $listonly=1;
  1706. }
  1707. elsif($ARGV[0] eq "-k") {
  1708. # keep stdout and stderr files after tests
  1709. $keepoutfiles=1;
  1710. }
  1711. elsif($ARGV[0] eq "-r") {
  1712. # run time statistics needs Time::HiRes
  1713. if($Time::HiRes::VERSION) {
  1714. keys(%timeprepini) = 1000;
  1715. keys(%timesrvrini) = 1000;
  1716. keys(%timesrvrend) = 1000;
  1717. keys(%timetoolini) = 1000;
  1718. keys(%timetoolend) = 1000;
  1719. keys(%timesrvrlog) = 1000;
  1720. keys(%timevrfyend) = 1000;
  1721. $timestats=1;
  1722. $fullstats=0;
  1723. }
  1724. }
  1725. elsif($ARGV[0] eq "-rf") {
  1726. # run time statistics needs Time::HiRes
  1727. if($Time::HiRes::VERSION) {
  1728. keys(%timeprepini) = 1000;
  1729. keys(%timesrvrini) = 1000;
  1730. keys(%timesrvrend) = 1000;
  1731. keys(%timetoolini) = 1000;
  1732. keys(%timetoolend) = 1000;
  1733. keys(%timesrvrlog) = 1000;
  1734. keys(%timevrfyend) = 1000;
  1735. $timestats=1;
  1736. $fullstats=1;
  1737. }
  1738. }
  1739. elsif($ARGV[0] eq "-rm") {
  1740. # force removal of files by killing locking processes
  1741. $clearlocks=1;
  1742. }
  1743. elsif($ARGV[0] eq "-u") {
  1744. # error instead of warning on server unexpectedly alive
  1745. $err_unexpected=1;
  1746. }
  1747. elsif(($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
  1748. # show help text
  1749. print <<"EOHELP"
  1750. Usage: runtests.pl [options] [test selection(s)]
  1751. -a continue even if a test fails
  1752. -ac path use this curl only to talk to APIs (currently only CI test APIs)
  1753. -am automake style output PASS/FAIL: [number] [name]
  1754. -c path use this curl executable
  1755. -d display server debug info
  1756. -e event-based execution
  1757. -E file load the specified file to exclude certain tests
  1758. -f forcibly run even if disabled
  1759. -g run the test case with gdb
  1760. -gw run the test case with gdb as a windowed application
  1761. -h this help text
  1762. -k keep stdout and stderr files present after tests
  1763. -L path require an additional perl library file to replace certain functions
  1764. -l list all test case names/descriptions
  1765. -n no valgrind
  1766. --no-debuginfod disable the valgrind debuginfod functionality
  1767. -o variable=value set internal variable to the specified value
  1768. -P proxy use the specified proxy
  1769. -p print log file contents when a test fails
  1770. -R scrambled order (uses the random seed, see --seed)
  1771. -r run time statistics
  1772. -rf full run time statistics
  1773. -rm force removal of files by killing locking processes (Windows only)
  1774. --repeat=[num] run the given tests this many times
  1775. -s short output
  1776. --seed=[num] set the random seed to a fixed number
  1777. --shallow=[num] randomly makes the torture tests "thinner"
  1778. -t[N] torture (simulate function failures); N means fail Nth function
  1779. -u error instead of warning on server unexpectedly alive
  1780. -v verbose output
  1781. -vc path use this curl only to verify the existing servers
  1782. [num] like "5 6 9" or " 5 to 22 " to run those tests only
  1783. [!num] like "!5 !6 !9" to disable those tests
  1784. [~num] like "~5 ~6 ~9" to ignore the result of those tests
  1785. [keyword] like "IPv6" to select only tests containing the key word
  1786. [!keyword] like "!cookies" to disable any tests containing the key word
  1787. [~keyword] like "~cookies" to ignore results of tests containing key word
  1788. EOHELP
  1789. ;
  1790. exit;
  1791. }
  1792. elsif($ARGV[0] =~ /^(\d+)/) {
  1793. $number = $1;
  1794. if($fromnum >= 0) {
  1795. for my $n ($fromnum .. $number) {
  1796. push @testthis, $n;
  1797. }
  1798. $fromnum = -1;
  1799. }
  1800. else {
  1801. push @testthis, $1;
  1802. }
  1803. }
  1804. elsif($ARGV[0] =~ /^to$/i) {
  1805. $fromnum = $number+1;
  1806. }
  1807. elsif($ARGV[0] =~ /^!(\d+)/) {
  1808. $fromnum = -1;
  1809. $disabled{$1}=$1;
  1810. }
  1811. elsif($ARGV[0] =~ /^~(\d+)/) {
  1812. $fromnum = -1;
  1813. $ignored{$1}=$1;
  1814. }
  1815. elsif($ARGV[0] =~ /^!(.+)/) {
  1816. $disabled_keywords{lc($1)}=$1;
  1817. }
  1818. elsif($ARGV[0] =~ /^~(.+)/) {
  1819. $ignored_keywords{lc($1)}=$1;
  1820. }
  1821. elsif($ARGV[0] =~ /^([-[{a-zA-Z].*)/) {
  1822. $enabled_keywords{lc($1)}=$1;
  1823. }
  1824. else {
  1825. print "Unknown option: $ARGV[0]\n";
  1826. exit;
  1827. }
  1828. shift @ARGV;
  1829. }
  1830. delete $ENV{'DEBUGINFOD_URLS'} if($ENV{'DEBUGINFOD_URLS'} && $no_debuginfod);
  1831. if(!$randseed) {
  1832. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
  1833. localtime(time);
  1834. # seed of the month. December 2019 becomes 201912
  1835. $randseed = ($year+1900)*100 + $mon+1;
  1836. open(my $curlvh, "-|", "$CURL --version 2>/dev/null") ||
  1837. die "could not get curl version!";
  1838. my @c = <$curlvh>;
  1839. close($curlvh) || die "could not get curl version!";
  1840. # use the first line of output and get the md5 out of it
  1841. my $str = md5($c[0]);
  1842. $randseed += unpack('S', $str); # unsigned 16 bit value
  1843. }
  1844. srand $randseed;
  1845. if(@testthis && ($testthis[0] ne "")) {
  1846. $TESTCASES=join(" ", @testthis);
  1847. }
  1848. if($valgrind) {
  1849. # we have found valgrind on the host, use it
  1850. # verify that we can invoke it fine
  1851. my $code = runclient("valgrind >/dev/null 2>&1");
  1852. if(($code>>8) != 1) {
  1853. #logmsg "Valgrind failure, disable it\n";
  1854. undef $valgrind;
  1855. } else {
  1856. # since valgrind 2.1.x, '--tool' option is mandatory
  1857. # use it, if it is supported by the version installed on the system
  1858. # (this happened in 2003, so we could probably don't need to care about
  1859. # that old version any longer and just delete this check)
  1860. runclient("valgrind --help 2>&1 | grep -- --tool > /dev/null 2>&1");
  1861. if (($? >> 8)) {
  1862. $valgrind_tool="";
  1863. }
  1864. open(my $curlh, "<", "$CURL");
  1865. my $l = <$curlh>;
  1866. if($l =~ /^\#\!/) {
  1867. # A shell script. This is typically when built with libtool,
  1868. $valgrind="../libtool --mode=execute $valgrind";
  1869. }
  1870. close($curlh);
  1871. # valgrind 3 renamed the --logfile option to --log-file!!!
  1872. # (this happened in 2005, so we could probably don't need to care about
  1873. # that old version any longer and just delete this check)
  1874. my $ver=join(' ', runclientoutput("valgrind --version"));
  1875. # cut off all but digits and dots
  1876. $ver =~ s/[^0-9.]//g;
  1877. if($ver =~ /^(\d+)/) {
  1878. $ver = $1;
  1879. if($ver < 3) {
  1880. $valgrind_logfile="--logfile";
  1881. }
  1882. }
  1883. }
  1884. }
  1885. if ($gdbthis) {
  1886. # open the executable curl and read the first 4 bytes of it
  1887. open(my $check, "<", "$CURL");
  1888. my $c;
  1889. sysread $check, $c, 4;
  1890. close($check);
  1891. if($c eq "#! /") {
  1892. # A shell script. This is typically when built with libtool,
  1893. $libtool = 1;
  1894. $gdb = "../libtool --mode=execute gdb";
  1895. }
  1896. }
  1897. #######################################################################
  1898. # clear and create logging directory:
  1899. #
  1900. cleardir($LOGDIR);
  1901. mkdir($LOGDIR, 0777);
  1902. mkdir($PIDDIR, 0777);
  1903. #######################################################################
  1904. # initialize some variables
  1905. #
  1906. get_disttests();
  1907. #######################################################################
  1908. # Output curl version and host info being tested
  1909. #
  1910. if(!$listonly) {
  1911. unlink($memdump); # remove this if there was one left
  1912. checksystemfeatures();
  1913. }
  1914. #######################################################################
  1915. # initialize configuration needed to set up servers
  1916. #
  1917. initserverconfig();
  1918. if(!$listonly) {
  1919. # these can only be displayed after initserverconfig() has been called
  1920. displayserverfeatures();
  1921. # globally disabled tests
  1922. disabledtests("$TESTDIR/DISABLED");
  1923. }
  1924. #######################################################################
  1925. # Fetch all disabled tests, if there are any
  1926. #
  1927. sub disabledtests {
  1928. my ($file) = @_;
  1929. my @input;
  1930. if(open(my $disabledh, "<", "$file")) {
  1931. while(<$disabledh>) {
  1932. if(/^ *\#/) {
  1933. # allow comments
  1934. next;
  1935. }
  1936. push @input, $_;
  1937. }
  1938. close($disabledh);
  1939. # preprocess the input to make conditionally disabled tests depending
  1940. # on variables
  1941. my @pp = prepro(0, @input);
  1942. for my $t (@pp) {
  1943. if($t =~ /(\d+)/) {
  1944. my ($n) = $1;
  1945. $disabled{$n}=$n; # disable this test number
  1946. if(! -f "$srcdir/data/test$n") {
  1947. print STDERR "WARNING! Non-existing test $n in $file!\n";
  1948. # fail hard to make user notice
  1949. exit 1;
  1950. }
  1951. logmsg "DISABLED: test $n\n" if ($verbose);
  1952. }
  1953. else {
  1954. print STDERR "$file: rubbish content: $t\n";
  1955. exit 2;
  1956. }
  1957. }
  1958. }
  1959. }
  1960. #######################################################################
  1961. # If 'all' tests are requested, find out all test numbers
  1962. #
  1963. if ( $TESTCASES eq "all") {
  1964. # Get all commands and find out their test numbers
  1965. opendir(DIR, $TESTDIR) || die "can't opendir $TESTDIR: $!";
  1966. my @cmds = grep { /^test([0-9]+)$/ && -f "$TESTDIR/$_" } readdir(DIR);
  1967. closedir(DIR);
  1968. $TESTCASES=""; # start with no test cases
  1969. # cut off everything but the digits
  1970. for(@cmds) {
  1971. $_ =~ s/[a-z\/\.]*//g;
  1972. }
  1973. # sort the numbers from low to high
  1974. foreach my $n (sort { $a <=> $b } @cmds) {
  1975. if($disabled{$n}) {
  1976. # skip disabled test cases
  1977. my $why = "configured as DISABLED";
  1978. $skipped{$why}++;
  1979. $teststat[$n]=$why; # store reason for this test case
  1980. next;
  1981. }
  1982. $TESTCASES .= " $n";
  1983. }
  1984. }
  1985. else {
  1986. my $verified="";
  1987. for(split(" ", $TESTCASES)) {
  1988. if (-e "$TESTDIR/test$_") {
  1989. $verified.="$_ ";
  1990. }
  1991. }
  1992. if($verified eq "") {
  1993. print "No existing test cases were specified\n";
  1994. exit;
  1995. }
  1996. $TESTCASES = $verified;
  1997. }
  1998. if($repeat) {
  1999. my $s;
  2000. for(1 .. $repeat) {
  2001. $s .= $TESTCASES;
  2002. }
  2003. $TESTCASES = $s;
  2004. }
  2005. if($scrambleorder) {
  2006. # scramble the order of the test cases
  2007. my @rand;
  2008. while($TESTCASES) {
  2009. my @all = split(/ +/, $TESTCASES);
  2010. if(!$all[0]) {
  2011. # if the first is blank, shift away it
  2012. shift @all;
  2013. }
  2014. my $r = rand @all;
  2015. push @rand, $all[$r];
  2016. $all[$r]="";
  2017. $TESTCASES = join(" ", @all);
  2018. }
  2019. $TESTCASES = join(" ", @rand);
  2020. }
  2021. # Display the contents of the given file. Line endings are canonicalized
  2022. # and excessively long files are elided
  2023. sub displaylogcontent {
  2024. my ($file)=@_;
  2025. if(open(my $single, "<", "$file")) {
  2026. my $linecount = 0;
  2027. my $truncate;
  2028. my @tail;
  2029. while(my $string = <$single>) {
  2030. $string =~ s/\r\n/\n/g;
  2031. $string =~ s/[\r\f\032]/\n/g;
  2032. $string .= "\n" unless ($string =~ /\n$/);
  2033. $string =~ tr/\n//;
  2034. for my $line (split(m/\n/, $string)) {
  2035. $line =~ s/\s*\!$//;
  2036. if ($truncate) {
  2037. push @tail, " $line\n";
  2038. } else {
  2039. logmsg " $line\n";
  2040. }
  2041. $linecount++;
  2042. $truncate = $linecount > 1000;
  2043. }
  2044. }
  2045. close($single);
  2046. if(@tail) {
  2047. my $tailshow = 200;
  2048. my $tailskip = 0;
  2049. my $tailtotal = scalar @tail;
  2050. if($tailtotal > $tailshow) {
  2051. $tailskip = $tailtotal - $tailshow;
  2052. logmsg "=== File too long: $tailskip lines omitted here\n";
  2053. }
  2054. for($tailskip .. $tailtotal-1) {
  2055. logmsg "$tail[$_]";
  2056. }
  2057. }
  2058. }
  2059. }
  2060. sub displaylogs {
  2061. my ($testnum)=@_;
  2062. opendir(DIR, "$LOGDIR") ||
  2063. die "can't open dir: $!";
  2064. my @logs = readdir(DIR);
  2065. closedir(DIR);
  2066. logmsg "== Contents of files in the $LOGDIR/ dir after test $testnum\n";
  2067. foreach my $log (sort @logs) {
  2068. if($log =~ /\.(\.|)$/) {
  2069. next; # skip "." and ".."
  2070. }
  2071. if($log =~ /^\.nfs/) {
  2072. next; # skip ".nfs"
  2073. }
  2074. if(($log eq "memdump") || ($log eq "core")) {
  2075. next; # skip "memdump" and "core"
  2076. }
  2077. if((-d "$LOGDIR/$log") || (! -s "$LOGDIR/$log")) {
  2078. next; # skip directory and empty files
  2079. }
  2080. if(($log =~ /^stdout\d+/) && ($log !~ /^stdout$testnum/)) {
  2081. next; # skip stdoutNnn of other tests
  2082. }
  2083. if(($log =~ /^stderr\d+/) && ($log !~ /^stderr$testnum/)) {
  2084. next; # skip stderrNnn of other tests
  2085. }
  2086. if(($log =~ /^upload\d+/) && ($log !~ /^upload$testnum/)) {
  2087. next; # skip uploadNnn of other tests
  2088. }
  2089. if(($log =~ /^curl\d+\.out/) && ($log !~ /^curl$testnum\.out/)) {
  2090. next; # skip curlNnn.out of other tests
  2091. }
  2092. if(($log =~ /^test\d+\.txt/) && ($log !~ /^test$testnum\.txt/)) {
  2093. next; # skip testNnn.txt of other tests
  2094. }
  2095. if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
  2096. next; # skip fileNnn.txt of other tests
  2097. }
  2098. if(($log =~ /^netrc\d+/) && ($log !~ /^netrc$testnum/)) {
  2099. next; # skip netrcNnn of other tests
  2100. }
  2101. if(($log =~ /^trace\d+/) && ($log !~ /^trace$testnum/)) {
  2102. next; # skip traceNnn of other tests
  2103. }
  2104. if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(?:\..*)?$/)) {
  2105. next; # skip valgrindNnn of other tests
  2106. }
  2107. if(($log =~ /^test$testnum$/)) {
  2108. next; # skip test$testnum since it can be very big
  2109. }
  2110. logmsg "=== Start of file $log\n";
  2111. displaylogcontent("$LOGDIR/$log");
  2112. logmsg "=== End of file $log\n";
  2113. }
  2114. }
  2115. #######################################################################
  2116. # Setup CI Test Run
  2117. citest_starttestrun();
  2118. #######################################################################
  2119. # The main test-loop
  2120. #
  2121. my $failed;
  2122. my $failedign;
  2123. my $ok=0;
  2124. my $ign=0;
  2125. my $total=0;
  2126. my $lasttest=0;
  2127. my @at = split(" ", $TESTCASES);
  2128. my $count=0;
  2129. $start = time();
  2130. foreach my $testnum (@at) {
  2131. $lasttest = $testnum if($testnum > $lasttest);
  2132. $count++;
  2133. # execute one test case
  2134. my $error = singletest($testnum, $count, scalar(@at));
  2135. # Submit the test case result with the CI environment
  2136. citest_finishtest($testnum, $error);
  2137. if($error < 0) {
  2138. # not a test we can run
  2139. next;
  2140. }
  2141. $total++; # number of tests we've run
  2142. if($error>0) {
  2143. if($error==2) {
  2144. # ignored test failures
  2145. $failedign .= "$testnum ";
  2146. }
  2147. else {
  2148. $failed.= "$testnum ";
  2149. }
  2150. if($postmortem) {
  2151. # display all files in $LOGDIR/ in a nice way
  2152. displaylogs($testnum);
  2153. }
  2154. if($error==2) {
  2155. $ign++; # ignored test result counter
  2156. }
  2157. elsif(!$anyway) {
  2158. # a test failed, abort
  2159. logmsg "\n - abort tests\n";
  2160. last;
  2161. }
  2162. }
  2163. elsif(!$error) {
  2164. $ok++; # successful test counter
  2165. }
  2166. # loop for next test
  2167. }
  2168. my $sofar = time() - $start;
  2169. #######################################################################
  2170. # Finish CI Test Run
  2171. citest_finishtestrun();
  2172. # Tests done, stop the servers
  2173. my $unexpected = stopservers($verbose);
  2174. my $numskipped = %skipped ? sum values %skipped : 0;
  2175. my $all = $total + $numskipped;
  2176. runtimestats($lasttest);
  2177. if($all) {
  2178. logmsg "TESTDONE: $all tests were considered during ".
  2179. sprintf("%.0f", $sofar) ." seconds.\n";
  2180. }
  2181. if(%skipped && !$short) {
  2182. my $s=0;
  2183. # Temporary hash to print the restraints sorted by the number
  2184. # of their occurrences
  2185. my %restraints;
  2186. logmsg "TESTINFO: $numskipped tests were skipped due to these restraints:\n";
  2187. for(keys %skipped) {
  2188. my $r = $_;
  2189. my $skip_count = $skipped{$r};
  2190. my $log_line = sprintf("TESTINFO: \"%s\" %d time%s (", $r, $skip_count,
  2191. ($skip_count == 1) ? "" : "s");
  2192. # now gather all test case numbers that had this reason for being
  2193. # skipped
  2194. my $c=0;
  2195. my $max = 9;
  2196. for(0 .. scalar @teststat) {
  2197. my $t = $_;
  2198. if($teststat[$t] && ($teststat[$t] eq $r)) {
  2199. if($c < $max) {
  2200. $log_line .= ", " if($c);
  2201. $log_line .= $t;
  2202. }
  2203. $c++;
  2204. }
  2205. }
  2206. if($c > $max) {
  2207. $log_line .= " and ".($c-$max)." more";
  2208. }
  2209. $log_line .= ")\n";
  2210. $restraints{$log_line} = $skip_count;
  2211. }
  2212. foreach my $log_line (sort {$restraints{$b} <=> $restraints{$a}} keys %restraints) {
  2213. logmsg $log_line;
  2214. }
  2215. }
  2216. if($total) {
  2217. if($failedign) {
  2218. logmsg "IGNORED: failed tests: $failedign\n";
  2219. }
  2220. logmsg sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
  2221. $ok/$total*100);
  2222. if($failed && ($ok != $total)) {
  2223. logmsg "\nTESTFAIL: These test cases failed: $failed\n\n";
  2224. }
  2225. }
  2226. else {
  2227. logmsg "\nTESTFAIL: No tests were performed\n\n";
  2228. if(scalar(keys %enabled_keywords)) {
  2229. logmsg "TESTFAIL: Nothing matched these keywords: ";
  2230. for(keys %enabled_keywords) {
  2231. logmsg "$_ ";
  2232. }
  2233. logmsg "\n";
  2234. }
  2235. }
  2236. if(($total && (($ok+$ign) != $total)) || !$total || $unexpected) {
  2237. exit 1;
  2238. }