You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by mo...@apache.org on 2026/10/12 21:55:11 UTC

(trafficserver) branch master updated: benchmark_HdrParse: Report unreadable corpus directories (#13792)

This is an automated email from the ASF dual-hosted git repository.

moonchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ddb75d459 benchmark_HdrParse: Report unreadable corpus directories (#13792)
9ddb75d459 is described below

commit 9ddb75d4598bd4ed06aa22fb744d78ae6a047808
Author: Mo Chen <mo...@apache.org>
AuthorDate: Mon Oct 12 16:55:04 2026 -0500

    benchmark_HdrParse: Report unreadable corpus directories (#13792)
    
    --corpus-dir loaded nothing and gave no warning when the directory was
    missing or unreadable, and an entry whose type could not be read ended
    the tool with an uncaught filesystem_error.  Iterate with the
    error_code overloads and warn the same way as for an unreadable
    --corpus-file.
    
    Also correct the comment that says which cases must fully parse, and
    qualify isspace/isprint with std:: in test_URL.cc.
---
 src/proxy/hdrs/unit_tests/test_URL.cc |  2 +-
 tools/benchmark/benchmark_HdrParse.cc | 13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/proxy/hdrs/unit_tests/test_URL.cc b/src/proxy/hdrs/unit_tests/test_URL.cc
index 2fc62bcdfd..c9e33a3e83 100644
--- a/src/proxy/hdrs/unit_tests/test_URL.cc
+++ b/src/proxy/hdrs/unit_tests/test_URL.cc
@@ -186,7 +186,7 @@ url_mostly_compliant_reference(const char *start, const char *end)
 {
   for (const char *p = start; p < end; ++p) {
     unsigned char const c = static_cast<unsigned char>(*p);
-    if (isspace(c) || !isprint(c)) {
+    if (std::isspace(c) || !std::isprint(c)) {
       return false;
     }
   }
diff --git a/tools/benchmark/benchmark_HdrParse.cc b/tools/benchmark/benchmark_HdrParse.cc
index cf93bde894..6f76a04cf1 100644
--- a/tools/benchmark/benchmark_HdrParse.cc
+++ b/tools/benchmark/benchmark_HdrParse.cc
@@ -365,11 +365,15 @@ build_corpus(const std::vector<std::filesystem::path> &files, const std::vector<
   }
   for (const auto &d : dirs) {
     std::error_code ec;
-    for (auto it = std::filesystem::directory_iterator(d, ec); !ec && it != std::filesystem::directory_iterator(); ++it) {
-      if (it->is_regular_file()) {
+    for (std::filesystem::directory_iterator it(d, ec); !ec && it != std::filesystem::directory_iterator(); it.increment(ec)) {
+      std::error_code type_ec;
+      if (it->is_regular_file(type_ec)) {
         load_file(it->path(), corp.cases);
       }
     }
+    if (ec) {
+      std::fprintf(stderr, "warning: cannot read corpus directory %s: %s\n", d.string().c_str(), ec.message().c_str());
+    }
   }
 
   corp.urls = {std::string(URL_REALISTIC), "http://www.example.com/" + std::string(4000, 'x')};
@@ -677,8 +681,9 @@ find_case(std::string_view label)
 }
 } // namespace
 
-// Built-in cases must fully parse (DONE + all bytes consumed); file-loaded cases
-// (label carries a '#') only must not ERROR.
+// Built-in cases must fully parse (DONE + all bytes consumed). In the request
+// and response tests, file-loaded cases (label carries a '#') only must not
+// ERROR; the mime test requires a full parse for them too.
 bool
 is_file_case(const HeaderCase &c)
 {