Bug #10325 ยป 0001-test-ruby-test_string-skip-test-if-low-on-memory.patch
test/ruby/memory_status.rb | ||
---|---|---|
status
|
||
end
|
||
end
|
||
def self.usable?(wanted)
|
||
file = '/proc/meminfo'
|
||
if File.readable?(file) && RUBY_PLATFORM =~ /linux/
|
||
h = {}
|
||
File.readlines(file).each do |l|
|
||
k, v = l.split(/:\s+/, 2)
|
||
h[k] = v.gsub!(/\s+kB$/, '') ? v.to_i * 1024 : v.to_i
|
||
end
|
||
begin
|
||
avail = h['MemFree'] + h['Cached']
|
||
rescue NoMethodError
|
||
warn "missing 'MemFree' or 'Cached' field in #{file}"
|
||
return true
|
||
end
|
||
avail > wanted
|
||
else
|
||
true
|
||
end
|
||
end
|
||
end
|
test/ruby/test_string.rb | ||
---|---|---|
def test_LSHIFT_neary_long_max
|
||
return unless @cls == String
|
||
assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 20)
|
||
require_relative 'memory_status'
|
||
long_max = 0x4000_0000
|
||
unless Memory.usable?(long_max)
|
||
skip "not enough free memory (wanted #{long_max} bytes)"
|
||
end
|
||
assert_ruby_status([], <<-"end;", '[ruby-core:61886] [Bug #9709]', timeout: 20)
|
||
begin
|
||
a = "a" * 0x4000_0000
|
||
a = "a" * #{long_max}
|
||
a << "a" * 0x1_0000
|
||
rescue NoMemoryError
|
||
end
|
||
-
|