Before running tests, build Mono using the desired configuration.
To build the runtime tests for Mono JIT or interpreter:
- Build CoreCLR - the
clr.native
subset is enough but you can build the whole thing, optionally. From the$(REPO_ROOT)
:
./build.sh clr.native -c <release|debug>
- Build the tests (in
$(REPO_ROOT)/src/tests
)
cd src/tests
./build.sh excludemonofailures <release|debug>
To build an individual test, test directory, or a whole subdirectory tree, use the -test:
, -dir:
or -tree:
options (without the src/tests prefix)
For example: ./build.sh excludemonofailures release -test:JIT/opt/InstructionCombining/DivToMul.csproj
Run individual test:
cd src/mono
make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Release/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh"
Run all tests:
cd src/mono
make run-tests-coreclr-all
To debug a single test with lldb
:
- Run the test at least once normally (or manually run the
mono.proj
PatchCoreClrCoreRoot
target) - Run the shell script for the test case manually:
bash ./artifacts/tests/coreclr/OSX.x64.Release/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh -coreroot=`pwd`/artifacts/tests/coreclr/OSX.x64.Release/Tests/Core_Root -debug=/usr/bin/lldb
- In LLDB add the debug symbols for mono:
add-dsym <CORE_ROOT>/libcoreclr.dylib.dwarf
- Run/debug the test
Build the runtime tests for WebAssembly
$(REPO_ROOT)/src/tests/build.sh -excludemonofailures os Browser wasm <Release/Debug>
The last few lines of the build log should contain something like this:
--------------------------------------------------
Example run.sh command
src/tests/run.sh --coreOverlayDir=<repo_root>artifacts/tests/coreclr/Browser.wasm.Release/Tests/Core_Root --testNativeBinDir=<repo_root>/artifacts/obj/coreclr/Browser.wasm.Release/tests --testRootDir=<repo_root>/artifacts/tests/coreclr/Browser.wasm.Release --copyNativeTestBin Release
--------------------------------------------------
To run all tests, execute that command, adding wasm
to the end.
Build the runtime tests for Android x64/ARM64
$(REPO_ROOT)/src/tests/build.sh -excludemonofailures os Android <x64/arm64> <Release/Debug>
Run one test wrapper from repo root
export CORE_ROOT=<path_to_folder_Core_Root>
./dotnet.sh <path_to_xunit.console.dll> <path_to_*.XUnitWrapper.dll>
For more details about internals of the runtime tests, please refer to the CoreCLR testing documents
Build and run library tests against Mono JIT or interpreter
$(REPO_ROOT)/dotnet.sh build /t:Test /p:RuntimeFlavor=mono /p:Configuration=<Release/Debug> $(REPO_ROOT)/src/libraries/<library>/tests
Alternatively, you could execute the following command from $(REPO_ROOT)/src/mono
make run-tests-corefx-<library>
For example, the following command is for running System.Runtime tests:
make run-tests-corefx-System.Runtime
Build and run library tests against WebAssembly, Android or iOS. See instructions located in Library testing document folder
There are the functional tests which aim to test some specific features/configurations/modes on Android, iOS-like platforms (iOS/tvOS + simulators, MacCatalyst), and WebAssembly.
A functional test can be run the same way as any library test suite, e.g.:
./dotnet.sh build /t:Test -c Release /p:TargetOS=Android /p:TargetArchitecture=x64 src/tests/FunctionalTests/Android/Device_Emulator/PInvoke/Android.Device_Emulator.PInvoke.Test.csproj
Currently the functional tests are expected to return 42
as a success code so please be careful when adding a new one.
For more details, see instructions located in Library testing document folder.
There are a few convenient samples located in $(REPO_ROOT)/src/mono/sample
, which could help you test your program easily with different flavors of Mono or do a sanity check on the build. The samples are set up to work with a specific configuration; please refer to the relevant Makefile for specifics. If you would like to work with a different configuration, you can edit the Makefile.
To run the desktop Mono sample, cd to HelloWorld
and execute:
make run
Note that the default configuration of this sample is LLVM JIT.
To run the WebAssembly sample, cd to wasm
. There are two sub-folders browser
and console
. One is set up to run the progam in browser, the other is set up to run the program in console. Enter the desirable sub-folder and execute
make build && make run
To run the Android sample, cd to Android
and execute
make run
To run the iOS sample, cd to iOS
and execute
make run