From: Rodrigo Kumpera Date: Fri, 5 Nov 2010 18:49:28 +0000 (-0200) Subject: Add tests for OOM handling. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=030f348396d83f9a53351f3b3d75e2880631e449;hp=004b5bfd73a16202b3ebbf5a635c8d5d1e3fa516;p=mono.git Add tests for OOM handling. --- diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 4f6fa21d73d..c25eb51e784 100644 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -889,6 +889,20 @@ test-process-exit: @$(RUNTIME) bug-438454.exe > bug-438454.exe.stdout @diff bug-438454.exe.stdout $(srcdir)/bug-438454.exe.stdout.expected +OOM_TESTS = \ + gc-oom-handling.exe \ + gc-oom-handling2.exe + + +test-oom: $(OOM_TESTS) + @for fn in $+ ; do \ + echo "Testing $$fn ..."; \ + MONO_GC_PARAMS=max-heap-size=16m,major=marksweep-par MONO_ENV_OPTIONS="--gc=sgen" $(RUNTIME) $$fn > $$fn.stdout || exit 1; \ + MONO_GC_PARAMS=max-heap-size=16m MONO_ENV_OPTIONS="--gc=sgen" $(RUNTIME) $$fn > $$fn.stdout || exit 1; \ + MONO_GC_PARAMS=max-heap-size=16m $(RUNTIME) $$fn > $$fn.stdout || exit 1; \ + done + + noinst_LTLIBRARIES = libtest.la INCLUDES = $(GLIB_CFLAGS) $(GMODULE_CFLAGS) diff --git a/mono/tests/gc-oom-handling.cs b/mono/tests/gc-oom-handling.cs new file mode 100644 index 00000000000..dc7c7f95c76 --- /dev/null +++ b/mono/tests/gc-oom-handling.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +class Driver { + static int Main () { + Console.WriteLine ("start"); + var l = new List (); + try { + for (int i = 0; i < 40000; ++i) { + var foo = new byte[2000]; + //Console.WriteLine ("done {0}",i); + if (foo == null) + Console.WriteLine ("WTF"); + l.Add (foo); + } + Console.WriteLine ("done"); + return -1; + } catch (Exception e) { + l.Clear (); + l = null; + Console.WriteLine ("OOM done"); + } + return 0; + } +} + diff --git a/mono/tests/gc-oom-handling2.cs b/mono/tests/gc-oom-handling2.cs new file mode 100644 index 00000000000..5b3cbf73aaf --- /dev/null +++ b/mono/tests/gc-oom-handling2.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +class Driver { + static int Main () { + Console.WriteLine ("start"); + var r = new Random (123456); + var l = new List (); + try { + for (int i = 0; i < 40000; ++i) { + var foo = new byte[r.Next () % 4000]; + l.Add (foo); + } + Console.WriteLine ("done"); + return -1; + } catch (Exception e) { + l.Clear (); + l = null; + Console.WriteLine ("OOM done"); + } + return 0; + } +} +