Disable GC checks for Ruby auto_ptr test
This commit is contained in:
parent
e321ee30f0
commit
a9731251a4
1 changed files with 12 additions and 28 deletions
|
|
@ -4,40 +4,24 @@ require 'swig_assert'
|
||||||
|
|
||||||
require 'li_std_auto_ptr'
|
require 'li_std_auto_ptr'
|
||||||
|
|
||||||
|
def gc_check(expected_count)
|
||||||
|
# GC.start(full_mark: true, immediate_sweep: true)
|
||||||
|
GC.start
|
||||||
|
# GC is not reliably run, skip check
|
||||||
|
# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count())
|
||||||
|
end
|
||||||
|
|
||||||
k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
|
k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
|
||||||
k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
|
k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
|
||||||
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 2)
|
swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count())
|
||||||
|
|
||||||
|
gc_check(2)
|
||||||
k1 = nil
|
k1 = nil
|
||||||
GC.start
|
gc_check(1)
|
||||||
|
|
||||||
# GC can need a few runs to actually collect the object.
|
|
||||||
100.times do ||
|
|
||||||
next if Li_std_auto_ptr::Klass::getTotal_count() == 2
|
|
||||||
|
|
||||||
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 1)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
swig_assert_equal_simple(k2.getLabel(), "second")
|
swig_assert_equal_simple(k2.getLabel(), "second")
|
||||||
|
gc_check(1)
|
||||||
if Li_std_auto_ptr::Klass::getTotal_count() != 1
|
|
||||||
STDERR.puts "GC failed to collect the first object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
|
|
||||||
|
|
||||||
# Skip the rest of the test as it's not going to work correctly anyhow.
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
k2 = nil
|
k2 = nil
|
||||||
GC.start
|
gc_check(0)
|
||||||
|
|
||||||
100.times do ||
|
|
||||||
next if Li_std_auto_ptr::Klass::getTotal_count() == 1
|
|
||||||
|
|
||||||
swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 0)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
if Li_std_auto_ptr::Klass::getTotal_count() != 0
|
|
||||||
STDERR.puts "GC failed to collect the second object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}"
|
|
||||||
end
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue