-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic testing infrastructure in NativeAOT (port from dotnet/linke…
…r) (#70408) Add basic testing infrastructure in NativeAOT (port from dotnet/linker) - Port the Mono.Linker.Tests* projects from dotnet/linker - Add the new projects to .editorconfig so they remain under the dotnet/linker format instead of dotnet/runtime - clr.toolstests subset now runs the Mono.Linker.Tests infrastructure - Make DisplayNameHelpers a public class so it can be used by the test infrastructure - Add a couple of simple test cases (Dataflow and Requires) along with a Repro test, just like the repro project the repro test serves prototyping purposes - Adds ProducedBy.NativeAOT to be able to represent differences between dotnet/linker and NativeAOT (either because of a bug or because NativeAOT correctly produces additional warnings) - Use MSBuild properties instead of trying to figure out with linker paths
- Loading branch information
Showing
157 changed files
with
9,001 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/AddedPseudoAttributeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event, AllowMultiple = true, Inherited = false)] | ||
public class AddedPseudoAttributeAttribute : BaseExpectedLinkedBehaviorAttribute | ||
{ | ||
public AddedPseudoAttributeAttribute (uint value) | ||
{ | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseExpectedLinkedBehaviorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// <summary> | ||
/// Base attribute for attributes that mark up the expected behavior of the linker on a member | ||
/// </summary> | ||
[Conditional ("INCLUDE_EXPECTATIONS")] | ||
public abstract class BaseExpectedLinkedBehaviorAttribute : Attribute | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...eclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseInAssemblyAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
public abstract class BaseInAssemblyAttribute : BaseExpectedLinkedBehaviorAttribute | ||
{ | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/BaseMemberAssertionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// A base class for attributes that make assertions about a particular member. | ||
// The test infrastructure is expected to check the assertion on the member to which | ||
// the attribute is applied. | ||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Delegate, AllowMultiple = true)] | ||
public abstract class BaseMemberAssertionAttribute : Attribute | ||
{ | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...reclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/CreatedMemberAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Delegate | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = true, Inherited = false)] | ||
public sealed class CreatedMemberAttribute : BaseExpectedLinkedBehaviorAttribute | ||
{ | ||
|
||
public CreatedMemberAttribute (string name) | ||
{ | ||
if (string.IsNullOrEmpty (name)) | ||
throw new ArgumentException ("Value cannot be null or empty.", nameof (name)); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/DependencyRecordedAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)] | ||
public class DependencyRecordedAttribute : BaseExpectedLinkedBehaviorAttribute | ||
{ | ||
public DependencyRecordedAttribute (string source, string target, string marked = null) | ||
{ | ||
if (string.IsNullOrEmpty (source)) | ||
throw new ArgumentException ("Value cannot be null or empty.", nameof (source)); | ||
|
||
if (string.IsNullOrEmpty (target)) | ||
throw new ArgumentException ("Value cannot be null or empty.", nameof (target)); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...coreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/DisplayNameAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
public class DisplayNameAttribute : BaseMemberAssertionAttribute | ||
{ | ||
public DisplayNameAttribute (string expectedDisplayName) | ||
{ | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...oreclr/tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/EnableLoggerAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
public abstract class EnableLoggerAttribute : BaseExpectedLinkedBehaviorAttribute | ||
{ | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../tools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectBodyModifiedAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)] | ||
public class ExpectBodyModifiedAttribute : BaseInAssemblyAttribute | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...sts.Cases.Expectations/Assertions/ExpectExactlyResolvedDocumentationSignatureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// Asserts that the given documentation signature string resolves to the | ||
// member with this attribute, and only that member. | ||
public class ExpectExactlyResolvedDocumentationSignatureAttribute : BaseMemberAssertionAttribute | ||
{ | ||
public ExpectExactlyResolvedDocumentationSignatureAttribute (string input) | ||
{ | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...no.Linker.Tests.Cases.Expectations/Assertions/ExpectExceptionHandlersModifiedAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)] | ||
public class ExpectExceptionHandlersModifiedAttribute : BaseInAssemblyAttribute | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ker.Tests.Cases.Expectations/Assertions/ExpectGeneratedDocumentationSignatureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// Asserts that the member to which this attribute is applied has the given | ||
/// documentation signature. | ||
public class ExpectGeneratedDocumentationSignatureAttribute : BaseMemberAssertionAttribute | ||
{ | ||
public ExpectGeneratedDocumentationSignatureAttribute (string expected) | ||
{ | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ools/aot/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectLocalsModifiedAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)] | ||
public class ExpectLocalsModifiedAttribute : BaseInAssemblyAttribute | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...nker.Tests.Cases.Expectations/Assertions/ExpectResolvedDocumentationSignatureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// Asserts that the given documentation signature string resolves to the | ||
// member with this attribute. | ||
public class ExpectResolvedDocumentationSignatureAttribute : BaseMemberAssertionAttribute | ||
{ | ||
public ExpectResolvedDocumentationSignatureAttribute (string input) | ||
{ | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...er.Tests.Cases.Expectations/Assertions/ExpectUnresolvedDocumentationSignatureAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
/// Asserts that the given documentation signature string does not resolve | ||
/// to the member with this attribute. | ||
public class ExpectUnresolvedDocumentationSignatureAttribute : BaseMemberAssertionAttribute | ||
{ | ||
public ExpectUnresolvedDocumentationSignatureAttribute (string expected) | ||
{ | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...t/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)] | ||
public class ExpectedInstructionSequenceAttribute : BaseInAssemblyAttribute | ||
{ | ||
public ExpectedInstructionSequenceAttribute (string[] opCodes) | ||
{ | ||
if (opCodes == null) | ||
throw new ArgumentNullException (nameof (opCodes)); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...s.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
namespace Mono.Linker.Tests.Cases.Expectations.Assertions | ||
{ | ||
[AttributeUsage (AttributeTargets.Class, Inherited = false, AllowMultiple = true)] | ||
public class ExpectedInstructionSequenceOnMemberInAssemblyAttribute : BaseInAssemblyAttribute | ||
{ | ||
public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, Type type, string memberName, string[] opCodes) | ||
{ | ||
if (string.IsNullOrEmpty (assemblyFileName)) | ||
throw new ArgumentNullException (nameof (assemblyFileName)); | ||
if (type == null) | ||
throw new ArgumentNullException (nameof (type)); | ||
if (string.IsNullOrEmpty (memberName)) | ||
throw new ArgumentNullException (nameof (memberName)); | ||
if (opCodes == null) | ||
throw new ArgumentNullException (nameof (opCodes)); | ||
} | ||
|
||
public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, string typeName, string memberName, string[] opCodes) | ||
{ | ||
if (string.IsNullOrEmpty (assemblyFileName)) | ||
throw new ArgumentNullException (nameof (assemblyFileName)); | ||
if (string.IsNullOrEmpty (typeName)) | ||
throw new ArgumentNullException (nameof (typeName)); | ||
if (string.IsNullOrEmpty (memberName)) | ||
throw new ArgumentNullException (nameof (memberName)); | ||
if (opCodes == null) | ||
throw new ArgumentNullException (nameof (opCodes)); | ||
} | ||
} | ||
} |
Oops, something went wrong.