From 8eb44fee8bdde41097f6b556ea3cc7559580e35b Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Wed, 22 Mar 2017 18:09:05 -0700 Subject: [PATCH] Add support for CoreCLR testing via ILLINK on Linux Made changes to the test infrastructure to 1) Generate .sh with commands to invoke ILLINK and run the output 2) Add runtest.sh --link= to invoke the ILLINK testing Commit migrated from https://github.com/dotnet/coreclr/commit/5f05a462321923ee6d9975cc3f88a233b3143332 --- src/coreclr/netci.groovy | 2 +- src/coreclr/tests/runtest.sh | 7 +- src/coreclr/tests/{ => scripts}/build_illink.cmd | 16 +-- src/coreclr/tests/scripts/build_illink.sh | 68 ++++++++++ src/coreclr/tests/src/CLRTest.Execute.Bash.targets | 146 +++++++++++++++++---- .../tests/src/CLRTest.Execute.Batch.targets | 8 +- 6 files changed, 206 insertions(+), 41 deletions(-) rename src/coreclr/tests/{ => scripts}/build_illink.cmd (58%) create mode 100755 src/coreclr/tests/scripts/build_illink.sh diff --git a/src/coreclr/netci.groovy b/src/coreclr/netci.groovy index db77ec38..0c6d139 100755 --- a/src/coreclr/netci.groovy +++ b/src/coreclr/netci.groovy @@ -1429,7 +1429,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR def illinkArch = (architecture == 'x86compatjit') ? 'x86' : architecture if (scenario == 'illink') { - buildCommands += "tests\\build_illink.cmd clone ${illinkArch}" + buildCommands += "tests\\scripts\\build_illink.cmd clone ${illinkArch}" } if (Constants.jitStressModeScenarios.containsKey(scenario) || diff --git a/src/coreclr/tests/runtest.sh b/src/coreclr/tests/runtest.sh index 3ec1e34..458f451 100755 --- a/src/coreclr/tests/runtest.sh +++ b/src/coreclr/tests/runtest.sh @@ -56,6 +56,7 @@ function print_usage { echo ' 8: GC on every allowable NGEN instr 16: GC only on a unique stack trace' echo ' --long-gc : Runs the long GC tests' echo ' --gcsimulator : Runs the GCSimulator tests' + echo ' --link : Runs the tests after linking via ILlink' echo ' --show-time : Print execution sequence and running time for each test' echo ' --no-lf-conversion : Do not execute LF conversion before running test script' echo ' --build-overlay-only : Exit after overlay directory is populated' @@ -960,7 +961,7 @@ buildOverlayOnly= gcsimulator= longgc= limitedCoreDumps= - +illinker= ((disableEventLogging = 0)) ((serverGC = 0)) @@ -994,6 +995,10 @@ do --jitforcerelocs) export COMPlus_ForceRelocs=1 ;; + --link=*) + export ILLINK=${i#*=} + export DoLink=true + ;; --jitdisasm) jitdisasm=1 ;; diff --git a/src/coreclr/tests/build_illink.cmd b/src/coreclr/tests/scripts/build_illink.cmd similarity index 58% rename from src/coreclr/tests/build_illink.cmd rename to src/coreclr/tests/scripts/build_illink.cmd index bfb01db..16fe10c 100644 --- a/src/coreclr/tests/build_illink.cmd +++ b/src/coreclr/tests/scripts/build_illink.cmd @@ -8,7 +8,6 @@ if /i "%1" == "-?" goto Usage if /i "%1" == "-h" goto Usage if /i "%1" == "-help" goto Usage if /i "%1" == "clone" (set doClone=1&shift&goto Arg_Loop) -if /i "%1" == "setenv" (set setEnv=1&shift&goto Arg_Loop) if /i "%1" == "x64" (set rid=win10-x64&shift&goto Arg_Loop) if /i "%1" == "x86" (set rid=win10-x86&shift&goto Arg_Loop) @@ -27,22 +26,19 @@ cd ..\linker ..\corebuild\Tools\dotnetcli\dotnet.exe publish -r %rid% -c netcore_Relase popd -if not defined setEnv goto Done -echo set ILLINK=%cd%\linker\linker\bin\netcore_Relase\netcoreapp2.0\%rid%\publish\illink.exe -endlocal && set ILLINK=%cd%\linker\linker\bin\netcore_Relase\netcoreapp2.0\%rid%\publish\illink.exe - +echo Built %cd%\linker\linker\bin\netcore_Release\netcoreapp2.0\%rid%\publish\illink.exe :Done exit /b 0 :Usage echo. -echo.Build the ILLINK for CoreCLR testing +echo.Build ILLINKer for CoreCLR testing echo. echo.Usage: -echo build_illink.cmd [clone] [setenv] runtime-ID +echo build_illink.cmd [clone] [setenv] [arch] echo.Where: echo.-? -h -help: view this message. -echo.clone: Clone the repository https://github.com/mono/linker -echo.set: set ILLINK to the path to illink.exe -echo.runtime-ID: The os-architecture configuration to build: x64 (default) or x86 +echo.clone : Clone the repository https://github.com/mono/linker +echo.arch : The architecture to build: x64 (default) or x86 +echo. goto Done diff --git a/src/coreclr/tests/scripts/build_illink.sh b/src/coreclr/tests/scripts/build_illink.sh new file mode 100755 index 0000000..d80a82e --- /dev/null +++ b/src/coreclr/tests/scripts/build_illink.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +function print_usage { + echo '' + echo 'Build ILLINKer for CoreCLR testing' + echo '' + echo 'Optional arguments:' + echo ' -?|-h|--help : Show usage information.' + echo ' --clone : Clone the repository https://github.com/mono/linker' + echo ' --arch : The architecture to build (default X64)' + echo ' --os : The os/runtime to build x64 (ubuntu.16.04)' + echo '' +} + +# Argument variables +clone= +setenv= +os='ubuntu.16.04' +arch='x64' + +for i in "$@" +do + case $i in + -?|-h|--help) + print_usage + exit $EXIT_CODE_SUCCESS + ;; + + --clone) + echo "Need to clone" + clone=1 + ;; + + --arch=*) + arch=${i#*=} + ;; + + --os=*) + os=${i#*=} + ;; + + *) + echo "Unknown switch: $i" + print_usage + exit $EXIT_CODE_SUCCESS + ;; + esac +done + +rid="$os-$arch" + +if [ ! -z "$clone" ]; then + echo "Of Course Not here" + git clone --recursive https://github.com/mono/linker +fi + +pushd linker/corebuild +./restore.sh -RuntimeIdentifier=$rid +export DoNotEmbedDescriptors=1 +cd ../linker +../corebuild/Tools/dotnetcli/dotnet publish -r $rid -c netcore_Release +popd + +dir=$(pwd) +output="$dir/linker/linker/bin/netcore_Release/netcoreapp2.0/$rid/publish/illink" +echo Built $output + +exit $EXIT_CODE_SUCCESS diff --git a/src/coreclr/tests/src/CLRTest.Execute.Bash.targets b/src/coreclr/tests/src/CLRTest.Execute.Bash.targets index 4471055..4f5cee8 100644 --- a/src/coreclr/tests/src/CLRTest.Execute.Bash.targets +++ b/src/coreclr/tests/src/CLRTest.Execute.Bash.targets @@ -29,23 +29,29 @@ WARNING: When setting properties based on their current state (for example: @@ -181,25 +187,113 @@ fi + + $(MSBuildProjectName).reflect.xml + + + # Remove Native images, since the goal is to run from Linked binaries + rm -f *.ni.* + + # Use hints for reflection roots, if provided in $(ReflectionRootsXml) + if [ -f $(ReflectionRootsXml) ]; + then + ReflectionRoots="-x $(ReflectionRootsXml)" + fi + + # Include all .exe files in this directory as entry points (some tests had multiple .exe file modules) + for bin in *.exe *.dll; + do + Assemblies="$Assemblies -a $bin" + done + + # Run dotnet-linker + # Run the Linker such that all assemblies except System.Private.Corlib.dll are linked + # Debug symbol generation needs some fixes, and is currently omitted. + # Once this is fixed, add -b true option. + echo "$ILLINK -out $LinkBin -d $CORE_ROOT -c link -l none -t $Assemblies $ReflectionRoots" + $ILLINK -out $LinkBin -d $CORE_ROOT -c link -l none -t $Assemblies $ReflectionRoots + ERRORLEVEL=$? + if [ $ERRORLEVEL -ne 0 ] + then + echo ILLINK FAILED $ERRORLEVEL + if [ ! -z "$KeepLinkedBinaries" ]; + then + rm -rf $LinkBin + fi + exit 1 + fi + + # Copy CORECLR native binaries to $LinkBin, so that we can run the test based on that directory + cp $CORE_ROOT/clrjit.dll $LinkBin + cp $CORE_ROOT/coreclr.dll $LinkBin + cp $CORE_ROOT/mscorrc.dll $LinkBin + cp $CORE_ROOT/CoreRun.exe $LinkBin + # Copy some files that may be arguments + cp *.txt $LinkBin + + ExePath=$LinkBin/$(InputAssemblyName) + export CORE_ROOT=$PWD/$LinkBin +fi +]]> + + + + + + <_CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"$CORE_ROOT/corerun" - +