summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-25 09:35:46 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-25 09:35:46 +0000
commit8ffefcb621510e7964f0e33290d7b247bfaa4988 (patch)
tree5c2828ed2daff2153650486062b18ad465d300ba /test
parent7bba6adc56b20606101131069ef8f1f96ff71fa2 (diff)
* test/lib/envutil.rb (Test::Unit::Assertions#assert_no_memory_leak):
NO_MEMORY_LEAK_ENVS is moved to Memory::NO_MEMORY_LEAK_ENVS to reduce child executions during test-all on Solaris. * test/lib/memory_status.rb (Memory::NO_MEMORY_LEAK_ENVS): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/lib/envutil.rb27
-rw-r--r--test/lib/memory_status.rb28
2 files changed, 30 insertions, 25 deletions
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb
index 826fd72..b739053 100644
--- a/test/lib/envutil.rb
+++ b/test/lib/envutil.rb
@@ -442,29 +442,6 @@ eom
assert_warning(*args) {$VERBOSE = false; yield}
end
- case RUBY_PLATFORM
- when /solaris2\.(?:9|[1-9][0-9])/i # Solaris 9, 10, 11,...
- bits = [nil].pack('p').size == 8 ? 64 : 32
- if ENV['LD_PRELOAD'].to_s.empty? &&
- ENV["LD_PRELOAD_#{bits}"].to_s.empty? &&
- (ENV['UMEM_OPTIONS'].to_s.empty? ||
- ENV['UMEM_OPTIONS'] == 'backend=mmap') then
- envs = {
- 'LD_PRELOAD' => 'libumem.so',
- 'UMEM_OPTIONS' => 'backend=mmap'
- }
- args = [
- envs,
- "--disable=gems",
- "-v", "-",
- ]
- _, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
- if status.exitstatus == 0 && err.to_s.empty? then
- NO_MEMORY_LEAK_ENVS = envs
- end
- end
- end #case RUBY_PLATFORM
-
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
require_relative 'memory_status'
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
@@ -477,9 +454,9 @@ eom
*args,
"-v", "-",
]
- if defined? NO_MEMORY_LEAK_ENVS then
+ if defined? Memory::NO_MEMORY_LEAK_ENVS then
envs ||= {}
- newenvs = envs.merge(NO_MEMORY_LEAK_ENVS) { |_, _, _| break }
+ newenvs = envs.merge(Memory::NO_MEMORY_LEAK_ENVS) { |_, _, _| break }
envs = newenvs if newenvs
end
args.unshift(envs) if envs
diff --git a/test/lib/memory_status.rb b/test/lib/memory_status.rb
index 071c5f6..c277760 100644
--- a/test/lib/memory_status.rb
+++ b/test/lib/memory_status.rb
@@ -108,4 +108,32 @@ module Memory
status
end
end
+
+ # On some platforms (e.g. Solaris), libc malloc does not return
+ # freed memory to OS because of efficiency, and linking with extra
+ # malloc library is needed to detect memory leaks.
+ #
+ case RUBY_PLATFORM
+ when /solaris2\.(?:9|[1-9][0-9])/i # Solaris 9, 10, 11,...
+ bits = [nil].pack('p').size == 8 ? 64 : 32
+ if ENV['LD_PRELOAD'].to_s.empty? &&
+ ENV["LD_PRELOAD_#{bits}"].to_s.empty? &&
+ (ENV['UMEM_OPTIONS'].to_s.empty? ||
+ ENV['UMEM_OPTIONS'] == 'backend=mmap') then
+ envs = {
+ 'LD_PRELOAD' => 'libumem.so',
+ 'UMEM_OPTIONS' => 'backend=mmap'
+ }
+ args = [
+ envs,
+ "--disable=gems",
+ "-v", "-",
+ ]
+ _, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
+ if status.exitstatus == 0 && err.to_s.empty? then
+ NO_MEMORY_LEAK_ENVS = envs
+ end
+ end
+ end #case RUBY_PLATFORM
+
end