Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: net/data/verify_certificate_chain_unittest/rebase-errors.py

Issue 2918913002: Add path validation error expectations for PKITS tests. (Closed)
Patch Set: Address Matt's comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/data/verify_certificate_chain_unittest/rebase-errors.py
diff --git a/net/data/verify_certificate_chain_unittest/rebase-errors.py b/net/data/verify_certificate_chain_unittest/rebase-errors.py
index bc74482c7b2c9decf3881578470cc4f433660050..ec3fa2b51e5494748ce756a217ef6e60a5d9132a 100755
--- a/net/data/verify_certificate_chain_unittest/rebase-errors.py
+++ b/net/data/verify_certificate_chain_unittest/rebase-errors.py
@@ -14,11 +14,11 @@ To use this run the affected tests, and then pass the input to this script
$ ./out/Release/net_unittests --gtest_filter="*VerifyCertificateChain*" | \
net/data/verify_certificate_chain_unittest/rebase-errors.py
-The script works by scanning the stdout looking for gtest failures when
-comparing "errors.ToDebugString(chain)". The C++ test side should have been
-instrumented to dump out the test file's path on mismatch.
+The script works by scanning the stdout looking for gtest failures having a
+particular format. The C++ test side should have been instrumented to dump out
+the test file's path on mismatch.
-This script will then update the corresponding .test file that contains the
+This script will then update the corresponding test/error file that contains the
error expectation.
"""
@@ -27,14 +27,19 @@ import sys
import re
# Regular expression to find the failed errors in test stdout.
-# * Group 1 of the match is the actual error text (backslash-escaped)
-# * Group 2 of the match is file path (relative to //src) where the expected
-# errors were read from.
+# * Group 1 of the match is file path (relative to //src) where the
+# expected errors were read from.
+# * Group 2 of the match is the actual error text
failed_test_regex = re.compile(r"""
-Value of: errors.ToDebugString\((?:test.chain)?\)
- Actual: "(.*)"
-(?:.|\n)+?
-Test file: (.*[.]test)
+Cert path errors don't match expectations \((.+?)\)
+
+EXPECTED:
+
+(?:.|\n)*?
+ACTUAL:
+
+((?:.|\n)*?)
+===> Use net/data/verify_certificate_chain_unittest/rebase-errors.py to rebaseline.
""", re.MULTILINE)
@@ -104,10 +109,18 @@ def main():
test_stdout = sys.stdin.read()
for m in failed_test_regex.finditer(test_stdout):
- actual_errors = m.group(1)
- actual_errors = actual_errors.decode('string-escape')
- relative_test_path = m.group(2)
- fixup_errors_for_file(actual_errors, get_abs_path(relative_test_path))
+ src_relative_errors_path = m.group(1)
+ errors_path = get_abs_path(src_relative_errors_path)
+ actual_errors = m.group(2)
+
+ if errors_path.endswith(".test"):
+ fixup_errors_for_file(actual_errors, errors_path)
+ elif errors_path.endswith(".txt"):
+ write_string_to_file(actual_errors, errors_path)
+ else:
+ print 'Unknown file extension'
+ sys.exit(1)
+
if __name__ == "__main__":
« no previous file with comments | « net/data/verify_certificate_chain_unittest/pkits_errors/4.9.8.txt ('k') | net/third_party/nist-pkits/generate_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698