[tor-commits] [tor/master] Improve openssl_version tests with better messages

nickm at torproject.org nickm at torproject.org
Sun Jun 17 23:29:10 UTC 2018


commit 8483241b4e2538e9adb75c7ffed2787afd361df6
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon May 21 15:06:45 2018 -0400

    Improve openssl_version tests with better messages
    
    These tests would report errors, but wouldn't report the offending
    strings.
---
 changes/bug26152       | 4 ++++
 src/test/test_crypto.c | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/changes/bug26152 b/changes/bug26152
new file mode 100644
index 000000000..34fda09b2
--- /dev/null
+++ b/changes/bug26152
@@ -0,0 +1,4 @@
+  o Minor bugfixes (testing):
+    - When logging a version mismatch in our openssl_version tests,
+      report the actual offending version strings. Fixes bug 26152; bugfix on
+      0.2.9.1-alpha.
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 24eef156b..e3a41412f 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -152,8 +152,13 @@ test_crypto_openssl_version(void *arg)
   const char *h_version = crypto_openssl_get_header_version_str();
   tt_assert(version);
   tt_assert(h_version);
-  tt_assert(!strcmpstart(version, h_version)); /* "-fips" suffix, etc */
-  tt_assert(!strstr(version, "OpenSSL"));
+  if (strcmpstart(version, h_version)) { /* "-fips" suffix, etc */
+    TT_DIE(("OpenSSL library version %s did not begin with header version %s.",
+            version, h_version));
+  }
+  if (strstr(version, "OpenSSL")) {
+    TT_DIE(("assertion failed: !strstr(\"%s\", \"OpenSSL\")", version));
+  }
   int a=-1,b=-1,c=-1;
   if (!strcmpstart(version, "LibreSSL") || !strcmpstart(version, "BoringSSL"))
     return;





More information about the tor-commits mailing list