[Unix] runtest.sh crossgen should exit on failure (dotnet/coreclr#9907)
authorSteve MacLean <sdmaclea@qti.qualcomm.com>
Thu, 23 Mar 2017 17:38:50 +0000 (13:38 -0400)
committerGaurav Khanna <gkhanna@microsoft.com>
Thu, 23 Mar 2017 17:38:50 +0000 (10:38 -0700)
* Fix crossgen segfault

* Check crossgen in runtests.sh

* Do not use test -v

CI showed bash 4.2 feature test -v is not present on
OSX CI systems.  Fall back to more standard bash test

Commit migrated from https://github.com/dotnet/coreclr/commit/087a2eeb4c1384113fe68da1257b98fa99bd0484

src/coreclr/src/utilcode/pedecoder.cpp
src/coreclr/tests/runtest.sh
src/coreclr/tests/skipCrossGenFiles.arm.txt [new file with mode: 0644]
src/coreclr/tests/skipCrossGenFiles.arm64.txt [new file with mode: 0644]
src/coreclr/tests/skipCrossGenFiles.x64.txt [new file with mode: 0644]
src/coreclr/tests/skipCrossGenFiles.x86.txt [new file with mode: 0644]

index 9b7a058..79fe244 100644 (file)
@@ -1828,8 +1828,8 @@ BOOL PEDecoder::HasNativeHeader() const
     CONTRACT_END;
 
 #ifdef FEATURE_PREJIT
-    // Pretend that ready-to-run images do not have native header
-    RETURN (((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) != 0) && !HasReadyToRunHeader());
+    // Pretend that ready-to-run images do not have native header
+    RETURN (GetCorHeader() && ((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) != 0) && !HasReadyToRunHeader());
 #else
     RETURN FALSE;
 #endif
index 649e236..dd5bf51 100755 (executable)
@@ -43,6 +43,7 @@ function print_usage {
     echo '  -h|--help                        : Show usage information.'
     echo '  --useServerGC                    : Enable server GC for this test run'
     echo '  --test-env                       : Script to set environment variables for tests'
+    echo '  --crossgen                       : Precompiles the framework managed assemblies'
     echo '  --runcrossgentests               : Runs the ready to run tests' 
     echo '  --jitstress=<n>                  : Runs the tests with COMPlus_JitStress=n'
     echo '  --jitstressregs=<n>              : Runs the tests with COMPlus_JitStressRegs=n'
@@ -370,11 +371,17 @@ function create_core_overlay {
 }
 
 function precompile_overlay_assemblies {
+    declare -A skipCrossGenFiles
+
+    while read line
+    do
+      skipCrossGenFiles[$line]=1
+    done <  "$(dirname "$0")/skipCrossGenFiles.$ARCH.txt"
 
     if [ $doCrossgen == 1 ]; then
         local overlayDir=$CORE_ROOT
 
-        filesToPrecompile=$(ls -trh $overlayDir/*.dll)
+        filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -type f )
         for fileToPrecompile in ${filesToPrecompile}
         do
             local filename=${fileToPrecompile}
@@ -385,15 +392,23 @@ function precompile_overlay_assemblies {
                     echo Unable to generate dasm for $filename
                 fi
             else
+                if [[ ${skipCrossGenFiles[$(basename $filename)]:-0} == 0 ]]; then
+                    continue
+                fi
                 echo Precompiling $filename
-                $overlayDir/crossgen /Platform_Assemblies_Paths $overlayDir $filename 2>/dev/null
+                $overlayDir/crossgen /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
                 local exitCode=$?
-                if [ $exitCode == -2146230517 ]; then
-                    echo $filename is not a managed assembly.
-                elif [ $exitCode != 0 ]; then
-                    echo Unable to precompile $filename.
+                if [[ $exitCode != 0 ]]; then
+                    if grep -q -e '(COR_E_ASSEMBLYEXPECTED)' $filename.stderr; then
+                        printf "\n\t$filename is not a managed assembly.\n\n"
+                    else
+                        echo Unable to precompile $filename.
+                        cat $filename.stdout
+                        cat $filename.stderr
+                        exit $exitCode
+                    fi
                 else
-                    echo Successfully precompiled $filename
+                    rm $filename.{stdout,stderr}
                 fi
             fi
         done
diff --git a/src/coreclr/tests/skipCrossGenFiles.arm.txt b/src/coreclr/tests/skipCrossGenFiles.arm.txt
new file mode 100644 (file)
index 0000000..df66983
--- /dev/null
@@ -0,0 +1,2 @@
+mscorlib.dll
+System.Runtime.WindowsRuntime.UI.Xaml.dll
diff --git a/src/coreclr/tests/skipCrossGenFiles.arm64.txt b/src/coreclr/tests/skipCrossGenFiles.arm64.txt
new file mode 100644 (file)
index 0000000..53eec85
--- /dev/null
@@ -0,0 +1,5 @@
+System.Runtime.WindowsRuntime.UI.Xaml.dll
+Microsoft.CodeAnalysis.VisualBasic.dll
+System.Net.NameResolution.dll
+System.Net.Sockets.dll
+System.Net.Primitives.dll
diff --git a/src/coreclr/tests/skipCrossGenFiles.x64.txt b/src/coreclr/tests/skipCrossGenFiles.x64.txt
new file mode 100644 (file)
index 0000000..df66983
--- /dev/null
@@ -0,0 +1,2 @@
+mscorlib.dll
+System.Runtime.WindowsRuntime.UI.Xaml.dll
diff --git a/src/coreclr/tests/skipCrossGenFiles.x86.txt b/src/coreclr/tests/skipCrossGenFiles.x86.txt
new file mode 100644 (file)
index 0000000..df66983
--- /dev/null
@@ -0,0 +1,2 @@
+mscorlib.dll
+System.Runtime.WindowsRuntime.UI.Xaml.dll