mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-06 01:49:47 +08:00
[Tests] Isolate Gen5 scalar fallback test from parallel static mutation (#488)
ScalarLoadReadsTrackedFallbackMemory swaps the process-global static Gen5ShaderScalarEvaluator.FallbackMemoryReader under a lock private to the test class. The SharpEmu.Libs [ModuleInitializer] (AgcShaderCompilerHooks) assigns the same static to TryReadShaderGuestMemory the first time any Libs type is touched, and it does not take that lock. Under xUnit's default cross-class parallelism a concurrent Libs test could fire the initializer mid-test, clobbering the swapped-in reader — observed on CI (linux-x64) as the fallback returning all zeros: Expected [1181044592, 4, 1319632096, 4], Actual [0, 0, 0, 0]. Put the test in a DisableParallelization collection, matching the existing convention for shared-mutable-static tests (KernelMemoryCompatState, AjmState, AvPlayerPathState). The collection runs alone in the non-parallel phase, so no other test can mutate the static while this one holds it. Co-authored-by: slick-daddy <slick-daddy@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,20 @@ using Xunit;
|
|||||||
|
|
||||||
namespace SharpEmu.Libs.Tests.Agc;
|
namespace SharpEmu.Libs.Tests.Agc;
|
||||||
|
|
||||||
|
// Gen5ShaderScalarEvaluator.FallbackMemoryReader is a process-global static. This
|
||||||
|
// test swaps it, but the SharpEmu.Libs [ModuleInitializer] (AgcShaderCompilerHooks)
|
||||||
|
// reassigns the same static the first time any Libs type is touched. Under xUnit's
|
||||||
|
// default cross-class parallelism a Libs test running concurrently can fire that
|
||||||
|
// initializer mid-test and clobber the swapped-in reader (observed as all-zero
|
||||||
|
// reads on CI). A DisableParallelization collection runs alone in the non-parallel
|
||||||
|
// phase, so nothing else can mutate the static while this test holds it.
|
||||||
|
[CollectionDefinition(Gen5ScalarEvaluatorStateCollection.Name, DisableParallelization = true)]
|
||||||
|
public sealed class Gen5ScalarEvaluatorStateCollection
|
||||||
|
{
|
||||||
|
public const string Name = "Gen5ScalarEvaluatorState";
|
||||||
|
}
|
||||||
|
|
||||||
|
[Collection(Gen5ScalarEvaluatorStateCollection.Name)]
|
||||||
public sealed class Gen5ScalarMemoryFallbackTests
|
public sealed class Gen5ScalarMemoryFallbackTests
|
||||||
{
|
{
|
||||||
private const ulong ScalarTableAddress = 0x4_4665_4FD0;
|
private const ulong ScalarTableAddress = 0x4_4665_4FD0;
|
||||||
|
|||||||
Reference in New Issue
Block a user