Skip to content

Commit

Permalink
Runtime test to reproduce threadpool+ProcessExit issue
Browse files Browse the repository at this point in the history
Do make test-process-exit to run


Commit migrated from mono/mono@a2e5492
  • Loading branch information
roji committed Nov 18, 2012
1 parent 4618fa2 commit c197ab9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mono/mono/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,16 @@ patch-libtool:
sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile
touch libtest.c

EXTRA_DIST += bug-438454.cs bug-438454.exe.stdout.expected
EXTRA_DIST += bug-438454.cs bug-438454.exe.stdout.expected threadpool-in-processexit.cs threadpool-in-processexit.exe.stdout.expected
test-process-exit:
@$(MCS) $(srcdir)/bug-438454.cs -out:bug-438454.exe
@echo "Testing bug-438454.exe..."
@$(RUNTIME) bug-438454.exe > bug-438454.exe.stdout
@diff -w bug-438454.exe.stdout $(srcdir)/bug-438454.exe.stdout.expected
@$(MCS) $(srcdir)/threadpool-in-processexit.cs -out:threadpool-in-processexit.exe
@echo "Testing threadpool-in-processexit.exe..."
@$(RUNTIME) threadpool-in-processexit.exe > threadpool-in-processexit.exe.stdout
@diff -w threadpool-in-processexit.exe.stdout $(srcdir)/threadpool-in-processexit.exe.stdout.expected

OOM_TESTS = \
gc-oom-handling.exe \
Expand Down
26 changes: 26 additions & 0 deletions src/mono/mono/tests/threadpool-in-processexit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Threading;

class Program
{
static AutoResetEvent mre = new AutoResetEvent(false);

static void Main ()
{
AppDomain.CurrentDomain.ProcessExit += SomeEndOfProcessAction;
}

static void SomeEndOfProcessAction(object sender, EventArgs args)
{
ThreadPool.QueueUserWorkItem (new WaitCallback (ThreadPoolCallback));
if (mre.WaitOne(1000))
Console.WriteLine ("PASS");
else
Console.WriteLine ("FAIL");
}

static void ThreadPoolCallback (object state)
{
mre.Set ();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PASS

0 comments on commit c197ab9

Please sign in to comment.