From e17e3b2ceee62fdc45486e966c623e834a559ca2 Mon Sep 17 00:00:00 2001
From: Sergey Andreenko <seandree@microsoft.com>
Date: Wed, 12 Jun 2019 15:25:55 -0700
Subject: [PATCH 1/4] abort build-tests if failed to restore stress
 dependencies

---
 build-test.cmd | 4 ++++
 build-test.sh  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/build-test.cmd b/build-test.cmd
index 39c38d415e5f..e07c926d059b 100644
--- a/build-test.cmd
+++ b/build-test.cmd
@@ -180,6 +180,10 @@ REM ===
 REM =========================================================================================
 
 call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
+if errorlevel 1 (
+    echo %__MsgPrefix%Error: setup-stress-dependencies failed.
+    goto     :Exit_Failure
+)
 @if defined _echo @echo on
 
 REM =========================================================================================
diff --git a/build-test.sh b/build-test.sh
index aa25c85bc661..b77cacb9bb02 100755
--- a/build-test.sh
+++ b/build-test.sh
@@ -159,6 +159,10 @@ generate_layout()
         nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --outputDir=$CORE_ROOT"
         echo "Resolve runtime dependences via $nextCommand"
         eval $nextCommand
+        if [ $? != 0 ]; then
+            echo "${__MsgPrefix}Error: setup-stress-dependencies failed."
+            exit 1
+        fi
     fi
 
     # Precompile framework assemblies with crossgen if required

From 29d66abdc7487225b1bb0f373cbf067d0efc69e2 Mon Sep 17 00:00:00 2001
From: Sergey Andreenko <seandree@microsoft.com>
Date: Thu, 13 Jun 2019 12:48:22 -0700
Subject: [PATCH 2/4] Fix arm condition.

---
 tests/setup-stress-dependencies.cmd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/setup-stress-dependencies.cmd b/tests/setup-stress-dependencies.cmd
index 78f81e9b15e4..70a0a0e324b2 100644
--- a/tests/setup-stress-dependencies.cmd
+++ b/tests/setup-stress-dependencies.cmd
@@ -36,10 +36,10 @@ if not defined __OutputDir goto Usage
 if not defined __Arch goto Usage 
 
 REM Check if the platform is supported
-if /i %__Arch% == "arm" (
+if /i "%__Arch%" == "arm" (
     echo No runtime dependencies for Arm32.
     exit /b 0
-    )
+)
 
 REM =========================================================================================
 REM ===

From 324ac2ea78779aed767548f5cc011cc530384a4b Mon Sep 17 00:00:00 2001
From: Sergey Andreenko <seandree@microsoft.com>
Date: Thu, 13 Jun 2019 12:48:58 -0700
Subject: [PATCH 3/4] Add arm64 condition.

---
 tests/setup-stress-dependencies.cmd | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/setup-stress-dependencies.cmd b/tests/setup-stress-dependencies.cmd
index 70a0a0e324b2..02bedd26ca0f 100644
--- a/tests/setup-stress-dependencies.cmd
+++ b/tests/setup-stress-dependencies.cmd
@@ -41,6 +41,11 @@ if /i "%__Arch%" == "arm" (
     exit /b 0
 )
 
+if /i "%__Arch%" == "arm64" (
+    echo No runtime dependencies for Arm64.
+    exit /b 0
+)
+
 REM =========================================================================================
 REM ===
 REM === Check if dotnet CLI and necessary directories exist

From 736c1fce69d48eb0cd8479c70f54439fc088168c Mon Sep 17 00:00:00 2001
From: Sergey Andreenko <seandree@microsoft.com>
Date: Thu, 13 Jun 2019 13:27:06 -0700
Subject: [PATCH 4/4] Skip runtime dependencies for arm32/arm64.

---
 build-test.sh                      |  2 +-
 tests/bringup_runtest.sh           | 10 ++--------
 tests/setup-stress-dependencies.sh | 19 +++++++++++++++++--
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/build-test.sh b/build-test.sh
index b77cacb9bb02..65703d57bf3a 100755
--- a/build-test.sh
+++ b/build-test.sh
@@ -156,7 +156,7 @@ generate_layout()
     cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
 
     if [ "$__BuildOS" != "OSX" ]; then
-        nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --outputDir=$CORE_ROOT"
+        nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --arch=$__BuildArch --outputDir=$CORE_ROOT"
         echo "Resolve runtime dependences via $nextCommand"
         eval $nextCommand
         if [ $? != 0 ]; then
diff --git a/tests/bringup_runtest.sh b/tests/bringup_runtest.sh
index cbaa4850e168..23b457624f0c 100755
--- a/tests/bringup_runtest.sh
+++ b/tests/bringup_runtest.sh
@@ -1451,14 +1451,8 @@ 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
-elif [ "$ARCH" != "arm64" ] && [ "$ARCH" != "arm" ]; then
-    echo "Skip preparing for GC stress test. Dependent package is not supported on this architecture."
-fi
+scriptPath=$(dirname $0)
+${scriptPath}/setup-stress-dependencies.sh --arch=$ARCH --outputDir=$coreOverlayDir
 
 export __TestEnv=$testEnv
 
diff --git a/tests/setup-stress-dependencies.sh b/tests/setup-stress-dependencies.sh
index 65fb5637b3f4..a6465a94f663 100755
--- a/tests/setup-stress-dependencies.sh
+++ b/tests/setup-stress-dependencies.sh
@@ -16,9 +16,10 @@ function print_usage {
     echo ''
     echo 'Command line:'
     echo ''
-    echo './setup-gcstress.sh --outputDir=<coredistools_lib_install_path>'
+    echo './setup-gcstress.sh --arch=<TargetArch> --outputDir=<coredistools_lib_install_path>'
     echo ''
     echo 'Required arguments:'
+    echo '  --arch=<TargetArch>        : Target arch for the build'
     echo '  --outputDir=<path>         : Directory to install libcoredistools.so'
     echo ''
 }
@@ -55,6 +56,9 @@ do
         -v|--verbose)
             verbose=1
             ;;
+        --arch=*)
+            __BuildArch=${i#*=}
+            ;;
         --outputDir=*)
             libInstallDir=${i#*=}
             ;;
@@ -66,12 +70,23 @@ do
     esac
 done
 
+if [ -z "$__BuildArch" ]; then
+    echo "--arch is required."
+    print_usage
+    exit_with_error 1
+fi
+
 if [ -z "$libInstallDir" ]; then
-    echo "--libInstallDir is required."
+    echo "--outputDir is required."
     print_usage
     exit_with_error 1
 fi
 
+if [ "$__BuildArch" == "arm64" ] || [ "$__BuildArch" == "arm" ]; then
+    echo "No runtime dependencies for arm32/arm64"
+    exit $EXIT_CODE_SUCCESS
+fi
+
 # This script must be located in coreclr/tests.
 scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"