]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: Automatically deduce the tool name from the test case for unit tests
authorSteve Holme <steve_holme@hotmail.com>
Sun, 23 Feb 2020 08:20:32 +0000 (08:20 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Thu, 27 Feb 2020 00:51:49 +0000 (00:51 +0000)
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:
tests/data/test1300
tests/data/test1301
tests/data/test1302
tests/data/test1303
tests/data/test1304
tests/data/test1305
tests/data/test1307
tests/data/test1308
tests/data/test1309
tests/data/test1323
tests/data/test1330
tests/data/test1394
tests/data/test1395
tests/data/test1396
tests/data/test1397
tests/data/test1398
tests/data/test1399
tests/data/test1600
tests/data/test1601
tests/data/test1602
tests/data/test1603
tests/data/test1604
tests/data/test1605
tests/data/test1606
tests/data/test1607
tests/data/test1608
tests/data/test1609
tests/data/test1610
tests/data/test1611
tests/data/test1612
tests/data/test1620
tests/data/test1621
tests/data/test1650
tests/data/test1651
tests/data/test1652
tests/data/test1653
tests/data/test1654
tests/data/test1655
tests/runtests.pl

index 1008885616ea3ca90c3c9598a3cdb890bf934175..11834121301c70076c93574da3e082185be32ab4 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 llist unit tests
  </name>
-<tool>
-unit1300
-</tool>
 </client>
-
 </testcase>
index 8506c0005eef453b2d9f66196b93f7729eff81c4..5aea24b654a97ddff762a5bc34ee15326bc3178e 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 curl_strcasecompare unit tests
  </name>
-<tool>
-unit1301
-</tool>
 </client>
-
 </testcase>
index 27ea8624856939eb6d550b5045b6dad86758a59a..9e9039cac6ce129569aed4f5807b27141b056841 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 base64 encode/decode unit tests
  </name>
-<tool>
-unit1302
-</tool>
 </client>
-
 </testcase>
index 925b47e15db12ec04630d4c240be8b148931e597..bb23352df13a27dc82226689b5d554ddaf3e0689 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 Curl_timeleft unit tests
  </name>
-<tool>
-unit1303
-</tool>
 </client>
-
 </testcase>
index d518de9e4cb31ca8b5a30c3f2ec4d780d0f587e3..b402bfc8bec05454d562c85dfc5bf62f6cbb16d7 100644 (file)
@@ -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>
index 91149b3ad57461de3999af6cd9ebf1cf3468a668..52efbcbb0124ac2dfbd2907adc6a56f374515b93 100644 (file)
@@ -19,12 +19,8 @@ unittest
  <name>
 internal hash create/destroy testing
  </name>
-<tool>
-unit1305
-</tool>
 <command>
 1305
 </command>
 </client>
-
 </testcase>
index c4f7ac7295d9423d487bef9987dfa29a127b13c6..f0e96bfa0111cd1c3fc7b6bd0494bbe92210ee20 100644 (file)
@@ -20,9 +20,5 @@ ftp
  <name>
 internal Curl_fnmatch() testing
  </name>
-<tool>
-unit1307
-</tool>
 </client>
-
 </testcase>
index 88e9771ddf289594fea5779a0a5a02a39db6c68d..3755ef8b41f232fb262f7c4bf482bad1d8f8e62d 100644 (file)
@@ -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>
index 0e0cad1e81fa715d4b18f5391616931fee612acb..7005d5f13c72114ee68d18b0d65f8ba8bade0132 100644 (file)
@@ -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>
index ec3ff9819760d0b072be044cc916529434efca76..66bac61ff7de336d1a9fc38f6589a658ffbb8256 100644 (file)
@@ -23,9 +23,6 @@ unittest
 <name>
 curlx_tvdiff
 </name>
-<tool>
-unit1323
-</tool>
 </client>
 
 #
index a78dc30b8de4d63b90f1741dad540eecc4e281dd..ce04e3331ea5e8d898874b8aeb74f632a95fb7d7 100644 (file)
@@ -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>
index 34d4a0e370c9274365182ab80a5ae338f9529a59..d3ffb2d33fa03ef22855795ef237a7c633b57993 100644 (file)
@@ -17,14 +17,10 @@ unittest
  <name>
 unit test for parse_cert_parameter()
  </name>
-<tool>
-unit1394
-</tool>
 </client>
 
 <verify>
 <stdout mode="text">
 </stdout>
 </verify>
-
 </testcase>
index 967c8d4921a636af696a9dd9c5f3be4783ed37b8..409e0d631ba11462689f9a7019031685cbac0627 100644 (file)
@@ -17,10 +17,5 @@ unittest
  <name>
 Curl_dedotdotify
  </name>
-<tool>
-unit1395
-</tool>
-
 </client>
-
 </testcase>
index 8ffe35f4caa6cf47133dc8d191fe8ccfe601f98e..d8b432d8b10c2abb1c77523cfb7fb729ee90b65c 100644 (file)
@@ -19,9 +19,6 @@ unittest
  <name>
 curl_easy_escape and curl_easy_unescape
  </name>
-<tool>
-unit1396
-</tool>
 </client>
 
 </testcase>
index 5f479b4685c0be9b297e8cb8de6ed1eaa44dd627..84f962abebee3c40631dc78a18299ff9ed7bd3a4 100644 (file)
@@ -19,9 +19,6 @@ unittest
  <name>
 Check wildcard certificate matching function Curl_cert_hostcheck
  </name>
-<tool>
-unit1397
-</tool>
 </client>
 
 </testcase>
index dd50baa6241a416212dd64333a4d7069a80b259b..436cac82d4b63a0df6a23bb2712df4b12d7328df 100644 (file)
@@ -18,9 +18,6 @@ unittest
  <name>
 curl_msnprintf unit tests
  </name>
-<tool>
-unit1398
-</tool>
 </client>
 
 </testcase>
index fe3879df10e905a0a1f2a163815ca34f6b04eb80..6d6ec7a5b048cfc2dc65661401013eb743b4be50 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 Curl_pgrsTime unit tests
  </name>
-<tool>
-unit1399
-</tool>
 </client>
-
 </testcase>
index 88040747a1e3518c0f8cb2206a4f4563c518a331..33413d7c39f5c7dbc7dc6f7d159292232253b2a0 100644 (file)
@@ -19,9 +19,5 @@ NTLM
  <name>
 NTLM unit tests
  </name>
-<tool>
-unit1600
-</tool>
 </client>
-
 </testcase>
index 125493bb016158b7e05d49058d910c66165acffc..2065fdd1d84f924e4a006ca19a475e35780263c4 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 MD5 unit tests
  </name>
-<tool>
-unit1601
-</tool>
 </client>
-
 </testcase>
index 4717058ced8be7936f08074e28bf4d92aabfa53b..56e243ff8a93890f97b46059e1545f208906b45f 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 Internal hash create/add/destroy testing, exercising clean functions
  </name>
-<tool>
-unit1602
-</tool>
 </client>
-
 </testcase>
index 805c9e378cc77c9ee164df2caf3872ff1149501e..406d197eeb6f10283d3bb7ea39abdfff06e93dcd 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 Internal hash add, retrieval, deletion testing
  </name>
-<tool>
-unit1603
-</tool>
 </client>
-
 </testcase>
index cf207750de62bf6d75a5289693c896cc6c4f1566..39daf9ddc58151969eee2bbeb81b758ed327deca 100644 (file)
@@ -17,9 +17,5 @@ unittest
  <name>
 Test WIN32/MSDOS filename sanitization
  </name>
-<tool>
-unit1604
-</tool>
 </client>
-
 </testcase>
index 09ef66942c5f97a7fef7b9a8643322e88975b129..a123b01a1db04a37c4db54516e7d1ca6535baed2 100644 (file)
@@ -17,9 +17,5 @@ unittest
  <name>
 Test negative data lengths as input to libcurl functions
  </name>
-<tool>
-unit1605
-</tool>
 </client>
-
 </testcase>
index 15488d40777bdaa370bb6b60f356b4f2749116dd..83e984427088a2bb11ba3ba771200b8db551b285 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 verify speedcheck
  </name>
-<tool>
-unit1606
-</tool>
 </client>
-
 </testcase>
index 9628324e4195fc8e2e87d501ad073fcd37758891..6d28d6eb49f9e247bde6639ec6044cc7ebd06704 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 CURLOPT_RESOLVE parsing
  </name>
-<tool>
-unit1607
-</tool>
 </client>
-
 </testcase>
index 702310757491e2bc1803bfe23ef3a9b1428ce1f6..fbc6238958c89bbdb5b3f0e39035f6cdb4b13d0e 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 verify DNS shuffling
  </name>
-<tool>
-unit1608
-</tool>
 </client>
-
 </testcase>
index c1b7c7a111401ae47e35cc93067b5c5301ecb31a..6d28d6eb49f9e247bde6639ec6044cc7ebd06704 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 CURLOPT_RESOLVE parsing
  </name>
-<tool>
-unit1609
-</tool>
 </client>
-
 </testcase>
index 2228515e9f1d1949c2d80d98c28d293e58f4ab81..fff973371de63cebb4421e61a25c396efb94c917 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 SHA256 unit tests
  </name>
-<tool>
-unit1610
-</tool>
 </client>
-
 </testcase>
index 151d321f4d862fe4cc5ebd52590da3c19e1dd6eb..008aea7ec46601621e4a621c2d518dcc2fe8b9fd 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 MD4 unit tests
  </name>
-<tool>
-unit1611
-</tool>
 </client>
-
 </testcase>
index c9a772be32f7f03cae44cc298191bd5a1fee16dd..3e92b6791209ac6938b25cd71feec6f15d7d19d5 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 HMAC unit tests
  </name>
-<tool>
-unit1612
-</tool>
 </client>
-
 </testcase>
index 83b08c7a811792f20615836ea6d25845605b5a5a..038bbcc1b47426dd5d540757d9f05b561426d5df 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 unit tests for url.c
  </name>
-<tool>
-unit1620
-</tool>
 </client>
-
 </testcase>
index 1117d1bd2a555fdecd1ddb9cdd990d8ecac962e6..62c81052ff353793f003fd776eb759f61fe1650f 100644 (file)
@@ -19,9 +19,5 @@ https
  <name>
 unit tests for stripcredentials from URL
  </name>
-<tool>
-unit1621
-</tool>
 </client>
-
 </testcase>
index 7a02a6dac461f7509825126a7d9afe18a00e5596..6248b9814d6f2057eadc855ce3964625197793ff 100644 (file)
@@ -19,9 +19,5 @@ DoH
  <name>
 DOH
  </name>
-<tool>
-unit1650
-</tool>
 </client>
-
 </testcase>
index 28a9b714c6939c013ede907ec3ac895534113282..d29974bf20f9d8fd841a2a0e594f1c52c7ad5277 100644 (file)
@@ -18,9 +18,5 @@ unittest
  <name>
 x509 parsing
  </name>
-<tool>
-unit1651
-</tool>
 </client>
-
 </testcase>
index c41169019444622a82117c6ac96d61675525e86f..678d19517806ab2d6d10bf2967480b3efcc196c6 100644 (file)
@@ -16,8 +16,5 @@ unittest
 <name>
 infof
 </name>
-<tool>
-unit1652
-</tool>
 </client>
 </testcase>
index 0de2c14b5ab2afcb2dba713b0a09980bf574c0eb..59ec3f3962017a945e2829848e22e19c1b7a42c2 100644 (file)
@@ -16,8 +16,5 @@ unittest
 <name>
 urlapi
 </name>
-<tool>
-unit1653
-</tool>
 </client>
 </testcase>
index 6a82daa081db0cb1dc14011e4fe61e348aceb796..6155635ab014ec98d8df623ba9e40e43e165ecda 100644 (file)
@@ -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
index 2e73f55d9bd5fc25e0a1fa16107fff75f7dc4e53..e161fb6621bbb179046797f24ed5b7bc3c1f64d1 100644 (file)
@@ -19,9 +19,5 @@ DoH
  <name>
 unit test for doh_encode
  </name>
-<tool>
-unit1655
-</tool>
 </client>
-
 </testcase>
index bef95574da6399441c72728fc05ccf4b37690612..61953ea642b8cde6e5773f83ecfafb6f1f84e352 100755 (executable)
@@ -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";
         }