Skip to content

Commit 1d1c61f

Browse files
committed
update runtime tests to work with WASIp2
As of this writing, WASIp2 [does not support process exit statuses](WebAssembly/wasi-cli#11) beyond 0 (success) and 1 (failure). To work around this, I've modified the relevant tests to return 0 on success instead of 100. Signed-off-by: Joel Dice <[email protected]>
1 parent cc896fe commit 1d1c61f

39 files changed

+347
-44
lines changed

eng/pipelines/common/global-build-job.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ jobs:
225225
displayName: Install wasi-sdk
226226
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasmtime.cmd $(Build.SourcesDirectory)\wasm-tools
227227
displayName: Install wasmtime
228+
- script: npm install -g @bytecodealliance/jco
229+
displayName: Install jco
228230

229231
- ${{ if or(eq(parameters.platform, 'browser_wasm_win'), and(eq(parameters.platform, 'wasi_wasm_win'), not(eq(parameters.runtimeFlavor, 'coreclr')))) }}:
230232
# Update machine certs

src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-bindings.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ set -ex
1111
# [cargo](https://rustup.rs/)
1212
# [curl](https://curl.se/download.html)
1313

14-
# TODO: Upstream the changes in this `wit-bindgen` fork and use a crates.io
15-
# release instead:
14+
# TODO: Use a crates.io release instead of the Git repo once a release
15+
# containing this commit has been created:
1616
cargo install --locked --no-default-features --features csharp-naot \
17-
--git https://github.com/dicej/wit-bindgen --branch dotnet \
17+
--git https://github.com/bytecodealliance/wit-bindgen --rev 266d638f7a9c4535ba5fa1f1bb2e8cc6b5d58667 \
1818
wit-bindgen-cli
1919
curl -OL https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.0.tar.gz
2020
tar xzf v0.2.0.tar.gz

src/libraries/System.Private.CoreLib/src/System/WASIp2/generate-bindings.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ set -ex
1111
# [cargo](https://rustup.rs/)
1212
# [curl](https://curl.se/download.html)
1313

14-
# TODO: Upstream the changes in this `wit-bindgen` fork and use a crates.io
15-
# release instead:
14+
# TODO: Use a crates.io release instead of the Git repo once a release
15+
# containing this commit has been created:
1616
cargo install --locked --no-default-features --features csharp-naot \
17-
--git https://github.com/dicej/wit-bindgen --branch dotnet \
17+
--git https://github.com/bytecodealliance/wit-bindgen --rev 266d638f7a9c4535ba5fa1f1bb2e8cc6b5d58667 \
1818
wit-bindgen-cli
1919
curl -OL https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.0.tar.gz
2020
tar xzf v0.2.0.tar.gz

src/tests/Common/scripts/nativeaottest.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
exename=$(basename $2 .dll)
1414
wasm="$1/native/${exename}.wasm"
15+
mjs="$1/native/${exename}.mjs"
1516

16-
if [ -e "$wasm" ]; then
17-
shift 2
18-
echo wasmtime run -S http "$wasm" "$@"
19-
wasmtime run -S http "$wasm" "$@"
17+
if [ -e "$mjs" ]; then
18+
node "$mjs" "${@:3}"
19+
elif [ -e "$wasm" ]; then
20+
echo wasmtime run -S http "$wasm" "${@:3}"
21+
wasmtime run -S http "$wasm" "${@:3}"
2022
else
2123
chmod +x $1/native/$exename
2224
$_DebuggerFullPath $1/native/$exename "${@:3}"

src/tests/nativeaot/CustomMain/CustomMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ static void IncrementExitCode(int amount)
3535
static int Main(string[] args)
3636
{
3737
Console.WriteLine("hello from managed main");
38-
return s_exitCode;
38+
return s_exitCode - 100;
3939
}
4040
}

src/tests/nativeaot/CustomMain/CustomMain.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<!-- TODO-LLVM: Remove when https://github.com/WebAssembly/wasi-sdk/issues/367 is resolved -->
88
<EmccExtraArgs Condition="'$(TargetOS)' == 'wasi'">-Wl,--export-if-defined=__main_argc_argv</EmccExtraArgs>
9+
<CLRTestExitCode>0</CLRTestExitCode>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<!-- Look for MULTIMODULE_BUILD #define for the more specific incompatible parts -->
1212
<CLRTestTargetUnsupported Condition="'$(IlcMultiModule)' == 'true'">true</CLRTestTargetUnsupported>
13+
<CLRTestExitCode>0</CLRTestExitCode>
1314
</PropertyGroup>
1415

1516
<ItemGroup>

src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static int Main(string[] args)
165165
if (passed && CoreFXTestLibrary.Internal.Runner.NumPassedTests > 0)
166166
{
167167
CoreFXTestLibrary.Logger.LogInformation("All tests PASSED.");
168-
return 100;
168+
return 0;
169169
}
170170
else
171171
{

src/tests/nativeaot/SmokeTests/Exceptions/Exceptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class BringUpTest
1111
{
12-
const int Pass = 100;
12+
const int Pass = 0;
1313
const int Fail = -1;
1414

1515
volatile int myField;

src/tests/nativeaot/SmokeTests/Exceptions/Exceptions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ServerGarbageCollection>true</ServerGarbageCollection>
77
<!-- Test infra issue on apple devices: https://github.com/dotnet/runtime/issues/89917 -->
88
<CLRTestTargetUnsupported Condition="'$(TargetsAppleMobile)' == 'true'">true</CLRTestTargetUnsupported>
9+
<CLRTestExitCode>0</CLRTestExitCode>
910
</PropertyGroup>
1011
<ItemGroup>
1112
<Compile Include="Exceptions.cs" />

0 commit comments

Comments
 (0)