Skip to content

Commit

Permalink
allow WASI runtime tests to be built and run on non-Windows systems
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Dice <[email protected]>
  • Loading branch information
dicej committed Jun 20, 2024
1 parent a36c613 commit cc896fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/tests/Common/CLRTest.Execute.Bash.targets
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fi
<WatcherRunFile>"$CORE_ROOT/watchdog" $_WatcherTimeoutMins</WatcherRunFile>

<!-- Note that this overwrites CLRTestBashPreCommands rather than adding to it. -->
<CLRTestBashPreCommands Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetArchitecture)' == 'wasm'"><![CDATA[
<CLRTestBashPreCommands Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetArchitecture)' == 'wasm' And '$(TargetOS)' == 'browser'"><![CDATA[
# Build wasm app containing the test dll
__Command=""
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
Expand Down
12 changes: 10 additions & 2 deletions src/tests/Common/scripts/nativeaottest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@
# 3. - n. Additional arguments that were passed to the test .sh

exename=$(basename $2 .dll)
chmod +x $1/native/$exename
$_DebuggerFullPath $1/native/$exename "${@:3}"
wasm="$1/native/${exename}.wasm"

if [ -e "$wasm" ]; then
shift 2
echo wasmtime run -S http "$wasm" "$@"
wasmtime run -S http "$wasm" "$@"
else
chmod +x $1/native/$exename
$_DebuggerFullPath $1/native/$exename "${@:3}"
fi
3 changes: 1 addition & 2 deletions src/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@
<!-- Set Test Wrapper running host OS -->
<PropertyGroup>
<TestWrapperTargetsWindows>false</TestWrapperTargetsWindows>
<!-- TODO-LLVM: we only support building on windows for LLVM, so if the TargetArchitecture == 'wasm', assume windows. Change when we support Linux/MacOS -->
<TestWrapperTargetsWindows Condition=" ('$(TargetsWindows)' != '' And '$(TargetsWindows)' ) OR ('$(TargetOS)' == 'android' And '$(TargetArchitecture)' == 'arm64' ) OR ('$(TargetArchitecture)' == 'wasm')">true</TestWrapperTargetsWindows>
<TestWrapperTargetsWindows Condition=" ('$(TargetsWindows)' != '' And '$(TargetsWindows)' ) OR ('$(TargetOS)' == 'android' And '$(TargetArchitecture)' == 'arm64' )">true</TestWrapperTargetsWindows>
<TestScriptExtension Condition="'$(TestWrapperTargetsWindows)' != 'true' ">sh</TestScriptExtension>
<TestScriptExtension Condition="'$(TestWrapperTargetsWindows)' == 'true' ">cmd</TestScriptExtension>
</PropertyGroup>
Expand Down
12 changes: 10 additions & 2 deletions src/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function print_usage {
echo ' <arch> : One of x64, x86, arm, arm64, loongarch64, riscv64, wasm. Defaults to current architecture.'
echo ' <build configuration> : One of debug, checked, release. Defaults to debug.'
echo ' android : Set build OS to Android.'
echo ' wasi : Set build OS to WASI.'
echo ' --test-env=<path> : Script to set environment variables for tests'
echo ' --testRootDir=<path> : Root directory of the test build (e.g. runtime/artifacts/tests/windows.x64.Debug).'
echo ' --coreRootDir=<path> : Directory to the CORE_ROOT location.'
Expand Down Expand Up @@ -105,6 +106,9 @@ do
android)
buildOS="android"
;;
wasi)
buildOS="wasi"
;;
debug|Debug)
buildConfiguration="Debug"
;;
Expand Down Expand Up @@ -204,8 +208,12 @@ runtestPyArguments=("-arch" "${buildArch}" "-build_type" "${buildConfiguration}"
echo "Build Architecture : ${buildArch}"
echo "Build Configuration : ${buildConfiguration}"

if [ "$buildArch" = "wasm" ]; then
runtestPyArguments+=("-os" "browser")
if [ "$buildArch" = "wasm" -a -z "$buildOS" ]; then
buildOS="browser"
fi

if [ -n "$buildOS" ]; then
runtestPyArguments+=("-os" "$buildOS")
fi

if [ "$buildOS" = "android" ]; then
Expand Down

0 comments on commit cc896fe

Please sign in to comment.