Skip to content

Commit b0acc1a

Browse files
committed
Make optional benchmark test in OpenSSL::OSSL#test_memcmp_timing
1 parent 13b03ba commit b0acc1a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/openssl/test_ossl.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22
require_relative "utils"
33

4-
require 'benchmark'
5-
64
if defined?(OpenSSL)
75

86
class OpenSSL::OSSL < OpenSSL::SSLTestCase
@@ -44,6 +42,12 @@ def test_secure_compare
4442
end
4543

4644
def test_memcmp_timing
45+
begin
46+
require "benchmark"
47+
rescue LoadError
48+
pend "Benchmark is not available in this environment. Please install it with `gem install benchmark`."
49+
end
50+
4751
# Ensure using fixed_length_secure_compare takes almost exactly the same amount of time to compare two different strings.
4852
# Regular string comparison will short-circuit on the first non-matching character, failing this test.
4953
# NOTE: this test may be susceptible to noise if the system running the tests is otherwise under load.

0 commit comments

Comments
 (0)