From 0922f762407cc20c90f8f5cfa01c5eafbdfecde0 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sun, 23 Feb 2020 08:20:32 +0000 Subject: 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 --- tests/data/test1300 | 4 ---- tests/data/test1301 | 4 ---- tests/data/test1302 | 4 ---- tests/data/test1303 | 4 ---- tests/data/test1304 | 4 ---- tests/data/test1305 | 4 ---- tests/data/test1307 | 4 ---- tests/data/test1308 | 4 ---- tests/data/test1309 | 4 ---- tests/data/test1323 | 3 --- tests/data/test1330 | 6 ------ tests/data/test1394 | 4 ---- tests/data/test1395 | 5 ----- tests/data/test1396 | 3 --- tests/data/test1397 | 3 --- tests/data/test1398 | 3 --- tests/data/test1399 | 4 ---- tests/data/test1600 | 4 ---- tests/data/test1601 | 4 ---- tests/data/test1602 | 4 ---- tests/data/test1603 | 4 ---- tests/data/test1604 | 4 ---- tests/data/test1605 | 4 ---- tests/data/test1606 | 4 ---- tests/data/test1607 | 4 ---- tests/data/test1608 | 4 ---- tests/data/test1609 | 4 ---- tests/data/test1610 | 4 ---- tests/data/test1611 | 4 ---- tests/data/test1612 | 4 ---- tests/data/test1620 | 4 ---- tests/data/test1621 | 4 ---- tests/data/test1650 | 4 ---- tests/data/test1651 | 4 ---- tests/data/test1652 | 3 --- tests/data/test1653 | 3 --- tests/data/test1654 | 3 --- tests/data/test1655 | 4 ---- tests/runtests.pl | 21 ++++++++++++++++----- 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 llist unit tests - -unit1300 - - 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 curl_strcasecompare unit tests - -unit1301 - - 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 base64 encode/decode unit tests - -unit1302 - - 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 Curl_timeleft unit tests - -unit1303 - - 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 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 91149b3ad..52efbcbb0 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 c4f7ac729..f0e96bfa0 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 88e9771dd..3755ef8b4 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 0e0cad1e8..7005d5f13 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 ec3ff9819..66bac61ff 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 a78dc30b8..ce04e3331 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 34d4a0e37..d3ffb2d33 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 967c8d492..409e0d631 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 8ffe35f4c..d8b432d8b 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 5f479b468..84f962abe 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 dd50baa62..436cac82d 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 fe3879df1..6d6ec7a5b 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 88040747a..33413d7c3 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 125493bb0..2065fdd1d 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 4717058ce..56e243ff8 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 805c9e378..406d197ee 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 cf207750d..39daf9ddc 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 09ef66942..a123b01a1 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 15488d407..83e984427 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 9628324e4..6d28d6eb4 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 702310757..fbc623895 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 c1b7c7a11..6d28d6eb4 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 2228515e9..fff973371 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 151d321f4..008aea7ec 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 c9a772be3..3e92b6791 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 83b08c7a8..038bbcc1b 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 1117d1bd2..62c81052f 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 7a02a6dac..6248b9814 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 28a9b714c..d29974bf2 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 c41169019..678d19517 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 0de2c14b5..59ec3f396 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 6a82daa08..6155635ab 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 2e73f55d9..e161fb662 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 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 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"; } -- cgit v1.2.1