Explicitly download correct version of CoreDisTools package
authorwtgodbe <wigodbe@microsoft.com>
Mon, 5 Jun 2017 20:17:25 +0000 (13:17 -0700)
committerwtgodbe <wigodbe@microsoft.com>
Mon, 5 Jun 2017 20:26:01 +0000 (13:26 -0700)
build-test.cmd
tests/runtest.sh
tests/setup-stress-dependencies.cmd [new file with mode: 0644]
tests/setup-stress-dependencies.sh [new file with mode: 0644]
tests/src/Common/stress_dependencies/stress_dependencies.csproj [new file with mode: 0644]
tests/src/Common/test_dependencies/test_dependencies.csproj

index 6291f50..6a320e3 100644 (file)
@@ -147,6 +147,14 @@ call "%__ProjectDir%\init-tools.cmd"
 
 REM =========================================================================================
 REM ===
+REM === Resolve runtime dependences
+REM ===
+REM =========================================================================================
+
+call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
+
+REM =========================================================================================
+REM ===
 REM === Native test build section
 REM ===
 REM =========================================================================================
index 439bbb6..82bbaff 100755 (executable)
@@ -1202,6 +1202,18 @@ else
     load_failing_tests
 fi
 
+# Other architectures are not supported yet.
+if [ "$ARCH" == "x64" ]
+then
+    scriptPath=$(dirname $0)
+    ${scriptPath}/setup-stress-dependencies.sh --outputDir=$coreOverlayDir
+else
+    if [ "$ARCH" != "arm64" ]
+    then
+        echo "Skip preparing for GC stress test. Dependent package is not supported on this architecture."
+    fi
+fi
+
 export __TestEnv=$testEnv
 
 cd "$testRootDir"
diff --git a/tests/setup-stress-dependencies.cmd b/tests/setup-stress-dependencies.cmd
new file mode 100644 (file)
index 0000000..0770e85
--- /dev/null
@@ -0,0 +1,117 @@
+@if not defined _echo @echo off
+setlocal
+
+set __ThisScriptShort=%0
+set __ThisScriptFull=%~f0
+set __ThisScriptPath=%~dp0
+
+REM =========================================================================================
+REM ===
+REM === Parse arguments
+REM ===
+REM =========================================================================================
+
+set __OutputDir=
+set __Arch= 
+
+:Arg_Loop
+if "%1" == "" goto ArgsDone
+
+if /i "%1" == "/?"    goto Usage
+if /i "%1" == "-?"    goto Usage
+if /i "%1" == "/h"    goto Usage
+if /i "%1" == "-h"    goto Usage
+if /i "%1" == "/help" goto Usage
+if /i "%1" == "-help" goto Usage
+
+if /i "%1" == "/arch"             (set __Arch=%2&shift&shift&goto Arg_Loop) 
+if /i "%1" == "/outputdir"        (set __OutputDir=%2&shift&shift&goto Arg_Loop)
+
+echo Invalid command-line argument: %1
+goto Usage
+
+:ArgsDone
+
+if not defined __OutputDir goto Usage
+if not defined __Arch goto Usage 
+
+REM Check if the platform is supported
+if /i %__Arch% == "arm" (
+    echo No runtime dependencies for Arm32.
+    exit /b 0
+    )
+
+REM =========================================================================================
+REM ===
+REM === Check if dotnet CLI and necessary directories exist
+REM ===
+REM =========================================================================================
+
+set __DotNetToolDir=%__ThisScriptPath%..\Tools
+set __DotNetCmd=%__DotNetToolDir%\dotnetcli\dotnet.exe 
+set __PackageDir=%__ThisScriptPath%..\Packages
+set __CsprojPath=%__ThisScriptPath%\src\Common\stress_dependencies\stress_dependencies.csproj
+
+REM Check if dotnet cli exists
+if not exist "%__DotNetToolDir%" (
+    echo Directory containing dotnet CLI does not exist: %__DotNetToolDir%
+    goto Fail
+)
+if not exist "%__DotNetCmd%" (
+    echo dotnet.exe does not exist: %__DotNetCmd%
+    goto Fail
+)
+
+REM Create directories needed
+if not exist "%__PackageDir%" md "%__PackageDir%"
+if not exist "%__OutputDir%" md "%__OutputDir%"
+
+REM =========================================================================================
+REM ===
+REM === Download packages
+REM ===
+REM =========================================================================================
+
+REM Download the package
+echo Downloading CoreDisTools package
+set DOTNETCMD="%__DotNetCmd%" restore "%__CsprojPath%" --source https://dotnet.myget.org/F/dotnet-core/ --packages "%__PackageDir%"
+echo %DOTNETCMD%
+call %DOTNETCMD%
+if errorlevel 1 goto Fail
+
+REM Get downloaded dll path
+echo Locating coredistools.dll
+FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s ^| findstr /R "runtime.win[0-9]*-%__Arch%"') DO set __LibPath=%%i
+echo CoreDisTools library path: %__LibPath%
+if not exist "%__LibPath%" (
+    echo Failed to locate the downloaded library: %__LibPath%
+    goto Fail
+)
+
+REM Copy library to output directory
+echo Copy library: %__LibPath% to %__OutputDir%
+copy /y "%__LibPath%" "%__OutputDir%"
+if errorlevel 1 (
+    echo Failed to copy %__LibPath% to %__OutputDir%
+    goto Fail
+)
+
+exit /b 0
+
+:Fail
+exit /b 1
+
+REM =========================================================================================
+REM ===
+REM === Helper routines
+REM ===
+REM =========================================================================================
+
+:Usage
+echo.
+echo Download coredistools for GC stress testing
+echo.
+echo Usage:
+echo     %__ThisScriptShort% /arch ^<TargetArch^> /outputdir ^<coredistools_lib_install_path^>
+echo.
+exit /b 1
\ No newline at end of file
diff --git a/tests/setup-stress-dependencies.sh b/tests/setup-stress-dependencies.sh
new file mode 100644 (file)
index 0000000..a7f3c49
--- /dev/null
@@ -0,0 +1,133 @@
+#!/usr/bin/env bash
+# set -x
+
+#
+# Constants
+#
+readonly EXIT_CODE_SUCCESS=0
+
+#
+# This script should be located in coreclr/tests.
+#
+
+function print_usage {
+    echo ''
+    echo 'Download coredistools for GC stress testing'
+    echo ''
+    echo 'Command line:'
+    echo ''
+    echo './setup-gcstress.sh --outputDir=<coredistools_lib_install_path>'
+    echo ''
+    echo 'Required arguments:'
+    echo '  --outputDir=<path>         : Directory to install libcoredistools.so'
+    echo ''
+}
+
+function exit_with_error {
+    local errorCode=$1
+    local errorMsg=$2
+
+    if [ ! -z "$2" ]; then
+        echo $2
+    fi
+    
+    exit $errorCode
+}
+
+function handle_ctrl_c {
+    exit_with_error 1 'Aborted by Ctrl+C'
+ }
+
+# Register the Ctrl-C handler
+trap handle_ctrl_c INT
+
+# Argument variables
+libInstallDir=
+
+# Handle arguments
+verbose=0
+for i in "$@"
+do
+    case $i in
+        -h|--help)
+            exit $EXIT_CODE_SUCCESS
+            ;;
+        -v|--verbose)
+            verbose=1
+            ;;
+        --outputDir=*)
+            libInstallDir=${i#*=}
+            ;;
+        *)
+            echo "Unknown switch: $i"
+            print_usage
+            exit $EXIT_CODE_SUCCESS
+            ;;
+    esac
+done
+
+if [ -z "$libInstallDir" ]; then
+    echo "--libInstallDir is required."
+    print_usage
+    exit_with_error 1
+fi
+
+# This script must be located in coreclr/tests.
+scriptDir=$(cd "$(dirname "$0")"; pwd -P)
+
+echo "Running init-tools.sh"
+$scriptDir/../init-tools.sh
+
+dotnetToolsDir=$scriptDir/../Tools
+dotnetCmd=${dotnetToolsDir}/dotnetcli/dotnet
+packageDir=${scriptDir}/../packages
+csprojPath=${scriptDir}/src/Common/stress_dependencies/stress_dependencies.csproj
+
+# Check tool directory
+if [ ! -e $dotnetToolsDir ]; then
+    exit_with_error 1 'Directory containing dotnet commandline does not exist:'$dotnetToolsDir 
+fi
+if [ ! -e $dotnetCmd ]; then
+    exit_with_error 1 'dotnet commandline does not exist:'$dotnetCmd
+fi
+
+# make package directory
+if [ ! -e $packageDir ]; then
+    mkdir -p $packageDir
+fi
+
+# make output directory
+if [ ! -e $libInstallDir ]; then
+    mkdir -p $libInstallDir
+fi
+
+# Query runtime Id
+rid=`$dotnetCmd --info | grep 'RID:' | sed 's/^ *RID: *//g'`  
+if [ -z "$rid" ]; then
+    exit_with_error 1 "Failed to query runtime Id"
+fi    
+
+# Download the package
+echo Downloading CoreDisTools package
+bash -c -x "$dotnetCmd restore $csprojPath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir"
+if [ $? -ne 0 ]
+then
+    exit_with_error 1 "Failed to restore the package"
+fi
+
+# Get library path
+libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools`
+if [ ! -e $libPath ]; then
+    exit_with_error 1 'Failed to locate the downloaded library'
+fi
+
+# Copy library to output directory
+echo 'Copy library:' $libPath '-->' $libInstallDir/
+cp -f $libPath $libInstallDir
+if [ $? -ne 0 ]
+then
+    exit_with_error 1 "Failed to copy the library"
+fi
+
+# Return success
+exit $EXIT_CODE_SUCCESS
diff --git a/tests/src/Common/stress_dependencies/stress_dependencies.csproj b/tests/src/Common/stress_dependencies/stress_dependencies.csproj
new file mode 100644 (file)
index 0000000..e33ee1e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <CLRTestKind>BuildOnly</CLRTestKind>
+    <NugetTargetMoniker>.NETCoreApp,Version=v2.0</NugetTargetMoniker>
+    <NugetTargetMonikerShort>netcoreapp2.0</NugetTargetMonikerShort>
+    <IsTestProject>false</IsTestProject>
+  </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="Microsoft.NETCore.CoreDisTools">
+      <Version>1.0.1-prerelease-*</Version>
+    </PackageReference>
+  </ItemGroup>
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
+    <PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
+    <RuntimeIdentifiers>win7-x64;ubuntu.14.04-x64;osx.10.10-x64;win7-x86;ubuntu.14.04-x86;osx.10.10-x86</RuntimeIdentifiers>
+    <ContainsPackageReferences>true</ContainsPackageReferences>
+    <PrereleaseResolveNuGetPackages>false</PrereleaseResolveNuGetPackages>
+  </PropertyGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <Target Name="Build"
+     DependsOnTargets="ResolveReferences" />
+</Project>
\ No newline at end of file
index 53b51f7..c225dee 100644 (file)
@@ -10,9 +10,6 @@
     <IsTestProject>false</IsTestProject>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.NETCore.CoreDisTools">
-      <Version>1.0.1-prerelease-*</Version>
-    </PackageReference>
     <PackageReference Include="Microsoft.Private.CoreFx.NETCoreApp">
       <Version>$(CoreFxPackageVersion)</Version>
     </PackageReference>