diff options
author | Steve Holme <steve_holme@hotmail.com> | 2020-02-23 08:20:32 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2020-02-27 00:51:49 +0000 |
commit | 0922f762407cc20c90f8f5cfa01c5eafbdfecde0 (patch) | |
tree | 9a3a672688a9197c66b66338e6c2a994e37b18d6 | |
parent | d9e40f57de17bff9e96f76f502e611dd1b70feac (diff) | |
download | curl-0922f762407cc20c90f8f5cfa01c5eafbdfecde0.tar.gz |
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 <tool> 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
39 files changed, 16 insertions, 153 deletions
diff --git a/tests/data/test1300 b/tests/data/test1300 index 100888561..118341213 100644 --- a/tests/data/test1300 +++ b/tests/data/test1300 @@ -18,9 +18,5 @@ unittest <name> llist unit tests </name> -<tool> -unit1300 -</tool> </client> - </testcase> diff --git a/tests/data/test1301 b/tests/data/test1301 index 8506c0005..5aea24b65 100644 --- a/tests/data/test1301 +++ b/tests/data/test1301 @@ -18,9 +18,5 @@ unittest <name> curl_strcasecompare unit tests </name> -<tool> -unit1301 -</tool> </client> - </testcase> diff --git a/tests/data/test1302 b/tests/data/test1302 index 27ea86248..9e9039cac 100644 --- a/tests/data/test1302 +++ b/tests/data/test1302 @@ -18,9 +18,5 @@ unittest <name> base64 encode/decode unit tests </name> -<tool> -unit1302 -</tool> </client> - </testcase> diff --git a/tests/data/test1303 b/tests/data/test1303 index 925b47e15..bb23352df 100644 --- a/tests/data/test1303 +++ b/tests/data/test1303 @@ -18,9 +18,5 @@ unittest <name> Curl_timeleft unit tests </name> -<tool> -unit1303 -</tool> </client> - </testcase> diff --git a/tests/data/test1304 b/tests/data/test1304 index d518de9e4..b402bfc8b 100644 --- a/tests/data/test1304 +++ b/tests/data/test1304 @@ -18,13 +18,9 @@ unittest <name> netrc parsing unit tests </name> -<tool> -unit1304 -</tool> <file name="log/netrc1304"> machine example.com login admin password passwd machine curl.example.com login none password none </file> </client> - </testcase> diff --git a/tests/data/test1305 b/tests/data/test1305 index 91149b3ad..52efbcbb0 100644 --- a/tests/data/test1305 +++ b/tests/data/test1305 @@ -19,12 +19,8 @@ unittest <name> internal hash create/destroy testing </name> -<tool> -unit1305 -</tool> <command> 1305 </command> </client> - </testcase> diff --git a/tests/data/test1307 b/tests/data/test1307 index c4f7ac729..f0e96bfa0 100644 --- a/tests/data/test1307 +++ b/tests/data/test1307 @@ -20,9 +20,5 @@ ftp <name> internal Curl_fnmatch() testing </name> -<tool> -unit1307 -</tool> </client> - </testcase> diff --git a/tests/data/test1308 b/tests/data/test1308 index 88e9771dd..3755ef8b4 100644 --- a/tests/data/test1308 +++ b/tests/data/test1308 @@ -20,12 +20,8 @@ http <name> formpost unit tests </name> -<tool> -unit1308 -</tool> <file name="log/test-1308"> Piece of the file that is to uploaded as a formpost </file> </client> - </testcase> diff --git a/tests/data/test1309 b/tests/data/test1309 index 0e0cad1e8..7005d5f13 100644 --- a/tests/data/test1309 +++ b/tests/data/test1309 @@ -18,9 +18,6 @@ unittest <name> splay unit tests </name> -<tool> -unit1309 -</tool> </client> <verify> @@ -1564,5 +1561,4 @@ removed payload 1013[1] removed payload 1013[2] </stdout> </verify> - </testcase> diff --git a/tests/data/test1323 b/tests/data/test1323 index ec3ff9819..66bac61ff 100644 --- a/tests/data/test1323 +++ b/tests/data/test1323 @@ -23,9 +23,6 @@ unittest <name> curlx_tvdiff </name> -<tool> -unit1323 -</tool> </client> # diff --git a/tests/data/test1330 b/tests/data/test1330 index a78dc30b8..ce04e3331 100644 --- a/tests/data/test1330 +++ b/tests/data/test1330 @@ -20,11 +20,6 @@ none unittest TrackMemory </features> -# tool is what to use instead of 'curl' -<tool> -unit1330 -</tool> - <name> unit tests memory tracking operational </name> @@ -48,5 +43,4 @@ s:^(MEM )(.*/)(.*):$1$3: s/\r\n/\n/ </stripfile> </verify> - </testcase> diff --git a/tests/data/test1394 b/tests/data/test1394 index 34d4a0e37..d3ffb2d33 100644 --- a/tests/data/test1394 +++ b/tests/data/test1394 @@ -17,14 +17,10 @@ unittest <name> unit test for parse_cert_parameter() </name> -<tool> -unit1394 -</tool> </client> <verify> <stdout mode="text"> </stdout> </verify> - </testcase> diff --git a/tests/data/test1395 b/tests/data/test1395 index 967c8d492..409e0d631 100644 --- a/tests/data/test1395 +++ b/tests/data/test1395 @@ -17,10 +17,5 @@ unittest <name> Curl_dedotdotify </name> -<tool> -unit1395 -</tool> - </client> - </testcase> diff --git a/tests/data/test1396 b/tests/data/test1396 index 8ffe35f4c..d8b432d8b 100644 --- a/tests/data/test1396 +++ b/tests/data/test1396 @@ -19,9 +19,6 @@ unittest <name> curl_easy_escape and curl_easy_unescape </name> -<tool> -unit1396 -</tool> </client> </testcase> diff --git a/tests/data/test1397 b/tests/data/test1397 index 5f479b468..84f962abe 100644 --- a/tests/data/test1397 +++ b/tests/data/test1397 @@ -19,9 +19,6 @@ unittest <name> Check wildcard certificate matching function Curl_cert_hostcheck </name> -<tool> -unit1397 -</tool> </client> </testcase> diff --git a/tests/data/test1398 b/tests/data/test1398 index dd50baa62..436cac82d 100644 --- a/tests/data/test1398 +++ b/tests/data/test1398 @@ -18,9 +18,6 @@ unittest <name> curl_msnprintf unit tests </name> -<tool> -unit1398 -</tool> </client> </testcase> diff --git a/tests/data/test1399 b/tests/data/test1399 index fe3879df1..6d6ec7a5b 100644 --- a/tests/data/test1399 +++ b/tests/data/test1399 @@ -18,9 +18,5 @@ unittest <name> Curl_pgrsTime unit tests </name> -<tool> -unit1399 -</tool> </client> - </testcase> diff --git a/tests/data/test1600 b/tests/data/test1600 index 88040747a..33413d7c3 100644 --- a/tests/data/test1600 +++ b/tests/data/test1600 @@ -19,9 +19,5 @@ NTLM <name> NTLM unit tests </name> -<tool> -unit1600 -</tool> </client> - </testcase> diff --git a/tests/data/test1601 b/tests/data/test1601 index 125493bb0..2065fdd1d 100644 --- a/tests/data/test1601 +++ b/tests/data/test1601 @@ -18,9 +18,5 @@ unittest <name> MD5 unit tests </name> -<tool> -unit1601 -</tool> </client> - </testcase> diff --git a/tests/data/test1602 b/tests/data/test1602 index 4717058ce..56e243ff8 100644 --- a/tests/data/test1602 +++ b/tests/data/test1602 @@ -18,9 +18,5 @@ unittest <name> Internal hash create/add/destroy testing, exercising clean functions </name> -<tool> -unit1602 -</tool> </client> - </testcase> diff --git a/tests/data/test1603 b/tests/data/test1603 index 805c9e378..406d197ee 100644 --- a/tests/data/test1603 +++ b/tests/data/test1603 @@ -18,9 +18,5 @@ unittest <name> Internal hash add, retrieval, deletion testing </name> -<tool> -unit1603 -</tool> </client> - </testcase> diff --git a/tests/data/test1604 b/tests/data/test1604 index cf207750d..39daf9ddc 100644 --- a/tests/data/test1604 +++ b/tests/data/test1604 @@ -17,9 +17,5 @@ unittest <name> Test WIN32/MSDOS filename sanitization </name> -<tool> -unit1604 -</tool> </client> - </testcase> diff --git a/tests/data/test1605 b/tests/data/test1605 index 09ef66942..a123b01a1 100644 --- a/tests/data/test1605 +++ b/tests/data/test1605 @@ -17,9 +17,5 @@ unittest <name> Test negative data lengths as input to libcurl functions </name> -<tool> -unit1605 -</tool> </client> - </testcase> diff --git a/tests/data/test1606 b/tests/data/test1606 index 15488d407..83e984427 100644 --- a/tests/data/test1606 +++ b/tests/data/test1606 @@ -18,9 +18,5 @@ unittest <name> verify speedcheck </name> -<tool> -unit1606 -</tool> </client> - </testcase> diff --git a/tests/data/test1607 b/tests/data/test1607 index 9628324e4..6d28d6eb4 100644 --- a/tests/data/test1607 +++ b/tests/data/test1607 @@ -18,9 +18,5 @@ unittest <name> CURLOPT_RESOLVE parsing </name> -<tool> -unit1607 -</tool> </client> - </testcase> diff --git a/tests/data/test1608 b/tests/data/test1608 index 702310757..fbc623895 100644 --- a/tests/data/test1608 +++ b/tests/data/test1608 @@ -18,9 +18,5 @@ unittest <name> verify DNS shuffling </name> -<tool> -unit1608 -</tool> </client> - </testcase> diff --git a/tests/data/test1609 b/tests/data/test1609 index c1b7c7a11..6d28d6eb4 100644 --- a/tests/data/test1609 +++ b/tests/data/test1609 @@ -18,9 +18,5 @@ unittest <name> CURLOPT_RESOLVE parsing </name> -<tool> -unit1609 -</tool> </client> - </testcase> diff --git a/tests/data/test1610 b/tests/data/test1610 index 2228515e9..fff973371 100644 --- a/tests/data/test1610 +++ b/tests/data/test1610 @@ -18,9 +18,5 @@ unittest <name> SHA256 unit tests </name> -<tool> -unit1610 -</tool> </client> - </testcase> diff --git a/tests/data/test1611 b/tests/data/test1611 index 151d321f4..008aea7ec 100644 --- a/tests/data/test1611 +++ b/tests/data/test1611 @@ -18,9 +18,5 @@ unittest <name> MD4 unit tests </name> -<tool> -unit1611 -</tool> </client> - </testcase> diff --git a/tests/data/test1612 b/tests/data/test1612 index c9a772be3..3e92b6791 100644 --- a/tests/data/test1612 +++ b/tests/data/test1612 @@ -18,9 +18,5 @@ unittest <name> HMAC unit tests </name> -<tool> -unit1612 -</tool> </client> - </testcase> diff --git a/tests/data/test1620 b/tests/data/test1620 index 83b08c7a8..038bbcc1b 100644 --- a/tests/data/test1620 +++ b/tests/data/test1620 @@ -18,9 +18,5 @@ unittest <name> unit tests for url.c </name> -<tool> -unit1620 -</tool> </client> - </testcase> diff --git a/tests/data/test1621 b/tests/data/test1621 index 1117d1bd2..62c81052f 100644 --- a/tests/data/test1621 +++ b/tests/data/test1621 @@ -19,9 +19,5 @@ https <name> unit tests for stripcredentials from URL </name> -<tool> -unit1621 -</tool> </client> - </testcase> diff --git a/tests/data/test1650 b/tests/data/test1650 index 7a02a6dac..6248b9814 100644 --- a/tests/data/test1650 +++ b/tests/data/test1650 @@ -19,9 +19,5 @@ DoH <name> DOH </name> -<tool> -unit1650 -</tool> </client> - </testcase> diff --git a/tests/data/test1651 b/tests/data/test1651 index 28a9b714c..d29974bf2 100644 --- a/tests/data/test1651 +++ b/tests/data/test1651 @@ -18,9 +18,5 @@ unittest <name> x509 parsing </name> -<tool> -unit1651 -</tool> </client> - </testcase> diff --git a/tests/data/test1652 b/tests/data/test1652 index c41169019..678d19517 100644 --- a/tests/data/test1652 +++ b/tests/data/test1652 @@ -16,8 +16,5 @@ unittest <name> infof </name> -<tool> -unit1652 -</tool> </client> </testcase> diff --git a/tests/data/test1653 b/tests/data/test1653 index 0de2c14b5..59ec3f396 100644 --- a/tests/data/test1653 +++ b/tests/data/test1653 @@ -16,8 +16,5 @@ unittest <name> urlapi </name> -<tool> -unit1653 -</tool> </client> </testcase> diff --git a/tests/data/test1654 b/tests/data/test1654 index 6a82daa08..6155635ab 100644 --- a/tests/data/test1654 +++ b/tests/data/test1654 @@ -26,9 +26,6 @@ alt-svc <command> log/1654 </command> -<tool> -unit1654 -</tool> <file name="log/1654" mode="text"> 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 2e73f55d9..e161fb662 100644 --- a/tests/data/test1655 +++ b/tests/data/test1655 @@ -19,9 +19,5 @@ DoH <name> unit test for doh_encode </name> -<tool> -unit1655 -</tool> </client> - </testcase> diff --git a/tests/runtests.pl b/tests/runtests.pl index bef95574d..61953ea64 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 <keywords> 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"; } |