diff options
author | Hiroshi SHIBATA <[email protected]> | 2024-08-29 10:53:53 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-08-29 17:37:44 +0900 |
commit | 1515353353271fd89b803bcbb1472ddb97e3f10d (patch) | |
tree | b39eb4b80aa5293cdb25081ff5b36a0ca553328f /test | |
parent | 4e5b3e58e26cf65e383ddb60ebb89e3ecd66824e (diff) |
Make optional benchmark test in OpenSSL::OSSL#test_memcmp_timing
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11490
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_ossl.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/openssl/test_ossl.rb b/test/openssl/test_ossl.rb index 979669a003..3a90ead10a 100644 --- a/test/openssl/test_ossl.rb +++ b/test/openssl/test_ossl.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true require_relative "utils" -require 'benchmark' - if defined?(OpenSSL) class OpenSSL::OSSL < OpenSSL::SSLTestCase @@ -44,6 +42,12 @@ class OpenSSL::OSSL < OpenSSL::SSLTestCase end def test_memcmp_timing + begin + require "benchmark" + rescue LoadError + pend "Benchmark is not available in this environment. Please install it with `gem install benchmark`." + end + # Ensure using fixed_length_secure_compare takes almost exactly the same amount of time to compare two different strings. # Regular string comparison will short-circuit on the first non-matching character, failing this test. # NOTE: this test may be susceptible to noise if the system running the tests is otherwise under load. |