Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "shared-infrastructure"]
path = shared-infrastructure
url = https://github.com/SixLabors/SharedInfrastructure
url = https://github.com/stefannikolei/SharedInfrastructure
2 changes: 1 addition & 1 deletion shared-infrastructure
1 change: 0 additions & 1 deletion tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<PackageReference Update="Colourful" Version="3.2.0" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="14.11.1" />
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="10.0.0-beta.25563.105" />
<PackageReference Update="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.23580.1" />
<PackageReference Update="Moq" Version="4.20.72" />
<PackageReference Update="NetVips" Version="3.0.0" />
<PackageReference Update="NetVips.Native" Version="8.16.0" />
Expand Down
7 changes: 6 additions & 1 deletion tests/ImageSharp.Tests.ProfilingSandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations;
using SixLabors.ImageSharp.Tests.ProfilingBenchmarks;
using SixLabors.ImageSharp.Tests.ProfilingSandbox;
using Xunit.Abstractions;
using Xunit;

// in this file, comments are used for disabling stuff for local execution
#pragma warning disable SA1515
Expand Down Expand Up @@ -32,7 +32,12 @@ static void RunToVector4ProfilingTest()

sealed class ConsoleOutput : ITestOutputHelper
{
public void Write(string message) => Console.Write(message);

public void Write(string format, params object[] args) => Console.Write(format, args);

public void WriteLine(string message) => Console.WriteLine(message);

public void WriteLine(string format, params object[] args) => Console.WriteLine(format, args);
public string Output { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using Wacton.Unicolour;
using Wacton.Unicolour.Icc;
using Xunit.Abstractions;
using Rgb = SixLabors.ImageSharp.ColorProfiles.Rgb;

namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc;
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Common/NumericsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Common;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Runtime.Intrinsics.X86;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Common;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License.

using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Tests.ColorProfiles;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// ReSharper disable InconsistentNaming
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Formats.Jpeg.Components;

using Xunit.Abstractions;

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Formats.Png;

Expand Down
8 changes: 4 additions & 4 deletions tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ public void WorksWithAllBitDepths<TPixel>(TestImageProvider<TPixel> provider, Pn
return;
}

foreach (object[] filterMethod in PngFilterMethods)
foreach (TheoryDataRow<PngFilterMethod> filterMethod in PngFilterMethods)
{
foreach (PngInterlaceMode interlaceMode in InterlaceMode)
{
TestPngEncoderCore(
provider,
pngColorType,
(PngFilterMethod)filterMethod[0],
filterMethod.Data,
pngBitDepth,
interlaceMode,
appendPngColorType: true,
Expand Down Expand Up @@ -236,14 +236,14 @@ public void WorksWithAllBitDepths<TPixel>(TestImageProvider<TPixel> provider, Pn
public void WorksWithAllBitDepthsAndExcludeAllFilter<TPixel>(TestImageProvider<TPixel> provider, PngColorType pngColorType, PngBitDepth pngBitDepth)
where TPixel : unmanaged, IPixel<TPixel>
{
foreach (object[] filterMethod in PngFilterMethods)
foreach (TheoryDataRow<PngFilterMethod> filterMethod in PngFilterMethods)
{
foreach (PngInterlaceMode interlaceMode in InterlaceMode)
{
TestPngEncoderCore(
provider,
pngColorType,
(PngFilterMethod)filterMethod[0],
filterMethod.Data,
pngBitDepth,
interlaceMode,
appendPngColorType: true,
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;

namespace SixLabors.ImageSharp.Tests.Helpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static TheoryData<bool, string, double> CreateLoadData()
public static TheoryData<bool, string, double> LoadData { get; } = CreateLoadData();

// TODO: Figure out cancellation failures on Linux
[ConditionalTheory(typeof(TestEnvironment), nameof(TestEnvironment.IsWindows))]
[Theory(Skip = "Skipped on non-Windows platforms", SkipType = typeof(TestEnvironment), SkipUnless = nameof(TestEnvironment.IsWindows))]
[MemberData(nameof(LoadData))]
public async Task LoadAsync_IsCancellable(bool useMemoryStream, string file, double percentageOfStreamReadToCancel)
{
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/ImageSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="Moq" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Condition="'$(IsOSX)'=='true'" />
<PackageReference Include="SharpZipLib" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ public partial class UniformUnmanagedMemoryPoolTests
public class Trim
{
[CollectionDefinition(nameof(NonParallelTests), DisableParallelization = true)]
public class NonParallelTests
{
}
public class NonParallelTests { }

[Fact]
public void TrimPeriodElapsed_TrimsHalfOfUnusedArrays()
{
RemoteExecutor.Invoke(RunTest).Dispose();
static void RunTest()
{
UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 5_000 };
UniformUnmanagedMemoryPool.TrimSettings trimSettings = new()
{
TrimPeriodMilliseconds = 5_000,
};
UniformUnmanagedMemoryPool pool = new(128, 256, trimSettings);

UnmanagedMemoryHandle[] a = pool.Rent(64);
Expand All @@ -37,7 +38,8 @@ static void RunTest()
// 128 - 32 - 16 = 80
Assert.True(
UnmanagedMemoryHandle.TotalOutstandingHandles <= 80,
$"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 80");
$"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 80"
);
pool.Return(b);
}
}
Expand All @@ -46,18 +48,16 @@ static void RunTest()
// MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed,
// which is strongly timing-sensitive, and might be flaky under high load.
[CollectionDefinition(nameof(NonParallelCollection), DisableParallelization = true)]
public class NonParallelCollection
{
}
public class NonParallelCollection { }

[Collection(nameof(NonParallelCollection))]
public class NonParallel
{
public static readonly bool IsNotMacOS = !TestEnvironment.IsMacOS;
public static bool IsNotMacOS => !TestEnvironment.IsMacOS;

// TODO: Investigate failures on macOS. All handles are released after GC.
// (It seems to happen more consistently on .NET 6.)
[ConditionalFact(nameof(IsNotMacOS))]
[Fact(Skip = "Skipped on macOS", SkipUnless = nameof(IsNotMacOS))]
public void MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed()
{
if (!TestEnvironment.RunsOnCI)
Expand All @@ -77,10 +77,16 @@ public void MultiplePoolInstances_TrimPeriodElapsed_AllAreTrimmed()

static void RunTest()
{
UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() { TrimPeriodMilliseconds = 6_000 };
UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new()
{
TrimPeriodMilliseconds = 6_000,
};
UniformUnmanagedMemoryPool pool1 = new(128, 256, trimSettings1);
Thread.Sleep(8_000); // Let some callbacks fire already
UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() { TrimPeriodMilliseconds = 3_000 };
UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new()
{
TrimPeriodMilliseconds = 3_000,
};
UniformUnmanagedMemoryPool pool2 = new(128, 256, trimSettings2);

pool1.Return(pool1.Rent(64));
Expand All @@ -96,21 +102,25 @@ static void RunTest()
Thread.Sleep(15_000);
Assert.True(
UnmanagedMemoryHandle.TotalOutstandingHandles <= 64,
$"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 64");
$"UnmanagedMemoryHandle.TotalOutstandingHandles={UnmanagedMemoryHandle.TotalOutstandingHandles} > 64"
);
GC.KeepAlive(pool1);
GC.KeepAlive(pool2);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void LeakPoolInstance()
{
UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 4_000 };
UniformUnmanagedMemoryPool.TrimSettings trimSettings = new()
{
TrimPeriodMilliseconds = 4_000,
};
_ = new UniformUnmanagedMemoryPool(128, 256, trimSettings);
}
}
}

public static readonly bool Is32BitProcess = !Environment.Is64BitProcess;
public static bool Is32BitProcess => !Environment.Is64BitProcess;
private static readonly List<byte[]> PressureArrays = [];

[Fact]
Expand All @@ -129,11 +139,16 @@ static void RunTest()
Assert.False(Environment.Is64BitProcess);
const int oneMb = 1 << 20;

UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { HighPressureThresholdRate = 0.2f };
UniformUnmanagedMemoryPool.TrimSettings trimSettings = new()
{
HighPressureThresholdRate = 0.2f,
};

GCMemoryInfo memInfo = GC.GetGCMemoryInfo();
int highLoadThreshold = (int)(memInfo.HighMemoryLoadThresholdBytes / oneMb);
highLoadThreshold = (int)(trimSettings.HighPressureThresholdRate * highLoadThreshold);
highLoadThreshold = (int)(
trimSettings.HighPressureThresholdRate * highLoadThreshold
);

UniformUnmanagedMemoryPool pool = new(oneMb, 16, trimSettings);
pool.Return(pool.Rent(16));
Expand Down
Loading
Loading