From: Sejong OH Date: Sat, 20 Feb 2016 20:44:13 +0000 (-0800) Subject: Add pulling down coredistool package for gcstress test X-Git-Tag: submit/tizen/20210909.063632~11030^2~11243^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aa1d63f79bad2a03cf907debec2523c07300307;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add pulling down coredistool package for gcstress test Commit migrated from https://github.com/dotnet/coreclr/commit/c4613e00119c798ec9804ebb12bf3bb89e58840c --- diff --git a/src/coreclr/src/vm/ceemain.cpp b/src/coreclr/src/vm/ceemain.cpp index e2419ac..668986b 100644 --- a/src/coreclr/src/vm/ceemain.cpp +++ b/src/coreclr/src/vm/ceemain.cpp @@ -982,20 +982,15 @@ void EEStartupHelper(COINITIEE fFlags) ClrSleepEx(g_pConfig->StartupDelayMS(), FALSE); } #endif - + #if USE_DISASSEMBLER if ((g_pConfig->GetGCStressLevel() & (EEConfig::GCSTRESS_INSTR_JIT | EEConfig::GCSTRESS_INSTR_NGEN)) != 0) { Disassembler::StaticInitialize(); if (!Disassembler::IsAvailable()) { -#ifdef HAVE_GCCOVER -#ifdef _DEBUG - printf("External disassembler is not available. Disabling GCStress for GCSTRESS_INSTR_JIT and GCSTRESS_INSTR_NGEN.\n"); -#endif // _DEBUG - g_pConfig->SetGCStressLevel( - g_pConfig->GetGCStressLevel() & ~(EEConfig::GCSTRESS_INSTR_JIT | EEConfig::GCSTRESS_INSTR_NGEN)); -#endif // HAVE_GCCOVER + fprintf(stderr, "External disassembler is not available.\n"); + IfFailGo(E_FAIL); } } #endif // USE_DISASSEMBLER diff --git a/src/coreclr/src/vm/disassembler.cpp b/src/coreclr/src/vm/disassembler.cpp old mode 100644 new mode 100755 index 9dd500c..ea44c61 --- a/src/coreclr/src/vm/disassembler.cpp +++ b/src/coreclr/src/vm/disassembler.cpp @@ -70,7 +70,6 @@ bool Disassembler::IsAvailable() #endif // USE_COREDISTOOLS_DISASSEMBLER } -// static void Disassembler::StaticInitialize() { LIMITED_METHOD_CONTRACT; @@ -78,10 +77,35 @@ void Disassembler::StaticInitialize() #if USE_COREDISTOOLS_DISASSEMBLER _ASSERTE(!IsAvailable()); - // TODO: The 'coredistools' library will eventually be part of a NuGet package, need to be able to load - // that using appropriate search paths - LPCWSTR libraryName = MAKEDLLNAME(W("coredistools")); - HMODULE libraryHandle = CLRLoadLibrary(libraryName); + HMODULE libraryHandle = nullptr; + PathString libPath; + DWORD result = WszGetModuleFileName(nullptr, libPath); + if (result == 0) { +#ifdef _DEBUG + wprintf( + W("GetModuleFileName failed, function 'DisasmInstruction': error %u\n"), + GetLastError()); +#endif // _DEBUG + return; + } + +#if defined(FEATURE_PAL) + WCHAR delim = W('/'); +#else + WCHAR delim = W('\\'); +#endif + LPCWSTR libFileName = MAKEDLLNAME(W("coredistools")); + PathString::Iterator iter = libPath.End(); + if (libPath.FindBack(iter, delim)) { + libPath.Truncate(++iter); + libPath.Append(libFileName); + } + else { + _ASSERTE(!"unreachable"); + } + + LPCWSTR libraryName = libPath.GetUnicode(); + libraryHandle = CLRLoadLibrary(libraryName); do { if (libraryHandle == nullptr) @@ -137,8 +161,8 @@ void Disassembler::StaticInitialize() return; } while (false); - CLRFreeLibrary(libraryHandle); _ASSERTE(!IsAvailable()); + #endif // USE_COREDISTOOLS_DISASSEMBLER } diff --git a/src/coreclr/tests/runtest.sh b/src/coreclr/tests/runtest.sh index b81094c..309ad83 100755 --- a/src/coreclr/tests/runtest.sh +++ b/src/coreclr/tests/runtest.sh @@ -756,8 +756,16 @@ copy_test_native_bin_to_test_root load_unsupported_tests load_failing_tests +if [ -n "$COMPlus_GCStress" ]; then + scriptPath=$(dirname $0) + ${scriptPath}/setup-gcstress.sh --outputDir=$coreOverlayDir + if [ $? -ne 0 ] + then + echo 'Failed to download coredistools library' + exit $EXIT_CODE_EXCEPTION + fi +fi - cd "$testRootDir" if [ -z "$testDirectories" ] then @@ -789,4 +797,4 @@ if ((countFailedTests > 0)); then exit $EXIT_CODE_TEST_FAILURE fi -exit $EXIT_CODE_SUCCESS \ No newline at end of file +exit $EXIT_CODE_SUCCESS diff --git a/src/coreclr/tests/setup-gcstress.sh b/src/coreclr/tests/setup-gcstress.sh new file mode 100755 index 0000000..4d141b5 --- /dev/null +++ b/src/coreclr/tests/setup-gcstress.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +# +# This script should be located in coreclr/tests. +# + +function print_usage { + echo '' + echo 'Download coredistool for GC stress testing' + echo '' + echo 'Command line:' + echo '' + echo './setup-gcstress.sh --outputDir=' + echo '' + echo 'Required arguments:' + echo ' --outputDir= : Directory to install libcoredistools.so' + echo '' +} + +# 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 $EXIT_CODE_EXCEPTION +fi + +# This script must be located in coreclr/tests. +scriptDir=$(cd "$(dirname "$0")"; pwd -P) +dotnetToolsDir=$scriptDir/../Tools +dotnetCmd=${dotnetToolsDir}/dotnetcli/bin/dotnet +packageDir=${scriptDir}/../packages +jsonFilePath=${scriptDir}/project.json + +# Check tool directory +if [ ! -e $dotnetToolsDir ]; then + echo 'Directory containing dotnet commandline does not exist:' $dotnetToolsDir + exit 1 +fi +if [ ! -e $dotnetCmd ]; then + echo 'donet commandline does not exist:' $dotnetCmd + exit 1 +fi + +# make package directory +if [ ! -e $packageDir ]; then + mkdir -p $packageDir +fi + +# make output directory +if [ ! -e $libInstallDir ]; then + mkdir -p $libInstallDir +fi + +# Write dependency information to project.json +echo { \ + \"dependencies\": { \ + \"Microsoft.NETCore.CoreDisTools\": \"1.0.0-prerelease-00001\" \ + }, \ + \"frameworks\": { \"dnxcore50\": { } } \ + } > $jsonFilePath + +# Find runtime id +rid=`$dotnetCmd --version | grep 'Runtime Id:' | sed 's/^ *Runtime Id: *//g'` + +# Download the package +echo Downloading CoreDisTools package +bash -c -x "$dotnetCmd restore $jsonFilePath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir --runtime $rid" + +# Get library path +libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools` +if [ ! -e $libPath ]; then + echo 'Failed to locate the downloaded library' + exit 1 +fi + +# Copy library to output directory +echo 'Copy library:' $libPath '-->' $libInstallDir/ +cp -f $libPath $libInstallDir + +# Delete temporary files +rm -rf $jsonFilePath + +# Return success +exit 0 +