Fix and enable failed gradient signal tests on Linux

* Fix failure reason for PerlinGradientComponent_GoldenTest: non-standard behavior of std::shuffle producing different results across platforms
* Fix failure reason for GradientImageAssetConversionU8SingleScale: Undefined behavior when float casts to a uint8 has overflow

Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
This commit is contained in:
Steve Pham
2021-12-08 14:28:45 -08:00
committed by GitHub
parent fc71f3f81d
commit 9b480f252e
7 changed files with 37 additions and 9 deletions
@@ -38,3 +38,9 @@
#define AZ_TRAIT_DISABLE_FAILED_VEGETATION_TESTS true
#define AZ_TRAIT_DISABLE_LOG_ALWAYS_FUZZ_TEST true
// Golden perline gradiant values for random seed 7878 for this platform
#define AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 0.5000f, 0.5456f, 0.5138f, 0.4801f, \
0.4174f, 0.4942f, 0.5493f, 0.5431f, \
0.4984f, 0.5204f, 0.5526f, 0.5840f, \
0.5251f, 0.5029f, 0.6153f, 0.5802f,
@@ -18,7 +18,7 @@
#define AZ_TRAIT_DISABLE_FAILED_FRAMEPROFILER_TEST true
#define AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_GRADIENT_SIGNAL_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_NATIVE_WINDOWS_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_TESTS true
@@ -27,3 +27,9 @@
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_METRICS_TESTS true
// Golden perline gradiant values for random seed 7878 for this platform
#define AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 0.5000f, 0.4455f, 0.4838f, 0.4589f, \
0.4539f, 0.5138f, 0.4104f, 0.4618f, \
0.4572f, 0.4894f, 0.4767f, 0.4197f, \
0.5500f, 0.4635f, 0.5199f, 0.4467f, \
@@ -16,3 +16,9 @@
#define AZ_TRAIT_DISABLE_ASSET_JOB_PARALLEL_TESTS true
#define AZ_TRAIT_DISABLE_ASSET_MANAGER_FLOOD_TEST true
#define AZ_TRAIT_DISABLE_ASSETCONTAINERDISABLETEST true
// Golden perline gradiant values for random seed 7878 for this platform
#define AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 0.5000f, 0.5456f, 0.5138f, 0.4801f, \
0.4174f, 0.4942f, 0.5493f, 0.5431f, \
0.4984f, 0.5204f, 0.5526f, 0.5840f, \
0.5251f, 0.5029f, 0.6153f, 0.5802f,
@@ -13,3 +13,9 @@
#define AZ_TRAIT_UNIT_TEST_ASSET_MANAGER_TEST_DEFAULT_TIMEOUT_SECS 5
#define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000
#define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000
// Golden perline gradiant values for random seed 7878 for this platform
#define AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 0.5000f, 0.5456f, 0.5138f, 0.4801f, \
0.4174f, 0.4942f, 0.5493f, 0.5431f, \
0.4984f, 0.5204f, 0.5526f, 0.5840f, \
0.5251f, 0.5029f, 0.6153f, 0.5802f,
@@ -16,3 +16,9 @@
#define AZ_TRAIT_DISABLE_ASSET_JOB_PARALLEL_TESTS true
#define AZ_TRAIT_DISABLE_ASSET_MANAGER_FLOOD_TEST true
#define AZ_TRAIT_DISABLE_ASSETCONTAINERDISABLETEST true
// Golden perline gradiant values for random seed 7878 for this platform
#define AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 0.5000f, 0.5456f, 0.5138f, 0.4801f, \
0.4174f, 0.4942f, 0.5493f, 0.5431f, \
0.4984f, 0.5204f, 0.5526f, 0.5840f, \
0.5251f, 0.5029f, 0.6153f, 0.5802f,
@@ -157,13 +157,6 @@ namespace UnitTest
// matches a previously-calculated "golden" set of values.
constexpr int dataSize = 4;
AZStd::vector<float> expectedOutput =
{
0.5000f, 0.5456f, 0.5138f, 0.4801f,
0.4174f, 0.4942f, 0.5493f, 0.5431f,
0.4984f, 0.5204f, 0.5526f, 0.5840f,
0.5251f, 0.5029f, 0.6153f, 0.5802f,
};
GradientSignal::PerlinGradientConfig config;
config.m_randomSeed = 7878;
@@ -171,6 +164,8 @@ namespace UnitTest
config.m_amplitude = 3.0f;
config.m_frequency = 1.13f;
AZStd::vector<float> expectedOutput = { AZ_TRAIT_UNIT_TEST_PERLINE_GRADIANT_GOLDEN_VALUES_7878 };
auto entity = CreateEntity();
CreateComponent<GradientSignal::PerlinGradientComponent>(entity.get(), config);
@@ -111,7 +111,10 @@ namespace
constexpr auto numChannels = 1;
constexpr auto bytesPerPixel = numChannels * sizeof(AZ::u8);
constexpr auto outputSize = imageDimensions * imageDimensions;
constexpr auto scaling = 25;
// Adjust the test scale so that none of the input data overflows the cast to AZ::u8.
// The overflow behavior when casting from float to uint8 is undefined so we want to
// avoid that consistently across all platforms
constexpr auto scaling = 255.0f / aznumeric_cast<float>(imageDimensions * imageDimensions);
auto inputData = Detail::GenerateInput<AZ::u8, imageDimensions, numChannels>(scaling);