Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] wasi: Enable library tests on CI #81052

Merged
merged 40 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a564ab2
Add tasks from https://github.com/SteveSandersonMS/dotnet-wasi-sdk
radical Jan 31, 2023
5db6d5c
build changes
radical Jan 31, 2023
023226a
add test build changes
radical Jan 31, 2023
ce9dff4
test fixes
radical Jan 31, 2023
8e59b0d
add more wasi build files
radical Jan 31, 2023
03b6c28
fix wasi sample
radical Jan 31, 2023
5d977c2
add missing files
radical Jan 31, 2023
d918291
disable non-wasi/wasm builds
radical Jan 31, 2023
7d659e3
address feedback from @pavelsavara
radical Jan 31, 2023
d7f70d2
Merge remote-tracking branch 'origin/main' into wasi_tests
radical Jan 31, 2023
396e4df
cleanup
radical Jan 31, 2023
fd211a8
restore ci builds
radical Jan 31, 2023
7ad2c72
fix the optional build
radical Jan 31, 2023
4564943
Address review feedback from @pavelsavara
radical Jan 31, 2023
44ca339
Fix analyzer errors
radical Jan 31, 2023
c93e98a
Address review feedback from @pavelsavara
radical Jan 31, 2023
00121bc
gen-buildsys.cmd: fix wasi sdk path on windows
radical Feb 1, 2023
3a3f499
Always set arch=wasm for OS=browser, and OS=wasi
radical Feb 1, 2023
2cba616
[wasi] Fix wasi/windows build
radical Feb 1, 2023
855af93
cleanup
radical Feb 1, 2023
025d0a4
Add wasi windows job
radical Feb 1, 2023
40c38b7
Merge remote-tracking branch 'origin/main' into wasi_tests
radical Feb 1, 2023
3f53baa
Fix building sample
radical Feb 1, 2023
0c21d23
Fixes for running wasi sample, and library tests - System.Buffers.Tes…
radical Feb 1, 2023
89ddbb5
fix wasm tests
radical Feb 1, 2023
b8c9676
fix wasm tests
radical Feb 1, 2023
6a345ea
Merge remote-tracking branch 'origin/main' into wasi_tests
radical Feb 1, 2023
110c126
fix sample
pavelsavara Feb 1, 2023
851145f
runner script for windows
pavelsavara Feb 1, 2023
6b12f34
forgot to add WasiRunnerTemplate.cmd
radical Feb 1, 2023
9952901
fix sample again
pavelsavara Feb 1, 2023
0ea5bab
[wasm] fix wasi tests on windows/CI
radical Feb 1, 2023
0fd51b8
[wasm] Add wasi tests for CI/win
radical Feb 1, 2023
efea8b9
Merge remote-tracking branch 'origin/main' into wasi_tests
radical Feb 2, 2023
d97cb02
fix stack range again
pavelsavara Feb 3, 2023
a2239d4
* stack first
pavelsavara Feb 3, 2023
bf21da7
- back to assembly in .S file. extern doesn't work is zero
pavelsavara Feb 3, 2023
2c49658
[wasm] wasi: Fix assert, and compute stack size at run time
radical Feb 4, 2023
6fbd475
fix typos in makefile
radical Feb 4, 2023
3746b09
Run System.Collections.Tests also, which would test the oom case
radical Feb 4, 2023
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
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
<PropertyGroup Label="CalculateArch">
<_hostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</_hostArch>
<BuildArchitecture Condition="'$(BuildArchitecture)' == ''">$(_hostArch)</BuildArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and ('$(TargetOS)' == 'browser' or '$(RuntimeIdentifier)' == 'browser-wasm')">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and ('$(TargetOS)' == 'wasi' or '$(RuntimeIdentifier)' == 'wasi-wasm')">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm'">arm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'armv6'">armv6</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'armel'">armel</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'arm64'">arm64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'loongarch64'">loongarch64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 's390x'">s390x</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(_hostArch)' == 'ppc64le'">ppc64le</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and ('$(TargetOS)' == 'browser' or '$(RuntimeIdentifier)' == 'browser-wasm')">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and ('$(TargetOS)' == 'wasi' or '$(RuntimeIdentifier)' == 'wasi-wasm')">wasm</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(TargetsMobile)' == 'true'">x64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
<Platform Condition="'$(Platform)' == '' and '$(InferPlatformFromTargetArchitecture)' == 'true'">$(TargetArchitecture)</Platform>
Expand Down
12 changes: 12 additions & 0 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@
IsNative="true" />
</ItemGroup>

<ItemGroup Label="Wasi" Condition="'$(TargetOS)' == 'wasi'">
<LibrariesRuntimeFiles Include="
$(LibrariesNativeArtifactsPath)src\*.c"
NativeSubDirectory="src"
IsNative="true" />

<LibrariesRuntimeFiles Include="
$(LibrariesNativeArtifactsPath)include\wasm\*.h;"
NativeSubDirectory="include\wasm"
IsNative="true" />
</ItemGroup>

<Error Condition="'@(LibrariesRuntimeFiles)' == ''" Text="The 'libs' subset must be built before building this project." />
</Target>

Expand Down
2 changes: 1 addition & 1 deletion eng/native/gen-buildsys.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if /i "%__Arch%" == "wasm" (
exit /B 1
)

set "WASI_SDK_PATH=%__repoRoot%src\mono\wasi\wasi-sdk"
set "WASI_SDK_PATH=%__repoRoot%\src\mono\wasi\wasi-sdk"
)
:: replace backslash with forward slash and append last slash
set "WASI_SDK_PATH=!WASI_SDK_PATH:\=/!"
Expand Down
3 changes: 1 addition & 2 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,13 @@ jobs:
df -h
displayName: Disk Usage before Build

- ${{ if eq(parameters.platform, 'browser_wasm_win') }}:
- ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}:
# Update machine certs
- task: PowerShell@2
displayName: Update machine certs
inputs:
filePath: $(Build.SourcesDirectory)/eng/pipelines/mono/update-machine-certs.ps1


# Build
- ${{ if eq(parameters.isSourceBuild, false) }}:
- ${{ if eq(parameters.isManualCodeQLBuild, true) }}:
Expand Down
20 changes: 20 additions & 0 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,26 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}

# WASI WebAssembly windows

- ${{ if containsValue(parameters.platforms, 'wasi_wasm_win') }}:
- template: xplat-setup.yml
parameters:
jobTemplate: ${{ parameters.jobTemplate }}
helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
variables: ${{ parameters.variables }}
osGroup: wasi
archType: wasm
targetRid: wasi-wasm
platform: wasi_wasm_win
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
jobParameters:
hostedOs: windows
runtimeFlavor: ${{ parameters.runtimeFlavor }}
stagedBuild: ${{ parameters.stagedBuild }}
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}

# Browser WebAssembly

- ${{ if containsValue(parameters.platforms, 'browser_wasm') }}:
Expand Down
1 change: 0 additions & 1 deletion eng/pipelines/common/templates/wasm-library-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
alwaysRun: false
buildAndRunWasi: false
extraBuildArgs: ''
extraHelixArgs: ''
isExtraPlatformsBuild: false
Expand Down
11 changes: 11 additions & 0 deletions eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parameters:
isRollingBuild: false
excludeLibTests: false
excludeNonLibTests: false
excludeOptional: true
debuggerTestsOnly: false

jobs:
Expand Down Expand Up @@ -230,3 +231,13 @@ jobs:
#parameters:
#runProfile: 'v8'
#onlySanityCheck: true

- ${{ if and(ne(parameters.isRollingBuild, true), ne(parameters.excludeOptional, true)) }}:
- template: /eng/pipelines/common/templates/wasm-library-tests.yml
parameters:
platforms:
- wasi_wasm
extraBuildArgs: /p:EnableAggressiveTrimming=true
alwaysRun: ${{ parameters.isWasmOnlyBuild }}
scenarios:
- normal
2 changes: 1 addition & 1 deletion eng/pipelines/libraries/helix-queues-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ jobs:
- (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly

# Browser WebAssembly windows
- ${{ if eq(parameters.platform, 'browser_wasm_win') }}:
- ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}:
- (Windows.Amd64.Server2022.Open)windows.amd64.server2022.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly

${{ insert }}: ${{ parameters.jobParameters }}
29 changes: 29 additions & 0 deletions eng/pipelines/runtime-wasm-optional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This is a wrapper yml for `extra-platforms/runtime-extra-platforms-wasm.yml`, which
# has all the wasm jobs. This file is essentially so we can have point
# the pipeline in azdo UI to this, and thus avoid any scheduled triggers

trigger: none

variables:
- template: /eng/pipelines/common/variables.yml

extends:
template: /eng/pipelines/common/templates/pipeline-with-resources.yml
parameters:
stages:
- stage: Build
jobs:

#
# Evaluate paths
#
- template: /eng/pipelines/common/evaluate-default-paths.yml

- template: /eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
parameters:
isExtraPlatformsBuild: ${{ variables.isExtraPlatformsBuild }}
isWasmOnlyBuild: ${{ variables.isWasmOnlyBuild }}
isRollingBuild: ${{ variables.isRollingBuild }}
excludeLibTests: true
excludeNonLibTests: true
excludeOptional: false
12 changes: 9 additions & 3 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ extends:
parameters:
platforms:
- browser_wasm
buildAndRunWasi: true
alwaysRun: ${{ variables.isRollingBuild }}
scenarios:
- normal
Expand Down Expand Up @@ -456,12 +455,19 @@ extends:
extraBuildArgs: /p:MonoWasmBuildVariant=perftrace
alwaysRun: ${{ variables.isRollingBuild }}

# BUILD ONLY - WASI/Wasm
- template: /eng/pipelines/common/templates/wasi-build-only.yml
# WASI/WASM

- template: /eng/pipelines/common/templates/wasm-library-tests.yml
parameters:
platforms:
- wasi_wasm
- wasi_wasm_win
nameSuffix: '_Smoke'
extraBuildArgs: /p:EnableAggressiveTrimming=true /p:RunWasmSamples=true
shouldRunSmokeOnly: true
alwaysRun: ${{ variables.isRollingBuild }}
scenarios:
- normal

#
# iOS/tvOS devices - Full AOT + AggressiveTrimming to reduce size
Expand Down
69 changes: 69 additions & 0 deletions eng/testing/WasiRunnerTemplate.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@echo off
setlocal enabledelayedexpansion

:: SetCommands defined in eng\testing\tests.wasi.targets
[[SetCommands]]
[[SetCommandsEcho]]

set EXECUTION_DIR=%~dp0
if [%3] NEQ [] (
set SCENARIO=%3
)

if [%HELIX_WORKITEM_UPLOAD_ROOT%] == [] (
set "XHARNESS_OUT=%EXECUTION_DIR%xharness-output"
) else (
set "XHARNESS_OUT=%HELIX_WORKITEM_UPLOAD_ROOT%\xharness-output"
)

if [%XHARNESS_CLI_PATH%] NEQ [] (
:: When running in CI, we only have the .NET runtime available
:: We need to call the XHarness CLI DLL directly via dotnet exec
set HARNESS_RUNNER=dotnet.exe exec "%XHARNESS_CLI_PATH%"
) else (
set HARNESS_RUNNER=dotnet.exe xharness
)

if [%XHARNESS_COMMAND%] == [] (
set XHARNESS_COMMAND=test
)

if [%XHARNESS_ARGS%] == [] (
set "XHARNESS_ARGS=%ENGINE_ARGS%"
)

if [%PREPEND_PATH%] NEQ [] (
set "PATH=%PREPEND_PATH%:%PATH%"
)

if [%XUNIT_RANDOM_ORDER_SEED%] NEQ [] (
set "WasmXHarnessMonoArgs=%WasmXHarnessMonoArgs% --setenv=XUNIT_RANDOM_ORDER_SEED=%XUNIT_RANDOM_ORDER_SEED%"
)

echo EXECUTION_DIR=%EXECUTION_DIR%
echo SCENARIO=%SCENARIO%
echo XHARNESS_OUT=%XHARNESS_OUT%
echo XHARNESS_CLI_PATH=%XHARNESS_CLI_PATH%
echo HARNESS_RUNNER=%HARNESS_RUNNER%
echo XHARNESS_COMMAND=%XHARNESS_COMMAND%
echo XHARNESS_ARGS=%XHARNESS_ARGS%

:: ========================= BEGIN Test Execution =============================
echo ----- start %DATE% %TIME% =============== To repro directly: =====================================================
echo pushd %EXECUTION_DIR%
:: RunCommands defined in eng\testing\tests.wasi.targets
[[RunCommandsEcho]]
echo popd
echo ===========================================================================================================
pushd %EXECUTION_DIR%
@echo on
:: RunCommands defined in eng\testing\tests.wasi.targets
[[RunCommands]]
set EXIT_CODE=%ERRORLEVEL%
@echo off
popd
echo ----- end %DATE% %TIME% ----- exit code %EXIT_CODE% ----------------------------------------------------------

echo XHarness artifacts: %XHARNESS_OUT%

exit /b %EXIT_CODE%
68 changes: 68 additions & 0 deletions eng/testing/WasiRunnerTemplate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved

# SetCommands defined in eng\testing\tests.wasi.targets
[[SetCommands]]
[[SetCommandsEcho]]

EXECUTION_DIR=$(dirname $0)
if [[ -n "$3" ]]; then
SCENARIO=$3
fi

if [[ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then
XHARNESS_OUT="$EXECUTION_DIR/xharness-output"
else
XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output"
fi

if [[ -n "$XHARNESS_CLI_PATH" ]]; then
# When running in CI, we only have the .NET runtime available
# We need to call the XHarness CLI DLL directly via dotnet exec
HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH"
else
HARNESS_RUNNER="dotnet xharness"
fi

if [[ -z "$XHARNESS_COMMAND" ]]; then
XHARNESS_COMMAND="test"
fi

if [[ -z "$XHARNESS_ARGS" ]]; then
XHARNESS_ARGS="$ENGINE_ARGS"
fi

if [[ -n "$PREPEND_PATH" ]]; then
export PATH=$PREPEND_PATH:$PATH
fi

if [[ -n "$XUNIT_RANDOM_ORDER_SEED" ]]; then
WasmXHarnessMonoArgs="${WasmXHarnessMonoArgs} --setenv=XUNIT_RANDOM_ORDER_SEED=${XUNIT_RANDOM_ORDER_SEED}"
fi

echo EXECUTION_DIR=$EXECUTION_DIR
echo SCENARIO=$SCENARIO
echo XHARNESS_OUT=$XHARNESS_OUT
echo XHARNESS_CLI_PATH=$XHARNESS_CLI_PATH
echo HARNESS_RUNNER=$HARNESS_RUNNER
echo XHARNESS_COMMAND=$XHARNESS_COMMAND
echo XHARNESS_ARGS=$XHARNESS_ARGS

pushd $EXECUTION_DIR

# ========================= BEGIN Test Execution =============================
echo ----- start $(date) =============== To repro directly: =====================================================
echo pushd $EXECUTION_DIR
# RunCommands defined in eng\testing\tests.wasi.targets
[[RunCommandsEcho]]
echo popd
echo ===========================================================================================================
pushd $EXECUTION_DIR
# RunCommands defined in eng\testing\tests.wasi.targets
[[RunCommands]]
_exitCode=$?
popd
echo ----- end $(date) ----- exit code $_exitCode ----------------------------------------------------------

echo "XHarness artifacts: $XHARNESS_OUT"

exit $_exitCode
Loading