From 62eb1b3304abf1ecd96c5a1ee6f0ce95e6df5e04 Mon Sep 17 00:00:00 2001 From: dukeleto Date: Fri, 19 Feb 2010 04:12:17 +0000 Subject: [PATCH] [t] Add some tests to make sure a GC mark and sweep happens when a large amount of PMC's are created git-svn-id: https://svn.parrot.org/parrot/trunk@44160 d31e2699-5ff4-0310-a27c-f18f2fbe73fe --- MANIFEST | 3 ++- t/op/gc-leaky.t | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ t/op/string_mem.t | 2 -- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 t/op/gc-leaky.t diff --git a/MANIFEST b/MANIFEST index 1ba040aa17..3322fd0129 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Fri Feb 19 01:11:00 2010 UT +# generated by tools/dev/mk_manifest_and_skip.pl Fri Feb 19 04:10:16 2010 UT # # See below for documentation on the format of this file. # @@ -1814,6 +1814,7 @@ t/op/debuginfo.t [test] t/op/exceptions.t [test] t/op/exit.t [test] t/op/fetch.t [test] +t/op/gc-leaky.t [test] t/op/gc.t [test] t/op/globals.t [test] t/op/ifunless.t [test] diff --git a/t/op/gc-leaky.t b/t/op/gc-leaky.t new file mode 100644 index 0000000000..5f72350255 --- /dev/null +++ b/t/op/gc-leaky.t @@ -0,0 +1,73 @@ +#!./parrot +# Copyright (C) 2010, Parrot Foundation. +# $Id: string_mem.t 43904 2010-02-11 13:49:42Z whiteknight $ + +=head1 NAME + +t/op/gc-leaky.t - test for memory leaks in the Garbage Collector + +=head1 SYNOPSIS + + % prove t/op/gc-leaky.t + +=head1 DESCRIPTION + +Tests that we actually do a GC mark and sweep after a large number of PMC's have +been created. Test suggested by chromatic++ . More tests are needed to close +TT1465 - http://trac.parrot.org/parrot/ticket/1465 . + +=cut + +# 20:57 For every million PMCs allocated, see that the GC has performed a mark/sweep. + +.include 'interpinfo.pasm' + +.sub _main :main + .include 'test_more.pir' + + plan(2) + + $S0 = interpinfo .INTERPINFO_GC_SYS_NAME + if $S0 == "inf" goto dont_run_hanging_tests + + test_gc_mark_sweep() + + goto test_end + dont_run_hanging_tests: + ok(1, "#TODO - Test disabled on gc_inf") + ok(1, "#TODO - Test disabled on gc_inf") + test_end: +.end + +.sub test_gc_mark_sweep + .local int counter + counter = 0 + loop: + $P0 = box 0 + inc counter + if counter > 1e6 goto done + goto loop + done: + say "" + $I1 = interpinfo.INTERPINFO_GC_COLLECT_RUNS + $I2 = interpinfo.INTERPINFO_GC_MARK_RUNS + + $I3 = isge $I1, 1 + $I4 = isge $I2, 1 + + $S1 = $I1 + $S0 = "performed " . $S1 + $S0 .= " (which should be >=1) GC collect runs" + ok($I2,$S0) + + $S1 = $I2 + $S0 = "performed " . $S1 + $S0 .= " (which should be >=1) GC mark runs" + ok($I2,$S0) +.end + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: diff --git a/t/op/string_mem.t b/t/op/string_mem.t index c5e12eaf23..c8b42f2522 100644 --- a/t/op/string_mem.t +++ b/t/op/string_mem.t @@ -37,7 +37,6 @@ pin/unpin .sub _main :main .include 'test_more.pir' - .local pmc _ plan(TESTS) test_stringinfo() @@ -52,7 +51,6 @@ pin/unpin .end .sub test_stringinfo - .local pmc _ $S1 = "Hello, world" $S0 = $S1 -- 2.11.4.GIT