1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-10 18:11:04 +09:00
Satori/eng/testing/BionicRunOnDevice.sh
Jo Shields b5f9c224e7
Linux-bionic (Android libc w/o Android interop) initial implementation (#66147)
Implement support for "Linux Bionic", a RID which builds a Linux runtime against an Android libc but without Android OS functions like JNI, Dalvik, Instrumentation, etc. This configuration has been requested by a team working on an IoT scenario.

* The new RID is linux-bionic-arm64/linux-bionic-x64.
* The build reuses the existing Android build dockerfiles and Helix queues
* Since we don't have JNI, we don't have Android Crypto - instead, use an Android build of OpenSSL. As an errata, it is incumbent upon the end user to supply this in their OS environment (we download one ad-hoc for testing purposes, which was compiled by Google)
* Some tests cannot be completed due to SELinux policies affecting the shell user executing tests via adb shell in the world-writable /data/local/tmp directory. We expect those tests would pass if they pass on Android, in a real-world IoT scenario with a custom OS (rather than recycling Google's OS images intended for phones)

Closes: #66027
2022-05-19 15:27:40 -04:00

69 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
currentDirectory=$(realpath "$(dirname "$0")")
currentTest=$(basename "$0" .sh)
runtimeExeArg=${1:-}
runtimeExe=${2:-}
extraLibsArg=${3:-}
extraLibsDir=${4:-}
if [ $# -eq 0 ]; then
echo "Usage: ${currentTest}.sh -r /path/to/dotnet [-l /path/to/preloadlibs]"
exit 0
fi
if [ "x$runtimeExeArg" != "x" ]; then
if [ "x$runtimeExeArg" != "x-r" ]; then
echo "Must specify runtime with -r /path/to/dotnet"
exit 1
fi
if [ ! -x "$runtimeExe" ]; then
echo "$runtimeExe is not a valid dotnet executable"
exit 1
fi
else
echo "Must specify runtime with -r /path/to/dotnet"
exit 1
fi
if [ "x$extraLibsArg" != "x" ]; then
if [ "x$extraLibsArg" != "x-l" ]; then
echo "Must specify preload libs with -l /path/to/preloadlibs"
exit 1
fi
if [ ! -d "$extraLibsDir" ]; then
echo "$extraLibsDir is not a valid directory"
exit 1
fi
export LD_LIBRARY_PATH="$extraLibsDir"
fi
_RuntimeDir="$(dirname "$runtimeExe")"
# Consume OpenSSL if we find it in the runtime folder
if [ -d "$_RuntimeDir/openssl" ]; then
_thisArch=$(uname -m)
case "$_thisArch" in
x86_64)
_thisArchAndroid=x86_64
;;
i*86)
_thisArchAndroid=x86
;;
armv*)
_thisArchAndroid=armeabi-v7a
;;
aarch*)
_thisArchAndroid=arm64-v8a
;;
*)
;;
esac
export LD_LIBRARY_PATH="$_RuntimeDir/openssl/prefab/modules/ssl/libs/android.$_thisArchAndroid:$_RuntimeDir/openssl/prefab/modules/crypto/libs/android.$_thisArchAndroid"
# Since we're on Helix, we know we want to set the SSL cert dir
export SSL_CERT_DIR=/system/etc/security/cacerts
fi
# Android sets an invalid value for HOME, which we bypass on "real" Android via
# some env var setup in the task. Since we aren't using the Android task system
# for Bionic, we need to override the value another way
export HOME="$currentDirectory"
cd "$currentDirectory" || exit 1
# Sometimes the depsfile doesn't exist, so only conditionally try to pass it
if [ -e "${currentTest}.deps.json" ]; then
depsFileArg="--depsfile ${currentTest}.deps.json"
fi
$runtimeExe exec --runtimeconfig "${currentTest}".runtimeconfig.json ${depsFileArg} xunit.console.dll "${currentTest}".dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing