Sha256: cd0aa7cb582b3ffd4c3d5dc3b20c4e3361ebf211539ea637d7213e3b669eddac
Contents?: true
Size: 984 Bytes
Versions: 3
Compression:
Stored size: 984 Bytes
Contents
require "test/unit" require "pkcs11" require "test/helper" class TestPkcs11Thread < Test::Unit::TestCase include PKCS11 attr_reader :slots attr_reader :slot attr_reader :session def setup $pkcs11 ||= open_softokn @slots = $pkcs11.active_slots @slot = slots.last @session = slot.open # session.login(:USER, "") end def teardown # @session.logout @session.close end def test_concurrency return unless self.respond_to?(:skip) skip "PKCS#11 calls will block on Ruby 1.8.x" if RUBY_VERSION<'1.9' count = 0 th = Thread.new{ loop do count += 1 sleep 0.01 end } # This should take some seconds: pub_key, priv_key = session.generate_key_pair(:RSA_PKCS_KEY_PAIR_GEN, {:MODULUS_BITS=>2048, :PUBLIC_EXPONENT=>[3].pack("N"), :TOKEN=>false}, {}) th.kill assert_operator count, :>, 10, "The second thread should count further concurrent to the key generation" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pkcs11-0.2.4-x86-mingw32 | test/test_pkcs11_thread.rb |
pkcs11-0.2.4-x64-mingw32 | test/test_pkcs11_thread.rb |
pkcs11-0.2.4 | test/test_pkcs11_thread.rb |