From 2c884075cab3af77d235278841b7efac553a4046 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Jul 2023 20:48:34 +0200 Subject: [PATCH] Convert system CPU test to xUnit --- src/Ryujinx.Tests/Cpu/CpuTestSystem.cs | 37 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/Ryujinx.Tests/Cpu/CpuTestSystem.cs b/src/Ryujinx.Tests/Cpu/CpuTestSystem.cs index a975bbc83a..8415cef8ef 100644 --- a/src/Ryujinx.Tests/Cpu/CpuTestSystem.cs +++ b/src/Ryujinx.Tests/Cpu/CpuTestSystem.cs @@ -1,5 +1,8 @@ -// #define System +#define System +using ARMeilleure.State; +using System; +using System.Collections.Generic; using Xunit; namespace Ryujinx.Tests.Cpu @@ -17,10 +20,10 @@ namespace Ryujinx.Tests.Cpu yield return 0x8000000000000000ul; yield return 0xFFFFFFFFFFFFFFFFul; - bool v = TestContext.CurrentContext.Random.NextBool(); - bool c = TestContext.CurrentContext.Random.NextBool(); - bool z = TestContext.CurrentContext.Random.NextBool(); - bool n = TestContext.CurrentContext.Random.NextBool(); + bool v = Random.Shared.NextBool(); + bool c = Random.Shared.NextBool(); + bool z = Random.Shared.NextBool(); + bool n = Random.Shared.NextBool(); ulong rnd = 0UL; @@ -44,19 +47,25 @@ namespace Ryujinx.Tests.Cpu } #endregion - [Test, Pairwise] - public void MrsMsr_Nzcv([ValueSource(nameof(_MrsMsr_Nzcv_))] uint opcodes, - [Values(0u, 1u, 31u)] uint rt, - [ValueSource(nameof(_GenNzcv_))] ulong xt) + private static readonly uint[] _testData_rt = + { + 0u, 1u, 31u, + }; + + public static readonly MatrixTheoryData TestData = new(_MrsMsr_Nzcv_(), _testData_rt, _GenNzcv_()); + + [Theory] + [MemberData(nameof(TestData))] + public void MrsMsr_Nzcv(uint opcodes, uint rt, ulong xt) { opcodes |= (rt & 31) << 0; - bool v = TestContext.CurrentContext.Random.NextBool(); - bool c = TestContext.CurrentContext.Random.NextBool(); - bool z = TestContext.CurrentContext.Random.NextBool(); - bool n = TestContext.CurrentContext.Random.NextBool(); + bool v = Random.Shared.NextBool(); + bool c = Random.Shared.NextBool(); + bool z = Random.Shared.NextBool(); + bool n = Random.Shared.NextBool(); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcodes, x0: xt, x1: xt, x31: x31, overflow: v, carry: c, zero: z, negative: n);