-
Notifications
You must be signed in to change notification settings - Fork 167
/
Rakefile
90 lines (81 loc) · 2.67 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
require 'rake/testtask'
require 'rdoc/task'
require 'bundler/gem_tasks'
begin
require 'rake/extensiontask'
Rake::ExtensionTask.new('openssl')
# Run the debug_compiler task before the compile task.
Rake::Task['compile'].prerequisites.unshift :debug_compiler
rescue LoadError
warn "rake-compiler not installed. Run 'bundle install' to " \
"install testing dependency gems."
end
Rake::TestTask.new do |t|
t.libs << 'test/openssl'
t.test_files = FileList["test/**/test_*.rb"]
t.warning = true
end
desc 'Run tests for fips'
task :test_fips do
ENV['TEST_RUBY_OPENSSL_FIPS_ENABLED'] = 'true'
Rake::Task['test_fips_internal'].invoke
end
Rake::TestTask.new(:test_fips_internal) do |t|
t.libs << 'test/openssl'
# Exclude failing test files in FIPS for this task to pass.
# TODO: Fix failing test files.
t.test_files = FileList['test/**/test_*.rb'] - FileList[
'test/openssl/test_asn1.rb',
'test/openssl/test_cipher.rb',
'test/openssl/test_digest.rb',
'test/openssl/test_hmac.rb',
'test/openssl/test_kdf.rb',
'test/openssl/test_ns_spki.rb',
'test/openssl/test_ocsp.rb',
'test/openssl/test_pkcs12.rb',
'test/openssl/test_pkcs7.rb',
'test/openssl/test_ssl.rb',
'test/openssl/test_ts.rb',
'test/openssl/test_x509cert.rb',
'test/openssl/test_x509crl.rb',
'test/openssl/test_x509name.rb',
'test/openssl/test_x509req.rb',
]
t.warning = true
end
RDoc::Task.new do |rdoc|
rdoc.main = "README.md"
rdoc.rdoc_files.include("*.md", "lib/**/*.rb", "ext/**/*.c")
end
task :test => [:compile, :debug]
task :test_fips => [:compile, :debug]
# Print Ruby and compiler info for debugging purpose.
task :debug_compiler do
ruby '-v'
compiler = RbConfig::CONFIG['CC']
case compiler
when 'gcc', 'clang'
sh "#{compiler} --version"
else
Rake.rake_output_message "Compiler: #{RbConfig::CONFIG['CC']}"
end
end
task :debug do
ruby_code = <<~'EOF'
openssl_version_number_str = OpenSSL::OPENSSL_VERSION_NUMBER.to_s(16)
libressl_version_number_str = (defined? OpenSSL::LIBRESSL_VERSION_NUMBER) ?
OpenSSL::LIBRESSL_VERSION_NUMBER.to_s(16) : "undefined"
providers_str = (defined? OpenSSL::Provider) ?
OpenSSL::Provider.provider_names.join(", ") : "undefined"
puts <<~MESSAGE
OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}
OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}
OpenSSL::OPENSSL_VERSION_NUMBER: #{openssl_version_number_str}
OpenSSL::LIBRESSL_VERSION_NUMBER: #{libressl_version_number_str}
FIPS enabled: #{OpenSSL.fips_mode}
Providers: #{providers_str}
MESSAGE
EOF
ruby %Q(-I./lib -ropenssl.so -ve'#{ruby_code}')
end
task :default => :test