gtest_repeat crashes (#7645)

* Moved allocation to avoid crash on gtest_repeat.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fixed GradientSignal tests to work with gtest_repeat.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
monroegm-disable-blank-issue-2
Mike Balfour 4 years ago committed by GitHub
parent aaa8b9df7c
commit 7fbcab9f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,7 +52,6 @@ namespace AZ
GemTestEnvironment::GemTestEnvironment()
{
m_parameters = new Parameters;
}
void GemTestEnvironment::AddDynamicModulePaths(const AZStd::vector<AZStd::string>& dynamicModulePaths)
@ -84,6 +83,8 @@ namespace AZ
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
m_parameters = new Parameters;
AddGemsAndComponents();
PreCreateApplication();

@ -75,6 +75,22 @@ namespace UnitTest
});
}
void GradientSignalTestEnvironment::PostCreateApplication()
{
// Ebus usage will allocate a global context on first usage. If that first usage occurs in a DLL, then the context will be
// invalid on subsequent unit test runs if using gtest_repeat. However, if we force the ebus to create their global context in
// the main test DLL (this one), the context will remain active throughout repeated runs. By creating them in
// PostCreateApplication(), they will be created before the DLLs get loaded and any system components from those DLLs run, so we
// can guarantee this will be the first usage.
// These ebuses need their contexts created here before any of the dependent DLLs get loaded:
AZ::AssetTypeInfoBus::GetOrCreateContext();
SurfaceData::SurfaceDataSystemRequestBus::GetOrCreateContext();
SurfaceData::SurfaceDataProviderRequestBus::GetOrCreateContext();
SurfaceData::SurfaceDataModifierRequestBus::GetOrCreateContext();
LmbrCentral::ShapeComponentRequestsBus::GetOrCreateContext();
}
void GradientSignalBaseFixture::SetupCoreSystems()
{
// Using the AZ::RPI::MakeAssetHandler will both create the asset handlers,

@ -21,6 +21,7 @@ namespace UnitTest
{
public:
void AddGemsAndComponents() override;
void PostCreateApplication() override;
};
#ifdef HAVE_BENCHMARK

Loading…
Cancel
Save