From: Steve Holme Date: Sun, 23 Feb 2020 08:20:32 +0000 (+0000) Subject: tests: Automatically deduce the tool name from the test case for unit tests X-Git-Tag: curl-7_69_0~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0922f762407cc20c90f8f5cfa01c5eafbdfecde0;p=thirdparty%2Fcurl.git tests: Automatically deduce the tool name from the test case for unit tests It is still possible to override the executable to run during the test, using the tag, but this patch removes the requirement that the tag must be present for unit tests. It also removes the possibility of human error when existing test cases are used as the basis for new tests, as recently witnessed in 81c37124. Reviewed-by: Daniel Stenberg Closes #4976 --- diff --git a/tests/data/test1300 b/tests/data/test1300 index 1008885616..1183412130 100644 --- a/tests/data/test1300 +++ b/tests/data/test1300 @@ -18,9 +18,5 @@ unittest llist unit tests - -unit1300 - - diff --git a/tests/data/test1301 b/tests/data/test1301 index 8506c0005e..5aea24b654 100644 --- a/tests/data/test1301 +++ b/tests/data/test1301 @@ -18,9 +18,5 @@ unittest curl_strcasecompare unit tests - -unit1301 - - diff --git a/tests/data/test1302 b/tests/data/test1302 index 27ea862485..9e9039cac6 100644 --- a/tests/data/test1302 +++ b/tests/data/test1302 @@ -18,9 +18,5 @@ unittest base64 encode/decode unit tests - -unit1302 - - diff --git a/tests/data/test1303 b/tests/data/test1303 index 925b47e15d..bb23352df1 100644 --- a/tests/data/test1303 +++ b/tests/data/test1303 @@ -18,9 +18,5 @@ unittest Curl_timeleft unit tests - -unit1303 - - diff --git a/tests/data/test1304 b/tests/data/test1304 index d518de9e4c..b402bfc8be 100644 --- a/tests/data/test1304 +++ b/tests/data/test1304 @@ -18,13 +18,9 @@ unittest netrc parsing unit tests - -unit1304 - machine example.com login admin password passwd machine curl.example.com login none password none - diff --git a/tests/data/test1305 b/tests/data/test1305 index 91149b3ad5..52efbcbb01 100644 --- a/tests/data/test1305 +++ b/tests/data/test1305 @@ -19,12 +19,8 @@ unittest internal hash create/destroy testing - -unit1305 - 1305 - diff --git a/tests/data/test1307 b/tests/data/test1307 index c4f7ac7295..f0e96bfa01 100644 --- a/tests/data/test1307 +++ b/tests/data/test1307 @@ -20,9 +20,5 @@ ftp internal Curl_fnmatch() testing - -unit1307 - - diff --git a/tests/data/test1308 b/tests/data/test1308 index 88e9771ddf..3755ef8b41 100644 --- a/tests/data/test1308 +++ b/tests/data/test1308 @@ -20,12 +20,8 @@ http formpost unit tests - -unit1308 - Piece of the file that is to uploaded as a formpost - diff --git a/tests/data/test1309 b/tests/data/test1309 index 0e0cad1e81..7005d5f13c 100644 --- a/tests/data/test1309 +++ b/tests/data/test1309 @@ -18,9 +18,6 @@ unittest splay unit tests - -unit1309 - @@ -1564,5 +1561,4 @@ removed payload 1013[1] removed payload 1013[2] - diff --git a/tests/data/test1323 b/tests/data/test1323 index ec3ff98197..66bac61ff7 100644 --- a/tests/data/test1323 +++ b/tests/data/test1323 @@ -23,9 +23,6 @@ unittest curlx_tvdiff - -unit1323 - # diff --git a/tests/data/test1330 b/tests/data/test1330 index a78dc30b8d..ce04e3331e 100644 --- a/tests/data/test1330 +++ b/tests/data/test1330 @@ -20,11 +20,6 @@ none unittest TrackMemory -# tool is what to use instead of 'curl' - -unit1330 - - unit tests memory tracking operational @@ -48,5 +43,4 @@ s:^(MEM )(.*/)(.*):$1$3: s/\r\n/\n/ - diff --git a/tests/data/test1394 b/tests/data/test1394 index 34d4a0e370..d3ffb2d33f 100644 --- a/tests/data/test1394 +++ b/tests/data/test1394 @@ -17,14 +17,10 @@ unittest unit test for parse_cert_parameter() - -unit1394 - - diff --git a/tests/data/test1395 b/tests/data/test1395 index 967c8d4921..409e0d631b 100644 --- a/tests/data/test1395 +++ b/tests/data/test1395 @@ -17,10 +17,5 @@ unittest Curl_dedotdotify - -unit1395 - - - diff --git a/tests/data/test1396 b/tests/data/test1396 index 8ffe35f4ca..d8b432d8b1 100644 --- a/tests/data/test1396 +++ b/tests/data/test1396 @@ -19,9 +19,6 @@ unittest curl_easy_escape and curl_easy_unescape - -unit1396 - diff --git a/tests/data/test1397 b/tests/data/test1397 index 5f479b4685..84f962abeb 100644 --- a/tests/data/test1397 +++ b/tests/data/test1397 @@ -19,9 +19,6 @@ unittest Check wildcard certificate matching function Curl_cert_hostcheck - -unit1397 - diff --git a/tests/data/test1398 b/tests/data/test1398 index dd50baa624..436cac82d4 100644 --- a/tests/data/test1398 +++ b/tests/data/test1398 @@ -18,9 +18,6 @@ unittest curl_msnprintf unit tests - -unit1398 - diff --git a/tests/data/test1399 b/tests/data/test1399 index fe3879df10..6d6ec7a5b0 100644 --- a/tests/data/test1399 +++ b/tests/data/test1399 @@ -18,9 +18,5 @@ unittest Curl_pgrsTime unit tests - -unit1399 - - diff --git a/tests/data/test1600 b/tests/data/test1600 index 88040747a1..33413d7c39 100644 --- a/tests/data/test1600 +++ b/tests/data/test1600 @@ -19,9 +19,5 @@ NTLM NTLM unit tests - -unit1600 - - diff --git a/tests/data/test1601 b/tests/data/test1601 index 125493bb01..2065fdd1d8 100644 --- a/tests/data/test1601 +++ b/tests/data/test1601 @@ -18,9 +18,5 @@ unittest MD5 unit tests - -unit1601 - - diff --git a/tests/data/test1602 b/tests/data/test1602 index 4717058ced..56e243ff8a 100644 --- a/tests/data/test1602 +++ b/tests/data/test1602 @@ -18,9 +18,5 @@ unittest Internal hash create/add/destroy testing, exercising clean functions - -unit1602 - - diff --git a/tests/data/test1603 b/tests/data/test1603 index 805c9e378c..406d197eeb 100644 --- a/tests/data/test1603 +++ b/tests/data/test1603 @@ -18,9 +18,5 @@ unittest Internal hash add, retrieval, deletion testing - -unit1603 - - diff --git a/tests/data/test1604 b/tests/data/test1604 index cf207750de..39daf9ddc5 100644 --- a/tests/data/test1604 +++ b/tests/data/test1604 @@ -17,9 +17,5 @@ unittest Test WIN32/MSDOS filename sanitization - -unit1604 - - diff --git a/tests/data/test1605 b/tests/data/test1605 index 09ef66942c..a123b01a1d 100644 --- a/tests/data/test1605 +++ b/tests/data/test1605 @@ -17,9 +17,5 @@ unittest Test negative data lengths as input to libcurl functions - -unit1605 - - diff --git a/tests/data/test1606 b/tests/data/test1606 index 15488d4077..83e9844270 100644 --- a/tests/data/test1606 +++ b/tests/data/test1606 @@ -18,9 +18,5 @@ unittest verify speedcheck - -unit1606 - - diff --git a/tests/data/test1607 b/tests/data/test1607 index 9628324e41..6d28d6eb49 100644 --- a/tests/data/test1607 +++ b/tests/data/test1607 @@ -18,9 +18,5 @@ unittest CURLOPT_RESOLVE parsing - -unit1607 - - diff --git a/tests/data/test1608 b/tests/data/test1608 index 7023107574..fbc6238958 100644 --- a/tests/data/test1608 +++ b/tests/data/test1608 @@ -18,9 +18,5 @@ unittest verify DNS shuffling - -unit1608 - - diff --git a/tests/data/test1609 b/tests/data/test1609 index c1b7c7a111..6d28d6eb49 100644 --- a/tests/data/test1609 +++ b/tests/data/test1609 @@ -18,9 +18,5 @@ unittest CURLOPT_RESOLVE parsing - -unit1609 - - diff --git a/tests/data/test1610 b/tests/data/test1610 index 2228515e9f..fff973371d 100644 --- a/tests/data/test1610 +++ b/tests/data/test1610 @@ -18,9 +18,5 @@ unittest SHA256 unit tests - -unit1610 - - diff --git a/tests/data/test1611 b/tests/data/test1611 index 151d321f4d..008aea7ec4 100644 --- a/tests/data/test1611 +++ b/tests/data/test1611 @@ -18,9 +18,5 @@ unittest MD4 unit tests - -unit1611 - - diff --git a/tests/data/test1612 b/tests/data/test1612 index c9a772be32..3e92b67912 100644 --- a/tests/data/test1612 +++ b/tests/data/test1612 @@ -18,9 +18,5 @@ unittest HMAC unit tests - -unit1612 - - diff --git a/tests/data/test1620 b/tests/data/test1620 index 83b08c7a81..038bbcc1b4 100644 --- a/tests/data/test1620 +++ b/tests/data/test1620 @@ -18,9 +18,5 @@ unittest unit tests for url.c - -unit1620 - - diff --git a/tests/data/test1621 b/tests/data/test1621 index 1117d1bd2a..62c81052ff 100644 --- a/tests/data/test1621 +++ b/tests/data/test1621 @@ -19,9 +19,5 @@ https unit tests for stripcredentials from URL - -unit1621 - - diff --git a/tests/data/test1650 b/tests/data/test1650 index 7a02a6dac4..6248b9814d 100644 --- a/tests/data/test1650 +++ b/tests/data/test1650 @@ -19,9 +19,5 @@ DoH DOH - -unit1650 - - diff --git a/tests/data/test1651 b/tests/data/test1651 index 28a9b714c6..d29974bf20 100644 --- a/tests/data/test1651 +++ b/tests/data/test1651 @@ -18,9 +18,5 @@ unittest x509 parsing - -unit1651 - - diff --git a/tests/data/test1652 b/tests/data/test1652 index c411690194..678d195178 100644 --- a/tests/data/test1652 +++ b/tests/data/test1652 @@ -16,8 +16,5 @@ unittest infof - -unit1652 - diff --git a/tests/data/test1653 b/tests/data/test1653 index 0de2c14b5a..59ec3f3962 100644 --- a/tests/data/test1653 +++ b/tests/data/test1653 @@ -16,8 +16,5 @@ unittest urlapi - -unit1653 - diff --git a/tests/data/test1654 b/tests/data/test1654 index 6a82daa081..6155635ab0 100644 --- a/tests/data/test1654 +++ b/tests/data/test1654 @@ -26,9 +26,6 @@ alt-svc log/1654 - -unit1654 - h2 example.com 443 h3 shiny.example.com 8443 "20191231 00:00:00" 0 1 # a comment diff --git a/tests/data/test1655 b/tests/data/test1655 index 2e73f55d9b..e161fb6621 100644 --- a/tests/data/test1655 +++ b/tests/data/test1655 @@ -19,9 +19,5 @@ DoH unit test for doh_encode - -unit1655 - - diff --git a/tests/runtests.pl b/tests/runtests.pl index bef95574da..61953ea642 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -296,7 +296,8 @@ my %timevrfyend; # timestamp for each test result verification end my $testnumcheck; # test number, set in singletest sub. my %oldenv; -my %feature; # array of enabled features +my %feature; # array of enabled features +my %keywords; # array of keywords from the test spec ####################################################################### # variables that command line options may set @@ -3306,21 +3307,26 @@ sub singletest { } if(!$why) { - my @keywords = getpart("info", "keywords"); + my @info_keywords = getpart("info", "keywords"); my $match; my $k; - if(!$keywords[0]) { + # Clear the list of keywords from the last test + %keywords = (); + + if(!$info_keywords[0]) { $why = "missing the section!"; } - for $k (@keywords) { + for $k (@info_keywords) { chomp $k; if ($disabled_keywords{lc($k)}) { $why = "disabled by keyword"; } elsif ($enabled_keywords{lc($k)}) { $match = 1; } + + $keywords{$k} = 1; } if(!$why && !$match && %enabled_keywords) { @@ -3616,7 +3622,7 @@ sub singletest { $tool=$CMDLINE; $disablevalgrind=1; } - elsif(!$tool) { + elsif(!$tool && !$keywords{"unittest"}) { # run curl, add suitable command line options my $inc=""; if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) { @@ -3636,6 +3642,11 @@ sub singletest { $cmdargs = " $cmd"; # $cmd is the command line for the test file $CURLOUT = $STDOUT; # sends received data to stdout + # Default the tool to a unit test with the same name as the test spec + if($keywords{"unittest"} && !$tool) { + $tool="unit$testnum"; + } + if($tool =~ /^lib/) { $CMDLINE="$LIBDIR/$tool"; }