Skip to content
Merged
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 build/yaml/jobs/linux/binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build/yaml/jobs/linux/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions build/yaml/jobs/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
TargetFrameworkFolder: net10.0
NetSdkVersion: 10.0.x
27 changes: 10 additions & 17 deletions build/yaml/jobs/windows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
25 changes: 5 additions & 20 deletions build/yaml/steps/azuredevops/usedotnet.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions build/yaml/steps/windows/enginerestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 19 additions & 6 deletions docs/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker'))\build\Managed.props" />
<PropertyGroup>
<TargetFrameworks>net462;netcoreapp3.1;net50;net60;net70</TargetFrameworks>
<TargetFrameworks>net462;net10.0;net11.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<!-- Tests run from copied artifacts, not the build machine's NuGet cache. -->
<GenerateRuntimeConfigDevFile>false</GenerateRuntimeConfigDevFile>
<RootNamespace>InstrEngineTests</RootNamespace>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IProfilerManagerLogging> 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]"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker'))\build\Managed.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net50;net60;net70</TargetFrameworks>
<TargetFrameworks>net10.0;net11.0</TargetFrameworks>
</PropertyGroup>
<Import Project="$(EnlistmentRoot)\build\Managed.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<RuntimeIdentifiers>win7-x86</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x86</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<RootNamespace>RemoteUnitTestExecutor</RootNamespace>
<LangVersion>9.0</LangVersion>
Expand Down
Loading