Commit dfc7290d authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Use base::PersistentHash() in //chrome/browser/pdf

pdf_extension_test.cc is using the hash to help shard tests, so use
base::PersistentHash() for stability of results across different shards.

Note: it's unclear why it's doing this instead of depending on the
normal test sharding logic...

Bug: 1025358
Change-Id: Ie03c8d8e73ac5923208de869d06782694e428a5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1924794
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716867}
parent 3dfd12bb
...@@ -253,8 +253,9 @@ class PDFExtensionTest : public extensions::ExtensionApiTest { ...@@ -253,8 +253,9 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
} }
// Load all the PDFs contained in chrome/test/data/<dir_name>. This only runs // Load all the PDFs contained in chrome/test/data/<dir_name>. This only runs
// the test if base::Hash(filename) mod kNumberLoadTestParts == k in order // the test if base::PersistentHash(filename) mod kNumberLoadTestParts == k in
// to shard the files evenly across values of k in [0, kNumberLoadTestParts). // order to shard the files evenly across values of k in [0,
// kNumberLoadTestParts).
void LoadAllPdfsTest(const std::string& dir_name, int k) { void LoadAllPdfsTest(const std::string& dir_name, int k) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath test_data_dir; base::FilePath test_data_dir;
...@@ -271,7 +272,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest { ...@@ -271,7 +272,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
std::string pdf_file = dir_name + "/" + filename; std::string pdf_file = dir_name + "/" + filename;
SCOPED_TRACE(pdf_file); SCOPED_TRACE(pdf_file);
if (static_cast<int>(base::Hash(filename) % kNumberLoadTestParts) == k) { if (static_cast<int>(base::PersistentHash(filename) %
kNumberLoadTestParts) == k) {
LOG(INFO) << "Loading: " << pdf_file; LOG(INFO) << "Loading: " << pdf_file;
bool success = LoadPdf(embedded_test_server()->GetURL("/" + pdf_file)); bool success = LoadPdf(embedded_test_server()->GetURL("/" + pdf_file));
if (pdf_file == "pdf_private/cfuzz5.pdf") if (pdf_file == "pdf_private/cfuzz5.pdf")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment