[tests] Fix flakiness on some tests that assume object finalization
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 14 Jul 2016 00:41:01 +0000 (03:41 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Wed, 20 Jul 2016 09:15:59 +0000 (12:15 +0300)
commit220b5f56b817618506efbfd370d8b5c8d66081fd
tree496e4c88bac3e4d8fb0c9600d273958eed783404
parent1172aac102461c1daaea2ca1319d7213aa728130
[tests] Fix flakiness on some tests that assume object finalization

A common pattern that we use across the test suite is to create objects on a new thread, join the thread, collect then expect certain objects to be dead/finalized since we assumed that thread to be no longer a source of pinning. This is not always the case since, after joining, the thread might still be alive and running unmanaged code related to the thread shutdown, which can reuse the stack that previously contained the managed references.

The workaround is to still allocate objects far down the stack, even if we are on a separate thread.

At the moment the helper can be used in tests which run under the TestDriver (since it's included in TestDriver.dll) and can also be included as a helper source for test bcl classes that need it.
mcs/class/corlib/Test/System.Runtime.CompilerServices/ConditionalWeakTableTest.cs
mcs/class/corlib/corlib_test.dll.sources
mcs/class/test-helpers/TestHelpers.cs [new symlink]
mono/mini/Makefile.am.in
mono/mini/TestHelpers.cs [new file with mode: 0644]
mono/tests/Makefile.am
mono/tests/sgen-toggleref.cs