mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-28 01:50:50 +01:00
chore: Update tests dependencies (#3978)
* chore: Update tests dependencies * Apply TSR Berry suggestion to add a GC.SuppressFinalize in MemoryBlock.cs * Ensure we wait for the test thread to be dead on PartialUnmap * Use platform attribute for os specific tests * Make P/Invoke methods private * Downgrade NUnit3TestAdapter to 4.1.0 * test: Disable warning about platform compat for ThreadLocalMap() Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
This commit is contained in:
parent
b1d4b174a6
commit
b6614c6ad5
@ -25,7 +25,7 @@
|
|||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||||
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
|
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
|
||||||
<PackageVersion Include="NUnit" Version="3.13.3" />
|
<PackageVersion Include="NUnit" Version="3.13.3" />
|
||||||
<PackageVersion Include="NUnit3TestAdapter" Version="3.17.0" />
|
<PackageVersion Include="NUnit3TestAdapter" Version="4.1.0" />
|
||||||
<PackageVersion Include="OpenTK.Core" Version="4.7.5" />
|
<PackageVersion Include="OpenTK.Core" Version="4.7.5" />
|
||||||
<PackageVersion Include="OpenTK.Graphics" Version="4.7.5" />
|
<PackageVersion Include="OpenTK.Graphics" Version="4.7.5" />
|
||||||
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.5" />
|
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.5" />
|
||||||
|
@ -27,7 +27,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
|||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
public static partial int GetCurrentThreadId();
|
private static partial int GetCurrentThreadId();
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
@ -36,7 +36,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
|||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
[return: MarshalAs (UnmanagedType.Bool)]
|
[return: MarshalAs (UnmanagedType.Bool)]
|
||||||
public static partial bool CloseHandle(IntPtr hObject);
|
private static partial bool CloseHandle(IntPtr hObject);
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
@ -160,4 +160,4 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,14 +39,10 @@ namespace Ryujinx.Memory.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
[Platform(Exclude = "MacOsX")]
|
||||||
public void Test_Alias()
|
public void Test_Alias()
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
// Memory aliasing tests fail on CI at the moment.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using MemoryBlock backing = new MemoryBlock(0x10000, MemoryAllocationFlags.Mirrorable);
|
using MemoryBlock backing = new MemoryBlock(0x10000, MemoryAllocationFlags.Mirrorable);
|
||||||
using MemoryBlock toAlias = new MemoryBlock(0x10000, MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible);
|
using MemoryBlock toAlias = new MemoryBlock(0x10000, MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible);
|
||||||
|
|
||||||
@ -58,14 +54,10 @@ namespace Ryujinx.Memory.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
[Platform(Exclude = "MacOsX")]
|
||||||
public void Test_AliasRandom()
|
public void Test_AliasRandom()
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
// Memory aliasing tests fail on CI at the moment.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using MemoryBlock backing = new MemoryBlock(0x80000, MemoryAllocationFlags.Mirrorable);
|
using MemoryBlock backing = new MemoryBlock(0x80000, MemoryAllocationFlags.Mirrorable);
|
||||||
using MemoryBlock toAlias = new MemoryBlock(0x80000, MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible);
|
using MemoryBlock toAlias = new MemoryBlock(0x80000, MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible);
|
||||||
|
|
||||||
@ -94,14 +86,10 @@ namespace Ryujinx.Memory.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
[Platform(Exclude = "MacOsX")]
|
||||||
public void Test_AliasMapLeak()
|
public void Test_AliasMapLeak()
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
// Memory aliasing tests fail on CI at the moment.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong pageSize = 4096;
|
ulong pageSize = 4096;
|
||||||
ulong size = 100000 * pageSize; // The mappings limit on Linux is usually around 65K, so let's make sure we are above that.
|
ulong size = 100000 * pageSize; // The mappings limit on Linux is usually around 65K, so let's make sure we are above that.
|
||||||
|
|
||||||
|
@ -379,7 +379,12 @@ namespace Ryujinx.Memory
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// It's an error to use the memory block after disposal.
|
/// It's an error to use the memory block after disposal.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void Dispose() => FreeMemory();
|
public void Dispose()
|
||||||
|
{
|
||||||
|
FreeMemory();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
~MemoryBlock() => FreeMemory();
|
~MemoryBlock() => FreeMemory();
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ using Ryujinx.Memory.Tests;
|
|||||||
using Ryujinx.Memory.Tracking;
|
using Ryujinx.Memory.Tracking;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -57,14 +58,10 @@ namespace Ryujinx.Tests.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
[Platform(Exclude = "MacOsX")]
|
||||||
public void PartialUnmap([Values] bool readOnly)
|
public void PartialUnmap([Values] bool readOnly)
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
// Memory aliasing tests fail on CI at the moment.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up an address space to test partial unmapping.
|
// Set up an address space to test partial unmapping.
|
||||||
// Should register the signal handler to deal with this on Windows.
|
// Should register the signal handler to deal with this on Windows.
|
||||||
ulong vaSize = 0x100000;
|
ulong vaSize = 0x100000;
|
||||||
@ -78,11 +75,13 @@ namespace Ryujinx.Tests.Memory
|
|||||||
|
|
||||||
ref var state = ref PartialUnmapState.GetRef();
|
ref var state = ref PartialUnmapState.GetRef();
|
||||||
|
|
||||||
|
Thread testThread = null;
|
||||||
|
bool shouldAccess = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Globally reset the struct for handling partial unmap races.
|
// Globally reset the struct for handling partial unmap races.
|
||||||
PartialUnmapState.Reset();
|
PartialUnmapState.Reset();
|
||||||
bool shouldAccess = true;
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
// Create a large mapping.
|
// Create a large mapping.
|
||||||
@ -93,8 +92,6 @@ namespace Ryujinx.Tests.Memory
|
|||||||
memory.Reprotect(0, vaSize, MemoryPermission.Read);
|
memory.Reprotect(0, vaSize, MemoryPermission.Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread testThread;
|
|
||||||
|
|
||||||
if (readOnly)
|
if (readOnly)
|
||||||
{
|
{
|
||||||
// Write a value to the physical memory, then try to read it repeately from virtual.
|
// Write a value to the physical memory, then try to read it repeately from virtual.
|
||||||
@ -193,6 +190,10 @@ namespace Ryujinx.Tests.Memory
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
// In case something failed, we want to ensure the test thread is dead before disposing of the memory.
|
||||||
|
shouldAccess = false;
|
||||||
|
testThread?.Join();
|
||||||
|
|
||||||
exceptionHandler.Dispose();
|
exceptionHandler.Dispose();
|
||||||
unusedMainMemory.Dispose();
|
unusedMainMemory.Dispose();
|
||||||
memory.Dispose();
|
memory.Dispose();
|
||||||
@ -201,13 +202,10 @@ namespace Ryujinx.Tests.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Memory aliasing tests fail on CI at the moment.
|
||||||
|
[Platform(Exclude = "MacOsX")]
|
||||||
public unsafe void PartialUnmapNative()
|
public unsafe void PartialUnmapNative()
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
// Memory aliasing tests fail on CI at the moment.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up an address space to test partial unmapping.
|
// Set up an address space to test partial unmapping.
|
||||||
// Should register the signal handler to deal with this on Windows.
|
// Should register the signal handler to deal with this on Windows.
|
||||||
@ -284,26 +282,17 @@ namespace Ryujinx.Tests.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Only test in Windows, as this is only used on Windows and uses Windows APIs for trimming.
|
||||||
|
[Platform("Win")]
|
||||||
|
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
|
||||||
public void ThreadLocalMap()
|
public void ThreadLocalMap()
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
// Only test in Windows, as this is only used on Windows and uses Windows APIs for trimming.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PartialUnmapState.Reset();
|
PartialUnmapState.Reset();
|
||||||
ref var state = ref PartialUnmapState.GetRef();
|
ref var state = ref PartialUnmapState.GetRef();
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
var testThread = new Thread(() =>
|
var testThread = new Thread(() =>
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
// Need this here to avoid a warning.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PartialUnmapState.GetRef().RetryFromAccessViolation();
|
PartialUnmapState.GetRef().RetryFromAccessViolation();
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
@ -330,14 +319,10 @@ namespace Ryujinx.Tests.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
// Only test in Windows, as this is only used on Windows and uses Windows APIs for trimming.
|
||||||
|
[Platform("Win")]
|
||||||
public unsafe void ThreadLocalMapNative()
|
public unsafe void ThreadLocalMapNative()
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
// Only test in Windows, as this is only used on Windows and uses Windows APIs for trimming.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnsureTranslator();
|
EnsureTranslator();
|
||||||
|
|
||||||
PartialUnmapState.Reset();
|
PartialUnmapState.Reset();
|
||||||
@ -481,4 +466,4 @@ namespace Ryujinx.Tests.Memory
|
|||||||
Assert.False(error);
|
Assert.False(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user