Fix Nagler tests to run on Linux#524
Conversation
Date: Mon Oct 10 11:23:07 2022 -0700
Squashed commit of the following:
commit 2292449
Author: William Xie <willxie@microsoft.com>
Date: Fri Oct 7 14:30:06 2022 -0700
Fix up some last bugs
commit 364ab15
Author: William Xie <willxie@microsoft.com>
Date: Fri Oct 7 10:36:24 2022 -0700
Fix libxml2 handling of comment nodes
commit 4bcbe1f
Author: William Xie <willxie@microsoft.com>
Date: Thu Oct 6 21:42:24 2022 -0700
Add timeout override
commit 85b5661
Author: William Xie <willxie@microsoft.com>
Date: Thu Oct 6 21:22:28 2022 -0700
Fix logging test
commit 8ca135c
Author: William Xie <willxie@microsoft.com>
Date: Thu Oct 6 21:02:01 2022 -0700
Fix linux nagler tests
commit e21c6db
Author: William Xie <willxie@microsoft.com>
Date: Thu Oct 6 11:33:38 2022 -0700
temporary changes
|
TODO: update In reply to: 1273686615 |
| public const string NaglerInstrumentationConfigX86BinPath = @"../../x86/NaglerInstrumentationMethod_x86.xml"; | ||
| public const string NaglerInstrumentationMethodX64BinPath = @"../../x64/NaglerInstrumentationMethod_x64.dll"; | ||
| public const string NaglerInstrumentationMethodX86BinPath = @"../../x86/NaglerInstrumentationMethod_x86.dll"; | ||
| public const string LinuxInstrumentationEngineX64BinPath = @"../../../../out/Linux/bin/x64.Debug/ClrInstrumentationEngine/libInstrumentationEngine.so"; |
There was a problem hiding this comment.
I wish unit tests supported conditionally ignoring tests. Maybe separate the tests into categories, and only run the Windows tests on Windows, and the other tests on other platforms?
There was a problem hiding this comment.
We can potentially leverage the --filter option on dotnet test and rename some tests with a Windows prefix, but I'd like to make that change in a separate PR.
There was a problem hiding this comment.
Another way to do this is, I think, deployment items can be entire directories. So, we could copy the files that we need to a particular location as part of the build, and then just deploy the directory.
There was a problem hiding this comment.
Yeah, that's essentially the same thing. You can filter on categories as well. Something like this:
internal abstract class TestClassImpl
{
[TestMethod]
void Method1() {...}
}
[TestClass]
[Category("Windows")];
[DeploymentItem("WindowsFile", ...)]
internal class WindowsTest : TestClassImpl {}
[TestClass]
[Category("Linux")];
[DeploymentItem("LinuxFile", ...)]
internal class LinuxTest: TestClassImpl {}
|
@microsoft-github-policy-service test |
|
@microsoft-github-policy-service agree company="Microsoft" |
|
@microsoft-github-policy-service agree |
| targetFolder: $(Build.StagingDirectory)/binaries-windows-$(Configuration)/AnyCPU/net70/ | ||
|
|
||
| - task: UseDotNet@2 | ||
| displayName: 'Use .NET 7 sdk' |
There was a problem hiding this comment.
Should we test .NET 6 as well, since it is the LTS version? We could parameterize this job and run it twice. #Closed
There was a problem hiding this comment.
Makes sense, I'll update
| is32bitTest ? HostConfig32PathEnvName : HostConfig64PathEnvName, | ||
| Path.Combine(PathUtils.GetAssetsPath(), string.Format(CultureInfo.InvariantCulture, "NaglerInstrumentationMethod_{0}.xml", bitnessSuffix))); | ||
| } | ||
| else // Linux |
| [Timeout(TestConstants.TestTimeout)] | ||
| public void TestRefStructs_Validate_RefStructWithRefField_Load() | ||
| { | ||
| if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
There was a problem hiding this comment.
Instead of rewriting this code over and over, you can extend TestMethodAttribute:
internal class WindowsTestMethodAttribute: TestMethodAttribute
{
public override TestResult[] Execute(ITestMethod testMethod)
{
if (!RuntimeInformation.IsOsPlatform(OSPlatform.Windows))
{
return new[] {
new TestResult()
{
Outcome = UnitTestOutcome.Inconclusive,
TestFailureException = new AssertInconclusiveException("Test only runs on Windows")
}};
}
return base.Execute(testMethod);
}
}
``` #Closed
| # - download: current | ||
| # patterns: | | ||
| # binaries-windows-$(Configuration)/AnyCPU/** | ||
| # binaries-linux-ubuntu-$(Configuration)/ClrInstrumentationEngine/** |
There was a problem hiding this comment.
removing; this was the new way to download pipeline artifacts but for some reason the files are inaccessible in subsequent tasks (file/directory not found errors). #Resolved
| #define MOD_LOAD(_N) (GetModuleHandle(_N)) | ||
| #define SYM_LOAD(_M, _S) (GetProcAddress(_M, _S)) | ||
|
|
||
| #define GET_LAST_ERROR() \ |
| publishTestResults: true | ||
| condition: succeededOrFailed() | ||
|
|
||
| #- script: $(Agent.TempDirectory)/dotnet $(Pipeline.Workspace)/binaries-windows-Debug/AnyCPU/net70/InstrEngineTests.dll |
| psi.EnvironmentVariables.Add( | ||
| HostConfig64PathEnvName, | ||
| Path.Combine(PathUtils.GetAssetsPath(), "LinuxNaglerInstrumentationMethod.xml")); | ||
| } |
There was a problem hiding this comment.
nit: I think this could technically be in the NETCOREAPP as well.
There was a problem hiding this comment.
true but it doesn't change the behavior so I'll leave it as-is.
Summary
These changes fix InstrEngineTests.dll run on Linux.
Change Log
Test Methodology
Local build & test