-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[docs] How to run tests on iOS and Android #36297
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3955942
Draft for iOS and Android docs
EgorBo c771025
Mention AppleAppBuilder
EgorBo 07f572e
Update docs/workflow/testing/libraries/testing-apple.md
EgorBo b1e1d44
Update docs/workflow/testing/libraries/testing-apple.md
EgorBo ade5598
Update docs/workflow/testing/libraries/testing-apple.md
EgorBo 2c65efd
Update docs/workflow/testing/libraries/testing-apple.md
EgorBo a9b5da9
Update docs/workflow/testing/libraries/testing-android.md
EgorBo bd913f3
Update docs/workflow/testing/libraries/testing-android.md
EgorBo 33cbeea
Update docs/workflow/testing/libraries/testing-android.md
EgorBo d65f54f
Conver xharness, address feedback
EgorBo 2042a8e
Merge branch 'master' of github.com:dotnet/runtime into ios-android-docs
EgorBo 86a8678
Add script to install NDK, SDK and OpenSSL for Linux
EgorBo 5f853f4
Fix linux script
EgorBo aa42400
Address feedback
EgorBo d74691e
Add some limitations
EgorBo 3c26fc7
Make script portable
EgorBo ad193d7
remove todo
EgorBo 1ccc89b
Update docs/workflow/testing/libraries/testing-apple.md
EgorBo 38021c1
Update testing-apple.md
EgorBo 38ca98c
minor cleanup
EgorBo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Testing Libraries on Android | ||
|
|
||
| To build the tests and run them on Android (devices or emulators) you need the following prerequisites. | ||
|
|
||
| - [Android NDK](https://developer.android.com/ndk/downloads) | ||
| - [Android SDK](https://developer.android.com/studio) | ||
| - OpenJDK | ||
|
|
||
| (TODO: provide command-line steps to download them with dependencies) | ||
|
|
||
| Once SDKs are downloaded, set `ANDROID_NDK_ROOT`(CLARIFY: looks like `ANDROID_NDK_HOME` should also be set) and `ANDROID_SDK_ROOT`. | ||
| Example: | ||
| ``` | ||
| export ANDROID_SDK_ROOT=/Users/egorbo/Library/Android/sdk | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export ANDROID_NDK_ROOT=/Users/egorbo/android-ndk-r21b | ||
| export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT | ||
| ``` | ||
|
|
||
| Next, we need OpenSSL binaries and headers, we haven't properly integrated this dependency yet (it's an ongoing discussion) but there is a workaround: | ||
|
|
||
| - Download and unzip https://maven.google.com/com/android/ndk/thirdparty/openssl/1.1.1g-alpha-1/openssl-1.1.1g-alpha-1.aar | ||
| - Set these env variables: | ||
| ``` | ||
| GOOGLE_OPENSSL=/Users/egorbo/prj/openssl-1.1.1g-alpha-1.aar/prefab/modules | ||
| export AndroidOpenSslHeaders="$GOOGLE_OPENSSL/ssl/include" | ||
| export AndroidOpenSslCryptoLib="$GOOGLE_OPENSSL/crypto/libs/android.x86_64/libcrypto.so" | ||
| export AndroidOpenSslLib="$GOOGLE_OPENSSL/ssl/libs/android.x86_64/libssl.so" | ||
| ``` | ||
| **IMPORTANT:** make sure correct ABIs are used in the path, e.g. `-arch x64` -> `android.x86_64` (TODO: auto-detect) | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Now we're ready to build everything for Android: | ||
| ``` | ||
| ./build.sh -os Android -arch x64 -subset Mono+Libs | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| and even run tests one by one for each test suite: | ||
| ``` | ||
| ./build.sh -os Android -arch x64 -subset Libs.Tests -test | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| Make sure an emulator is booted or a device is plugged and unlocked. | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| **NOTE**: Xharness doesn't run any UI on Android and runs tests using headless testing API so the device/emulator won't show anything (but still must stay active). | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Running individual test suites | ||
| - The following shows how to run tests for a specific library | ||
| ``` | ||
| cd src/libraries/System.Numerics.Vectors/tests | ||
| ../../../.././dotnet.sh build /t:Test /p:TargetOS=Android /p:TargetArchitecture=x64 | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ### Obtaining the logs | ||
| XHarness doesn't talk much and only saves tests result at the end to a file but you can also subscribe to live logs via the following command: | ||
| ``` | ||
| adb logcat -S DOTNET | ||
| ``` | ||
| Or simply open `logcat` window in Android Studio or Visual Stuido. | ||
|
|
||
| ### Known Issues | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - We don't support `-os Android` on Windows yet (`WSL` can be used instead) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Testing Libraries on iOS and tvOS | ||
|
|
||
| In order to build librarires and tests for iOS or tvOS you only need some fresh version of XCode installed (e.g. 11.3 or higher). | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Build Librarires for iOS: | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| ./build.sh -os iOS -arch x64 -subset Mono+Libs | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| Run tests one by one for each test suite on a simulator: | ||
| ``` | ||
| ./build.sh -os iOS -arch x64 -subset Libs.Tests -test | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| Unlike XHarness-Android, XHarness for iOS is able to boot simulators by its own. | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Running individual test suites | ||
| - The following shows how to run tests for a specific library on a simulator | ||
| ``` | ||
| cd src/libraries/System.Numerics.Vectors/tests | ||
| ../../../.././dotnet.sh build /t:Test /p:TargetOS=iOS /p:TargetArchitecture=x64 | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| for devices you need to specify `DevTeamProvisioning`: | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| cd src/libraries/System.Numerics.Vectors/tests | ||
| ../../../.././dotnet.sh build /t:Test /p:TargetOS=iOS /p:TargetArchitecture=arm64 /p:DevTeamProvisioning=... | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
| AppleAppBuilder generates temp Xcode projects you can manually open and resolve provisioning there using native UI and deploy to your devices and start debugging. | ||
|
|
||
| ### Known Issues | ||
| - Most of the test suites crash on devices due to [#35674)(https://github.com/dotnet/runtime/issues/35674) | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.