diff --git a/build/yaml/jobs/linux/binaries.yaml b/build/yaml/jobs/linux/binaries.yaml index 40a7291c..31c62777 100644 --- a/build/yaml/jobs/linux/binaries.yaml +++ b/build/yaml/jobs/linux/binaries.yaml @@ -20,7 +20,7 @@ jobs: pool: ${{ if eq(variables['System.TeamProject'], 'devdiv') }}: name: AzurePipelines-EO - image: 1ESPT-Ubuntu20.04 + image: 1ESPT-Ubuntu22.04 os: linux ${{ else }}: vmImage: ubuntu-latest diff --git a/build/yaml/jobs/linux/tests.yaml b/build/yaml/jobs/linux/tests.yaml index 9bb81feb..b95748a5 100644 --- a/build/yaml/jobs/linux/tests.yaml +++ b/build/yaml/jobs/linux/tests.yaml @@ -17,7 +17,7 @@ jobs: pool: ${{ if eq(variables['System.TeamProject'], 'devdiv') }}: name: AzurePipelines-EO - image: 1ESPT-Ubuntu20.04 + image: 1ESPT-Ubuntu22.04 os: linux ${{ else }}: vmImage: ubuntu-latest diff --git a/build/yaml/jobs/tests.yaml b/build/yaml/jobs/tests.yaml index 5a389de3..0ff8fd15 100644 --- a/build/yaml/jobs/tests.yaml +++ b/build/yaml/jobs/tests.yaml @@ -41,8 +41,8 @@ jobs: parameters: MatrixStrategy: NET_Next: - TargetFrameworkFolder: net70 - NetSdkVersion: 7.x + TargetFrameworkFolder: net11.0 + NetSdkVersion: 11.0.x NET_LTS: - TargetFrameworkFolder: net60 - NetSdkVersion: 6.x \ No newline at end of file + TargetFrameworkFolder: net10.0 + NetSdkVersion: 10.0.x \ No newline at end of file diff --git a/build/yaml/jobs/windows/tests.yaml b/build/yaml/jobs/windows/tests.yaml index 27dd6045..5ac6d8ea 100644 --- a/build/yaml/jobs/windows/tests.yaml +++ b/build/yaml/jobs/windows/tests.yaml @@ -38,7 +38,7 @@ jobs: ArtifactName: binaries-windows-$(Configuration) - ${{ if eq('Managed', parameters.TestType) }}: - # Install dotnet runtimes to allow .NET Core and .NET 5+ based unit tests to run. + # Install .NET SDKs for CoreCLR tests. - template: ../../steps/azuredevops/usedotnet.yaml@self # The UseDotNet task is not sufficient because it will only install the X64 runtimes @@ -56,16 +56,14 @@ jobs: # Install x64 runtimes $dotnetX64Dir = Join-Path -Path $dotnetDir -ChildPath 'x64' New-Item -Path $dotnetX64Dir -ItemType 'Directory' | Out-Null - & $scriptPath -Runtime 'dotnet' -Channel '3.1' -Architecture 'x64' -InstallDir $dotnetX64Dir - & $scriptPath -Runtime 'dotnet' -Channel '5.0' -Architecture 'x64' -InstallDir $dotnetX64Dir - & $scriptPath -Runtime 'dotnet' -Channel '6.0' -Architecture 'x64' -InstallDir $dotnetX64Dir + & $scriptPath -Runtime 'dotnet' -Channel '10.0' -Architecture 'x64' -InstallDir $dotnetX64Dir + & $scriptPath -Runtime 'dotnet' -Channel '11.0' -Quality 'preview' -Architecture 'x64' -InstallDir $dotnetX64Dir $dotnetX64Path = Join-Path -Path $dotnetX64Dir -ChildPath 'dotnet.exe' -Resolve # Install x86 runtimes $dotnetX86Dir = Join-Path -Path $dotnetDir -ChildPath 'x86' New-Item -Path $dotnetX86Dir -ItemType 'Directory' | Out-Null - & $scriptPath -Runtime 'dotnet' -Channel '3.1' -Architecture 'x86' -InstallDir $dotnetX86Dir - & $scriptPath -Runtime 'dotnet' -Channel '5.0' -Architecture 'x86' -InstallDir $dotnetX86Dir - & $scriptPath -Runtime 'dotnet' -Channel '6.0' -Architecture 'x86' -InstallDir $dotnetX86Dir + & $scriptPath -Runtime 'dotnet' -Channel '10.0' -Architecture 'x86' -InstallDir $dotnetX86Dir + & $scriptPath -Runtime 'dotnet' -Channel '11.0' -Quality 'preview' -Architecture 'x86' -InstallDir $dotnetX86Dir $dotnetX86Path = Join-Path -Path $dotnetX86Dir -ChildPath 'dotnet.exe' -Resolve # Set job variables Write-Host "##vso[task.setvariable variable=DOTNET_EXE_X64;]$dotnetX64Path" @@ -102,18 +100,13 @@ jobs: - template: ../../steps/windows/dotnettest.yaml@self parameters: - SubFolder: 'netcoreapp3.1\' - RunTitle: '$(Build.BuildNumber)_Windows_Core31_$(Configuration)' - - - template: ../../steps/windows/dotnettest.yaml@self - parameters: - SubFolder: 'net50\' - RunTitle: '$(Build.BuildNumber)_Windows_Net50_$(Configuration)' - + SubFolder: 'net10.0\' + RunTitle: '$(Build.BuildNumber)_Windows_Net100_$(Configuration)' + - template: ../../steps/windows/dotnettest.yaml@self parameters: - SubFolder: 'net60\' - RunTitle: '$(Build.BuildNumber)_Windows_Net60_$(Configuration)' + SubFolder: 'net11.0\' + RunTitle: '$(Build.BuildNumber)_Windows_Net110_$(Configuration)' - ${{ if eq('true', parameters.IsMicroBuildInternal) }}: - template: ../../steps/microbuild/cleanup.yaml@self diff --git a/build/yaml/steps/azuredevops/usedotnet.yaml b/build/yaml/steps/azuredevops/usedotnet.yaml index 5f2c1e17..9620c871 100644 --- a/build/yaml/steps/azuredevops/usedotnet.yaml +++ b/build/yaml/steps/azuredevops/usedotnet.yaml @@ -1,35 +1,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -# Step Template: Install v5 of dotnet.core +# Step Template: Install .NET SDKs for managed builds and tests steps: - task: UseDotNet@2 - displayName: 'Install .NET Core 3.1 SDK' + displayName: 'Install .NET 10.0 SDK' inputs: packageType: 'sdk' - version: '3.1.x' + version: '10.0.x' performMultiLevelLookup: true - task: UseDotNet@2 - displayName: 'Install .NET 5.0 SDK' + displayName: 'Install .NET 11.0 SDK' inputs: packageType: 'sdk' - version: '5.0.x' - performMultiLevelLookup: true - - - task: UseDotNet@2 - displayName: 'Install .NET 6.0 SDK' - inputs: - packageType: 'sdk' - version: '6.0.x' - includePreviewVersions: true - performMultiLevelLookup: true - - - task: UseDotNet@2 - displayName: 'Install .NET 7.0 SDK' - inputs: - packageType: 'sdk' - version: '7.0.x' + version: '11.0.x' includePreviewVersions: true performMultiLevelLookup: true diff --git a/build/yaml/steps/windows/enginerestore.yaml b/build/yaml/steps/windows/enginerestore.yaml index d4468a6b..c947bfdb 100644 --- a/build/yaml/steps/windows/enginerestore.yaml +++ b/build/yaml/steps/windows/enginerestore.yaml @@ -4,17 +4,17 @@ # Step Template: Restore InstrumentationEngine.sln NuGet Packages # 'nuget restore' vs 'dotnet restore' and restoring separate solution -# - The InstrumentationEngine.sln file now contains .NET 6 projects +# - The InstrumentationEngine.sln file contains modern .NET projects # that build in the 'Any CPU' platform. These projects are not # buildable by MSBuild in the Azure DevOps pipelines because they # are using a non-preview version of Visual Studio and MSBuild. # - There are several managed projects in the 'x64' and 'x86' platforms # of the sln file, which still require NuGet package restoration. However, -# 'nuget restore' cannot be used on the sln because of the .NET 6 projects. +# 'nuget restore' cannot be used on the sln because of the modern .NET projects. # # Solution: Use 'dotnet restore' for restoring NuGet packages in the 'Any CPU' # platform. For the managed projects in 'x64' and 'x86' platforms, add them -# to a new solution without the .NET 6 projects and use 'nuget restore' to +# to a new solution without the modern .NET projects and use 'nuget restore' to # restore the packages for those projects. # # Long term, the managed projects in the 'x64' and 'x86' platforms should be diff --git a/docs/test.md b/docs/test.md index 525d1eef..1677d7a6 100644 --- a/docs/test.md +++ b/docs/test.md @@ -8,6 +8,19 @@ The [WindowsLocalTest.ps1](../src/Scripts/WindowsLocalTest.ps1) script requires ## Running unit tests locally +CoreCLR tests and `TestAppRunner` target only .NET 10 and .NET 11. Desktop .NET Framework +coverage is retained, including the `net462` instrumentation tests. Install the .NET 11 SDK +to build all test targets, using a prerelease SDK while .NET 11 is in preview. +On Windows, install both the x64 and x86 runtimes for .NET 10 and .NET 11 because the +tests launch applications of both bitnesses. Test binaries are written to the `net10.0` +and `net11.0` output folders, respectively. +On Linux, use a supported distribution such as Ubuntu 22.04 or later. + +`InstrEngineTests` runs from portable build artifacts and does not generate a +`runtimeconfig.dev.json` with build-machine NuGet probing settings. Exception stack +baselines exclude the test runner and the .NET 11 `System.Environment.CallEntryPoint` +bootstrap frame; application frames and exception callback ordering remain checked. + ### Windows There are two ways to run the CLR Instrumentation Engine unit tests - Visual Studio Test Explorer and `build.ps1` script. @@ -37,20 +50,20 @@ Verbose|Sets msbuild verbosity to `normal`. By default, verbosity is set to `Err #### Prerequisites -The following technologies/tools are required in order to run Linux tests on Windows. These instructions were tested for Ubuntu 18.04 LTS and may require adjustments for other distros/versions. +The following technologies/tools are required in order to run Linux tests on Windows. -* WSL (Windows Subsystem for Linux) 2.0 with Ubuntu 18.04 LTS +* WSL (Windows Subsystem for Linux) 2.0 with Ubuntu 22.04 LTS or later, the .NET 11 SDK, and the .NET 10 and .NET 11 runtimes - WSL is available on Windows 10 Build 19041+ and Windows 11. - - Run this in a command prompt `wsl --install -d Ubuntu-18.04` or download Ubuntu 18.04 from the Microsoft Store. Restart as needed and setup a user/pass for your account. + - Run this in a command prompt `wsl --install -d Ubuntu-22.04` or download Ubuntu 22.04 from the Microsoft Store. Restart as needed and setup a user/pass for your account. * Docker Desktop for Linux (Ubuntu) - Follow the instructions from the official docs https://docs.docker.com/engine/install/ubuntu/ #### Steps -1. On Windows, build InstrumentationEngine for Debug AnyCPU (which builds managed projects and dlls) - - You can also run `dotnet build InstrumentationEngine.sln` in the interactive container session from step 2 instead. +1. On Windows, build InstrumentationEngine for Debug AnyCPU (which builds managed projects and dlls). 2. Run `src\scripts\DockerLocalBuild.ps1 -Wsl -BuildDockerImage -Interactive -RebuildImage`. This will build a docker container and drop you in an interactive session. By default builds for Ubuntu/Debian; set `-CLib musl` if you want to build for Alpine Linux instead. 3. Run `./src/build.sh` within the interactive session. This builds the native shared object files (.so). -4. Run `dotnet test bin/Debug/AnyCPU/net70/InstrEngineTests.dll` +4. Exit the container and, from the repository directory in WSL, use the .NET 11 SDK to run both `dotnet test bin/Debug/AnyCPU/net10.0/InstrEngineTests.dll` and `dotnet test bin/Debug/AnyCPU/net11.0/InstrEngineTests.dll`. + The native build containers retain their older distribution baseline and are not the CoreCLR test execution environment. Please contact clrieowners@microsoft.com for any details or questions. \ No newline at end of file diff --git a/src/Tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj b/src/Tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj index 7ecc56b1..aaac02ea 100644 --- a/src/Tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj +++ b/src/Tests/InstrEngineTests/InstrEngineTests/InstrEngineTests.csproj @@ -7,8 +7,10 @@ - net462;netcoreapp3.1;net50;net60;net70 + net462;net10.0;net11.0 false + + false InstrEngineTests diff --git a/src/Tests/InstrEngineTests/InstrEngineTests/RefStructsTests.cs b/src/Tests/InstrEngineTests/InstrEngineTests/RefStructsTests.cs index 0172f2f1..bef09a4f 100644 --- a/src/Tests/InstrEngineTests/InstrEngineTests/RefStructsTests.cs +++ b/src/Tests/InstrEngineTests/InstrEngineTests/RefStructsTests.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; using Microsoft.VisualStudio.TestTools.UnitTesting; -// This file is only compiled for net70 +// This file is only compiled for .NET 7 and later. namespace InstrEngineTests { [TestClass] diff --git a/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/NaglerInstrumentationMethod.cpp b/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/NaglerInstrumentationMethod.cpp index 724e5b12..389e7df3 100644 --- a/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/NaglerInstrumentationMethod.cpp +++ b/src/Tests/InstrEngineTests/NaglerInstrumentationMethod/NaglerInstrumentationMethod.cpp @@ -1633,13 +1633,21 @@ HRESULT CInstrumentationMethod::HandleStackSnapshotCallbackExceptionThrown( CInstrStr clrieStrModuleName; IfFailRet(pModuleInfo->GetModuleName(&clrieStrModuleName.m_bstr)); + bool isRuntimeEntryPoint = false; + if (wcscmp(clrieStrModuleName, _T("System.Private.CoreLib.dll")) == 0 && + wcscmp(clrieStrMethodName, _T("CallEntryPoint")) == 0) + { + CInstrStr clrieStrFullName; + IfFailRet(pMethodInfo->GetFullName(&clrieStrFullName.m_bstr)); + isRuntimeEntryPoint = wcscmp(clrieStrFullName, _T("System.Environment.CallEntryPoint")) == 0; + } + CComPtr spLogger; m_pProfilerManager->GetLoggingInstance(&spLogger); tstring strMessage; - // Add [TestIgnore] for the TestAppRunner. This module is used for bootstrapping - // .NET Core test assemblies and is not intended to be used in test baselines. - if (wcscmp(clrieStrModuleName, _T("TestAppRunner.dll")) == 0) + // Ignore bootstrap frames, including the managed runtime entry point added in .NET 11. + if (wcscmp(clrieStrModuleName, _T("TestAppRunner.dll")) == 0 || isRuntimeEntryPoint) { strMessage.append(_T("[TestIgnore]")); } diff --git a/src/Tests/InstrEngineTests/TestAppRunner/TestAppRunner.csproj b/src/Tests/InstrEngineTests/TestAppRunner/TestAppRunner.csproj index b1e8822c..bdabed9e 100644 --- a/src/Tests/InstrEngineTests/TestAppRunner/TestAppRunner.csproj +++ b/src/Tests/InstrEngineTests/TestAppRunner/TestAppRunner.csproj @@ -8,7 +8,7 @@ Exe - netcoreapp3.1;net50;net60;net70 + net10.0;net11.0 diff --git a/src/Tests/RemoteUnitTestExecutor/RemoteUnitTestExecutor.csproj b/src/Tests/RemoteUnitTestExecutor/RemoteUnitTestExecutor.csproj index 042a0ca3..01a168b3 100644 --- a/src/Tests/RemoteUnitTestExecutor/RemoteUnitTestExecutor.csproj +++ b/src/Tests/RemoteUnitTestExecutor/RemoteUnitTestExecutor.csproj @@ -9,7 +9,7 @@ net462 - win7-x86 + win-x86 Exe RemoteUnitTestExecutor 9.0