mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-09 20:29:11 +00:00
Convert simple CPU tests to xUnit
This commit is contained in:
parent
d9c637ed31
commit
7b178da1b2
2 changed files with 16 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
using ARMeilleure.CodeGen.Arm64;
|
using ARMeilleure.CodeGen.Arm64;
|
||||||
using NUnit.Framework;
|
using Xunit;
|
||||||
|
|
||||||
namespace Ryujinx.Tests.Cpu
|
namespace Ryujinx.Tests.Cpu
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace Ryujinx.Tests.Cpu
|
||||||
public int ImmR;
|
public int ImmR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly TestCase[] TestCases =
|
private static readonly TestCase[] _testCases =
|
||||||
{
|
{
|
||||||
new() { Value = 0, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
new() { Value = 0, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
||||||
new() { Value = 0x970977f35f848714, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
new() { Value = 0x970977f35f848714, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
||||||
|
@ -32,15 +32,18 @@ namespace Ryujinx.Tests.Cpu
|
||||||
new() { Value = 0x000000000ffff800, Valid = true, ImmN = 1, ImmS = 0x10, ImmR = 53 },
|
new() { Value = 0x000000000ffff800, Valid = true, ImmN = 1, ImmS = 0x10, ImmR = 53 },
|
||||||
};
|
};
|
||||||
|
|
||||||
[Test]
|
public static readonly EnumerableTheoryData<TestCase> TestData = new(_testCases);
|
||||||
public void BitImmTests([ValueSource(nameof(TestCases))] TestCase test)
|
|
||||||
|
[Theory]
|
||||||
|
[MemberData(nameof(TestData))]
|
||||||
|
public void BitImmTests(TestCase test)
|
||||||
{
|
{
|
||||||
bool valid = CodeGenCommon.TryEncodeBitMask(test.Value, out int immN, out int immS, out int immR);
|
bool valid = CodeGenCommon.TryEncodeBitMask(test.Value, out int immN, out int immS, out int immR);
|
||||||
|
|
||||||
Assert.That(valid, Is.EqualTo(test.Valid));
|
Assert.Equal(test.Valid, valid);
|
||||||
Assert.That(immN, Is.EqualTo(test.ImmN));
|
Assert.Equal(test.ImmN, immN);
|
||||||
Assert.That(immS, Is.EqualTo(test.ImmS));
|
Assert.Equal(test.ImmS, immS);
|
||||||
Assert.That(immR, Is.EqualTo(test.ImmR));
|
Assert.Equal(test.ImmR, immR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
using ARMeilleure.Translation;
|
using ARMeilleure.Translation;
|
||||||
using NUnit.Framework;
|
|
||||||
using Ryujinx.Cpu.Jit;
|
using Ryujinx.Cpu.Jit;
|
||||||
using Ryujinx.Tests.Memory;
|
using Ryujinx.Tests.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace Ryujinx.Tests.Cpu
|
namespace Ryujinx.Tests.Cpu
|
||||||
{
|
{
|
||||||
internal class EnvironmentTests
|
public class EnvironmentTests
|
||||||
{
|
{
|
||||||
#pragma warning disable IDE0052 // Remove unread private member
|
#pragma warning disable IDE0052 // Remove unread private member
|
||||||
private static Translator _translator;
|
private static Translator _translator;
|
||||||
|
@ -36,14 +36,14 @@ namespace Ryujinx.Tests.Cpu
|
||||||
/// This test ensures that managed methods do not reset floating point control flags.
|
/// This test ensures that managed methods do not reset floating point control flags.
|
||||||
/// This is used to avoid changing control flags when running methods that don't require it, such as SVC calls, software memory...
|
/// This is used to avoid changing control flags when running methods that don't require it, such as SVC calls, software memory...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Fact]
|
||||||
public void FpFlagsPInvoke()
|
public void FpFlagsPInvoke()
|
||||||
{
|
{
|
||||||
EnsureTranslator();
|
EnsureTranslator();
|
||||||
|
|
||||||
// Subnormal results are not flushed to zero by default.
|
// Subnormal results are not flushed to zero by default.
|
||||||
// This operation should not be allowed to do constant propagation, hence the methods that explicitly disallow inlining.
|
// This operation should not be allowed to do constant propagation, hence the methods that explicitly disallow inlining.
|
||||||
Assert.AreNotEqual(GetDenormal() + GetZero(), 0f);
|
Assert.NotEqual(0f, GetDenormal() + GetZero());
|
||||||
|
|
||||||
bool methodCalled = false;
|
bool methodCalled = false;
|
||||||
bool isFz = false;
|
bool isFz = false;
|
||||||
|
@ -56,7 +56,7 @@ namespace Ryujinx.Tests.Cpu
|
||||||
int result = method(Marshal.GetFunctionPointerForDelegate(ManagedMethod));
|
int result = method(Marshal.GetFunctionPointerForDelegate(ManagedMethod));
|
||||||
|
|
||||||
// Subnormal results are not flushed to zero by default, which we should have returned to exiting the method.
|
// Subnormal results are not flushed to zero by default, which we should have returned to exiting the method.
|
||||||
Assert.AreNotEqual(GetDenormal() + GetZero(), 0f);
|
Assert.NotEqual(0f, GetDenormal() + GetZero());
|
||||||
|
|
||||||
Assert.True(result == 0);
|
Assert.True(result == 0);
|
||||||
Assert.True(methodCalled);
|
Assert.True(methodCalled);
|
||||||
|
|
Loading…
Reference in a new issue