summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-22 01:08:15 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-22 01:08:15 +0000
commit7e5462b36f0e3c07b3bdfcb09970fe39010c923e (patch)
tree1d55e560fd73eeccf6fc4b3735ce8031a42f73bc /test/ruby
parent966bfb07f6a7d1480abf8e48688294716218b72e (diff)
define PACKED_STRUCT_UNALIGNED correctly
Defining PACKED_STRUCT_UNALIGNED to a noop in ruby/config.h (via `configure') prevents the definition in include/ruby/defines.h from working This should have been fixed in r46914, so there's a size regression for some objects since Ruby 2.2+. I do not believe we can backport to existing releases, either, since it can affect ABI. Add a test for Time objects on common x86-based platforms to check for future regressions. * configure.in: remove PACKED_STRUCT_UNALIGNED definition * test/ruby/test_time.rb (test_memsize): new test for x86 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_time.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 48bc01d977..41d4b03553 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -1110,4 +1110,21 @@ class TestTime < Test::Unit::TestCase
end.new
assert_raise_with_message(TypeError, /Inexact/) {Time.at(x)}
end
+
+ def test_memsize
+ # Time objects are common in some code, try to keep them small
+ skip "Time object size test" if /^(?:i.?86|x86_64)-linux/ !~ RUBY_PLATFORM
+ require 'objspace'
+ t = Time.at(0)
+ size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE]
+ case size
+ when 20 then expect = 50
+ when 40 then expect = 86
+ else
+ flunk "Unsupported RVALUE_SIZE=#{size}, update test_memsize"
+ end
+ assert_equal expect, ObjectSpace.memsize_of(t)
+ rescue LoadError => e
+ skip "failed to load objspace: #{e.message}"
+ end
end