Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -1 +1 @@
6caf9e45c0683785157574c925ccd24a4627ff65
9cb9c84a3e58bd2712f47e85a4c926a0c2bd947e

View File

@@ -10,7 +10,7 @@
<ItemGroup>
<!-- Some tests consist of multiple assemblies - make sure ILC sees them -->
<IlcReference Include="$(MSBuildProjectDirectory)\*.dll" />
<IlcCompileInput Include="$(MSBuildProjectDirectory)\*.dll" />
</ItemGroup>
<Import Project="$(CoreRT_TestRoot)\Test.Common.targets" />

View File

@@ -10,8 +10,6 @@
@echo OFF
setlocal ENABLEDELAYEDEXPANSION
echo CoreRT_ToolchainDir %CoreRT_ToolchainDir%
set TestFolder=%1
::
@@ -37,8 +35,8 @@ if "%CoreRT_BuildArch%" == "x64" (
call "%VS140COMNTOOLS%\..\..\VC\bin\amd64\vcvars64.bat"
)
echo msbuild /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" %TestFolder%\Test.csproj
msbuild /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" %TestFolder%\Test.csproj
echo msbuild /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\..\bin\obj\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" /p:DisableFrameworkLibGeneration=true %TestFolder%\Test.csproj
msbuild /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\..\bin\obj\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" /p:DisableFrameworkLibGeneration=true %TestFolder%\Test.csproj
if errorlevel 1 (
set TestExitCode=!ERRORLEVEL!
goto :Cleanup

View File

@@ -8,22 +8,39 @@
export TestExecutable=$1
export TestFileName=${TestExecutable%.*}
source "$CoreRT_TestRoot/coredump_handling.sh"
if [[ $CoreRT_EnableCoreDumps == 1 ]]; then
set_up_core_dump_generation
fi
cp $CoreRT_TestRoot/CoreCLR/Test.csproj .
__msbuild_dir=${CoreRT_TestRoot}/../Tools
echo ${__msbuild_dir}/msbuild.sh /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} Test.csproj
${__msbuild_dir}/msbuild.sh /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} Test.csproj
# Some tests (interop) have native artifacts they depend on. Copy all DLLs to be sure we have them.
cp *.dll native/ 2>/dev/null
if [[ $CoreRT_EnableCoreDumps == 1 ]]; then
# Handle any core files generated when running the test IL through the toolchain.
inspect_and_delete_core_files $CoreRT_ToolchainDir/corerun "$CoreRT_ToolchainDir"
fi
# Remove the test executable from the arg list so it isn't passed to test execution
shift
native/${TestFileName} $*
if [[ ! -f native/${TestFileName} ]]; then
echo "ERROR: Native binary not found. Unable to run test."
exit -1
fi
native/${TestFileName} "$@"
testScriptExitCode=$?
if [[ $CoreRT_EnableCoreDumps == 1 ]]; then
# Handle any core files generated when running the test.
inspect_and_delete_core_files native/$TestFileName "$CoreRT_ToolchainDir"
fi
# Clean up test binary artifacts to save space
rm -r native 2>/dev/null

View File

@@ -17,8 +17,8 @@
Switching to the .NET Core version of the BuildTools tasks seems to break numerous scenarios, such as VS intellisense and resource designer
as well as runnning the build on mono. Until we can get these sorted out we will continue using the .NET 4.5 version of the tasks.
-->
<PropertyGroup>
<BuildToolsTargets45>true</BuildToolsTargets45>
<PropertyGroup>
<BuildToolsTargetsDesktop>true</BuildToolsTargetsDesktop>
</PropertyGroup>
<!-- Common repo directories -->
@@ -29,7 +29,7 @@
<PackagesDir>$(ProjectDir)..\..\..\packages\</PackagesDir>
<ToolsDir Condition="'$(ToolsDir)'==''">$(ProjectDir)..\Tools\</ToolsDir>
<DotnetCliPath Condition="'$(DotnetCliPath)'==''">$(ToolsDir)dotnetcli/</DotnetCliPath>
<BuildToolsTaskDir Condition="'$(BuildToolsTargets45)' == 'true'">$(ToolsDir)net45/</BuildToolsTaskDir>
<BuildToolsTaskDir Condition="'$(BuildToolsTargetsDesktop)' == 'true'">$(ToolsDir)net46/</BuildToolsTaskDir>
<SkipImportILTargets>true</SkipImportILTargets>
</PropertyGroup>

View File

@@ -118,14 +118,6 @@ case $OSName in
;;
esac
# clean up any existing dumpling remnants from previous runs.
dumplingsListPath="$PWD/dumplings.txt"
if [ -f "$dumplingsListPath" ]; then
rm "$dumplingsListPath"
fi
find . -type f -name "local_dumplings.txt" -exec rm {} \;
function xunit_output_begin {
xunitOutputPath=$__LogDir/testResults.xml
xunitTestOutputPath=${xunitOutputPath}.test
@@ -601,7 +593,7 @@ function print_info_from_core_file {
function download_dumpling_script {
echo "Downloading latest version of dumpling script."
wget "https://raw.githubusercontent.com/Microsoft/dotnet-reliability/master/src/triage.python/dumpling.py"
wget "https://dumpling.azurewebsites.net/api/client/dumpling.py"
local dumpling_script="dumpling.py"
chmod +x $dumpling_script
@@ -632,8 +624,11 @@ function upload_core_file_to_dumpling {
paths_to_add=$coreClrBinDir
fi
# Ensure the script has Unix line endings
perl -pi -e 's/\r\n|\n|\r/\n/g' "$dumpling_script"
# The output from this will include a unique ID for this dump.
./$dumpling_script "--corefile" "$core_file_name" "upload" "--addpaths" $paths_to_add "--squelch" | tee -a $dumpling_file
./$dumpling_script "upload" "--dumppath" "$core_file_name" "--incpaths" $paths_to_add "--properties" "Project=CoreCLR" "--squelch" | tee -a $dumpling_file
}
function preserve_core_file {
@@ -1203,6 +1198,13 @@ fi
export __TestEnv=$testEnv
cd "$testRootDir"
dumplingsListPath="$testRootDir/dumplings.txt"
# clean up any existing dumpling remnants from previous runs.
rm -f "$dumplingsListPath"
find $testRootDir -type f -name "local_dumplings.txt" -exec rm {} \;
time_start=$(date +"%s")
if [ -z "$testDirectories" ]
then
@@ -1224,8 +1226,7 @@ finish_remaining_tests
print_results
echo "constructing $dumplingsListPath"
find . -type f -name "local_dumplings.txt" -exec cat {} \; > $dumplingsListPath
find $testRootDir -type f -name "local_dumplings.txt" -exec cat {} \; > $dumplingsListPath
if [ -s $dumplingsListPath ]; then
cat $dumplingsListPath

View File

@@ -0,0 +1,148 @@
#
# This script does nothing on its own. It contains functions related to core
# dump handling and is intended to be sourced from other scripts.
#
function set_up_core_dump_generation {
# We will only enable dump generation here if we're on Mac or Linux
if [[ ! ( "$(uname -s)" == "Darwin" || "$(uname -s)" == "Linux" ) ]]; then
return
fi
# We won't enable dump generation on OS X/macOS if the machine hasn't been
# configured with the kern.corefile pattern we expect.
if [[ ( "$(uname -s)" == "Darwin" && "$(sysctl -n kern.corefile)" != "core.%P" ) ]]; then
echo "WARNING: Core dump generation not being enabled due to unexpected kern.corefile value."
return
fi
# Allow dump generation
ulimit -c unlimited
if [ "$(uname -s)" == "Linux" ]; then
if [ -e /proc/self/coredump_filter ]; then
# Include memory in private and shared file-backed mappings in the dump.
# This ensures that we can see disassembly from our shared libraries when
# inspecting the contents of the dump. See 'man core' for details.
echo 0x3F > /proc/self/coredump_filter
fi
fi
}
function print_info_from_core_file {
local core_file_name=$1
local executable_name=$2
if ! [ -e $executable_name ]; then
echo "Unable to find executable $executable_name"
return
elif ! [ -e $core_file_name ]; then
echo "Unable to find core file $core_file_name"
return
fi
# Use LLDB to inspect the core dump on Mac, and GDB everywhere else.
if [[ "$(uname -s)" == "Darwin" ]]; then
hash lldb 2>/dev/null || { echo >&2 "LLDB was not found. Unable to print core file."; return; }
echo "Printing info from core file $core_file_name"
lldb -c $core_file_name -b -o 'bt'
else
# Use GDB to print the backtrace from the core file.
hash gdb 2>/dev/null || { echo >&2 "GDB was not found. Unable to print core file."; return; }
echo "Printing info from core file $core_file_name"
gdb --batch -ex "thread apply all bt full" -ex "quit" $executable_name $core_file_name
fi
}
function download_dumpling_script {
echo "Downloading latest version of dumpling script."
wget "https://dumpling.azurewebsites.net/api/client/dumpling.py"
local dumpling_script="dumpling.py"
chmod +x $dumpling_script
}
function upload_core_file_to_dumpling {
local core_file_name=$1
local paths_to_add=$2
local dumpling_script="dumpling.py"
local dumpling_file="local_dumplings.txt"
# dumpling requires that the file exist before appending.
touch ./$dumpling_file
if [ ! -x $dumpling_script ]; then
download_dumpling_script
fi
if [ ! -x $dumpling_script ]; then
echo "Failed to download dumpling script. Dump cannot be uploaded."
return
fi
echo "Uploading $core_file_name to dumpling service."
# Ensure the script has Unix line endings
perl -pi -e 's/\r\n|\n|\r/\n/g' "$dumpling_script"
# The output from this will include a unique ID for this dump.
./$dumpling_script "upload" "--dumppath" "$core_file_name" "--incpaths" $paths_to_add "--properties" "Project=CoreRT" "--squelch" | tee -a $dumpling_file
}
function preserve_core_file {
local core_file_name=$1
local paths_to_associated_files=$2
local storage_location="/tmp/coredumps_corert"
# Create the directory (this shouldn't fail even if it already exists).
mkdir -p $storage_location
# Only preserve the dump if the directory is empty. Otherwise, do nothing.
# This is a way to prevent us from storing/uploading too many dumps.
if [ ! "$(ls -A $storage_location)" ]; then
echo "Copying core file $core_file_name to $storage_location"
cp $core_file_name $storage_location
upload_core_file_to_dumpling $core_file_name $paths_to_associated_files
fi
}
function inspect_and_delete_core_files {
# This function prints some basic information from core files in the current
# directory and deletes them immediately. Based on the state of the system, it may
# also upload a core file to the dumpling service.
# (see preserve_core_file).
# Depending on distro/configuration, the core files may either be named "core"
# or "core.<PID>" by default. We will read /proc/sys/kernel/core_uses_pid to
# determine which one it is.
# On OS X/macOS, we checked the kern.corefile value before enabling core dump
# generation, so we know it always includes the PID.
local core_name_uses_pid=0
if [[ (( -e /proc/sys/kernel/core_uses_pid ) && ( "1" == $(cat /proc/sys/kernel/core_uses_pid) ))
|| ( "$(uname -s)" == "Darwin" ) ]]; then
core_name_uses_pid=1
fi
local executable_name=$1
local associated_files=$2
if [ $core_name_uses_pid == "1" ]; then
# We don't know what the PID of the process was, so let's look at all core
# files whose name matches core.NUMBER
for f in core.*; do
if [[ $f =~ core.[0-9]+ ]]; then
print_info_from_core_file "$f" "$executable_name"
preserve_core_file "$f" "$associated_files"
rm "$f"
fi
done
elif [ -f core ]; then
print_info_from_core_file "core" $CORE_ROOT/"corerun"
preserve_core_file "core"
rm "core"
fi
}

View File

@@ -11,6 +11,8 @@ set CoreRT_TestRun=true
set CoreRT_TestCompileMode=
set CoreRT_RunCoreCLRTests=
set CoreRT_CoreCLRTargetsFile=
set CoreRT_TestLogFileName=testresults.xml
set CoreRT_TestName=*
:ArgLoop
if "%1" == "" goto :ArgsDone
@@ -44,9 +46,12 @@ if /i "%1" == "/coreclr" (
:ExtRepoTestsOk
goto ArgLoop
)
if /i "%1" == "/coreclrsingletest" (set CoreRT_RunCoreCLRTests=true&set CoreRT_CoreCLRTest=%2&shift&shift&goto ArgLoop)
if /i "%1" == "/mode" (set CoreRT_TestCompileMode=%2&shift&shift&goto ArgLoop)
if /i "%1" == "/test" (set CoreRT_TestName=%2&shift&shift&goto ArgLoop)
if /i "%1" == "/runtest" (set CoreRT_TestRun=%2&shift&shift&goto ArgLoop)
if /i "%1" == "/dotnetclipath" (set CoreRT_CliDir=%2&shift&shift&goto ArgLoop)
if /i "%1" == "/multimodule" (set CoreRT_MultiFileConfiguration=MultiModule&shift&goto ArgLoop)
echo Invalid command line argument: %1
goto :Usage
@@ -56,8 +61,12 @@ echo %ThisScript% [arch] [flavor] [/mode] [/runtest] [/coreclr ^<subset^>]
echo arch : x64 / x86 / arm
echo flavor : debug / release
echo /mode : Optionally restrict to a single code generator. Specify cpp/ryujit. Default: both
echo /test : Run a single test by folder name (ie, BasicThreading)
echo /runtest : Should just compile or run compiled binary? Specify: true/false. Default: true.
echo /coreclr : Download and run the CoreCLR repo tests
echo /coreclrsingletest ^<absolute\path\to\test.exe^>
echo : Run a single CoreCLR repo test
echo /multimodule : Compile the framework as a .lib and link tests against it (only supports ryujit)
echo.
echo --- CoreCLR Subset ---
echo Top200 : Runs broad coverage / CI validation (~200 tests).
@@ -67,12 +76,29 @@ exit /b 2
:ArgsDone
if /i "%CoreRT_TestCompileMode%"=="jit" (
set CoreRT_TestCompileMode=ryujit
)
:: Cpp Codegen does not support multi-module compilation, so force Ryujit
if "%CoreRT_MultiFileConfiguration%"=="MultiModule" (
set CoreRT_TestCompileMode=ryujit
)
call %CoreRT_TestRoot%testenv.cmd
set CoreRT_RspTemplateDir=%CoreRT_TestRoot%..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%
set __BuildStr=%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%
set __CoreRTTestBinDir=%CoreRT_TestRoot%..\bin\tests
:: Place test logs in a subfolder in multi-module mode so both single-file and
:: multi-module test results are visible to the CI tooling
if NOT "%CoreRT_MultiFileConfiguration%" == "" (
set CoreRT_TestLogFileName=%CoreRT_MultiFileConfiguration%\%CoreRT_TestLogFileName%
if not exist %__CoreRTTestBinDir%\%CoreRT_MultiFileConfiguration%\ mkdir %__CoreRTTestBinDir%\%CoreRT_MultiFileConfiguration%
)
set __LogDir=%CoreRT_TestRoot%\..\bin\Logs\%__BuildStr%\tests
call "!VS140COMNTOOLS!\..\..\VC\vcvarsall.bat" %CoreRT_BuildArch%
@@ -87,11 +113,17 @@ if /i "%__BuildType%"=="Debug" (
echo. > %__CoreRTTestBinDir%\testResults.tmp
rem Hacky filtering to prevent shared generics and unshared generics from mixing
set __Filter=
if /i "%CoreRT_MultiFileConfiguration%" == "MultiModule" (
set __Filter=^^^| findstr /V Generics
)
set /a __CppTotalTests=0
set /a __CppPassedTests=0
set /a __JitTotalTests=0
set /a __JitPassedTests=0
for /f "delims=" %%a in ('dir /s /aD /b %CoreRT_TestRoot%\src\*') do (
for /f "delims=" %%a in ('cmd /c dir /s /aD /b %CoreRT_TestRoot%\src\%CoreRT_TestName% %__Filter%') do (
set __SourceFolder=%%a
set __SourceFileName=%%~na
set __RelativePath=!__SourceFolder:%CoreRT_TestRoot%=!
@@ -116,14 +148,14 @@ set /a __TotalTests=%__JitTotalTests%+%__CppTotalTests%
set /a __PassedTests=%__JitPassedTests%+%__CppPassedTests%
set /a __FailedTests=%__JitFailedTests%+%__CppFailedTests%
echo ^<?xml version="1.0" encoding="utf-8"?^> > %__CoreRTTestBinDir%\testResults.xml
echo ^<assemblies^> >> %__CoreRTTestBinDir%\testResults.xml
echo ^<assembly name="ILCompiler" total="%__TotalTests%" passed="%__PassedTests%" failed="%__FailedTests%" skipped="0"^> >> %__CoreRTTestBinDir%\testResults.xml
echo ^<collection total="%__TotalTests%" passed="%__PassedTests%" failed="%__FailedTests%" skipped="0"^> >> %__CoreRTTestBinDir%\testResults.xml
type %__CoreRTTestBinDir%\testResults.tmp >> %__CoreRTTestBinDir%\testResults.xml
echo ^</collection^> >> %__CoreRTTestBinDir%\testResults.xml
echo ^</assembly^> >> %__CoreRTTestBinDir%\testResults.xml
echo ^</assemblies^> >> %__CoreRTTestBinDir%\testResults.xml
echo ^<?xml version="1.0" encoding="utf-8"?^> > %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^<assemblies^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^<assembly name="ILCompiler" total="%__TotalTests%" passed="%__PassedTests%" failed="%__FailedTests%" skipped="0"^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^<collection total="%__TotalTests%" passed="%__PassedTests%" failed="%__FailedTests%" skipped="0"^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
type %__CoreRTTestBinDir%\testResults.tmp >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^</collection^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^</assembly^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo ^</assemblies^> >> %__CoreRTTestBinDir%\%CoreRT_TestLogFileName%
echo.
set __JitStatusPassed=1
@@ -179,11 +211,15 @@ goto :eof
if /i "%CoreRT_BuildType%" == "debug" (
set extraArgs=!extraArgs! /p:UseDebugCrt=true
)
) else (
if "%CoreRT_MultiFileConfiguration%" == "MultiModule" (
set extraArgs=!extraArgs! "/p:IlcMultiModule=true"
)
)
echo msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" !extraArgs! !__SourceFile!.csproj
echo msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFile!.csproj
echo.
msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:RepoLocalBuild=true" !extraArgs! !__SourceFile!.csproj
msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFile!.csproj
endlocal
set __SavedErrorLevel=%ErrorLevel%
@@ -192,7 +228,7 @@ goto :eof
if "%__SavedErrorLevel%"=="0" (
echo.
echo Running test !__SourceFileName!
call !__SourceFile!.cmd !__SourceFolder!\bin\%CoreRT_BuildType%\native !__SourceFileName!.exe
call !__SourceFile!.cmd !__SourceFolder!\bin\%CoreRT_BuildType%\%CoreRT_BuildArch%\native !__SourceFileName!.exe
set __SavedErrorLevel=!ErrorLevel!
)
@@ -264,19 +300,42 @@ goto :eof
if not exist "%CoreRT_TestExtRepo%" ((call :Fail "%CoreRT_TestExtRepo% does not exist") & exit /b 1)
if "%CoreRT_MultiFileConfiguration%" == "MultiModule" (
set IlcMultiModule=true
REM Pre-compile shared framework assembly
echo Compiling framework library
echo msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%CoreRT_TestRoot%..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" /t:CreateLib %CoreRT_TestRoot%\..\src\BuildIntegration\BuildFrameworkNativeObjects.proj
msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%CoreRT_TestRoot%..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" /t:CreateLib %CoreRT_TestRoot%\..\src\BuildIntegration\BuildFrameworkNativeObjects.proj
)
echo.
set CLRCustomTestLauncher=%CoreRT_TestRoot%\CoreCLR\build-and-run-test.cmd
set XunitTestBinBase=!CoreRT_TestExtRepo!
set CORE_ROOT=%CoreRT_TestRoot%\..\Tools\dotnetcli\shared\Microsoft.NETCore.App\1.0.0
echo CORE_ROOT IS NOW %CORE_ROOT%
pushd %CoreRT_TestRoot%\CoreCLR\runtest
msbuild "/p:RepoLocalBuild=true" src\TestWrappersConfig\XUnitTooling.depproj
if errorlevel 1 (
exit /b 1
)
echo runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% %CoreCLRExcludeText% %CoreRT_CoreCLRTargetsFile% LogsDir %__LogDir%
call runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% %CoreCLRExcludeText% %CoreRT_CoreCLRTargetsFile% LogsDir %__LogDir%
if not "%CoreRT_CoreCLRTest%" == "" (
if not exist "%CoreRT_CoreCLRTest%" (
echo Target test file not found: %CoreRT_CoreCLRTest%
exit /b 1
)
for %%i in (%CoreRT_CoreCLRTest%) do (
set TestFolderName=%%~dpi
set TestFileName=%%~nxi
)
call %CoreRT_TestRoot%\CoreCLR\build-and-run-test.cmd !TestFolderName! !TestFileName!
) else (
echo runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% %CoreCLRExcludeText% %CoreRT_CoreCLRTargetsFile% LogsDir %__LogDir%
call runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% %CoreCLRExcludeText% %CoreRT_CoreCLRTargetsFile% LogsDir %__LogDir%
)
set __SavedErrorLevel=%ErrorLevel%
popd
exit /b %__SavedErrorLevel%

View File

@@ -4,8 +4,12 @@ usage()
{
echo "Usage: $0 [OS] [arch] [flavor] [-mode] [-runtest] [-coreclr <subset>]"
echo " -mode : Compilation mode. Specify cpp/ryujit. Default: ryujit"
echo " -test : Run a single test by folder name (ie, BasicThreading)"
echo " -runtest : Should just compile or run compiled binary? Specify: true/false. Default: true."
echo " -coreclr : Download and run the CoreCLR repo tests"
echo " -multimodule : Compile the framework as a .so and link tests against it (ryujit only)"
echo " -coredumps : [For CI use] Enables core dump generation, and analyzes and possibly stores/uploads"
echo " dumps collected during test run."
echo ""
echo " --- CoreCLR Subset ---"
echo " top200 : Runs broad coverage / CI validation (~200 tests)."
@@ -20,7 +24,7 @@ runtest()
__SourceFolder=$1
__SourceFileName=$2
__SourceFile=${__SourceFolder}/${__SourceFileName}
${__SourceFile}.sh $1/bin/${CoreRT_BuildType}/native $2
${__SourceFile}.sh $1/bin/${CoreRT_BuildType}/${CoreRT_BuildArch}/native $2
return $?
}
@@ -28,21 +32,38 @@ run_test_dir()
{
local __test_dir=$1
local __mode=$2
local __extra_cxxflags=$3
local __extra_linkflags=$4
local __dir_path=`dirname ${__test_dir}`
local __filename=`basename ${__dir_path}`
local __extra_args=""
if [ "${__mode}" = "Cpp" ]; then
__extra_args="${__extra_args} /p:NativeCodeGen=cpp"
__extra_args="${__extra_args} /p:NativeCodeGen=cpp"
fi
if [ -n "${__extra_cxxflags}" ]; then
__extra_cxxflags="/p:AdditionalCppCompilerFlags=\"${__extra_cxxflags}\""
fi
if [ -n "${__extra_cxxflags}" ]; then
__extra_linkflags="/p:AdditionalLinkerFlags=\"${__extra_linkflags}\""
fi
if [ "${CoreRT_MultiFileConfiguration}" = "MultiModule" ]; then
__extra_args="${__extra_args} /p:IlcMultiModule=true"
fi
rm -rf ${__dir_path}/bin ${__dir_path}/obj
rm -rf ${__dir_path}/bin/${CoreRT_BuildType} ${__dir_path}/obj/${CoreRT_BuildType}
local __msbuild_dir=${CoreRT_TestRoot}/../Tools
echo ${__msbuild_dir}/msbuild.sh /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} /p:RepoLocalBuild=true ${__extra_args} ${__dir_path}/${__filename}.csproj
${__msbuild_dir}/msbuild.sh /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} /p:RepoLocalBuild=true ${__extra_args} ${__dir_path}/${__filename}.csproj
runtest ${__dir_path} ${__filename}
echo ${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /ds /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} /p:Platform=${CoreRT_BuildArch} /p:RepoLocalBuild=true "/p:FrameworkLibPath=${CoreRT_TestRoot}/../bin/Product/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/lib" "/p:FrameworkObjPath=${CoreRT_TestRoot}/../bin/obj/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/Framework" ${__extra_args} "${__extra_cxxflags}" "${__extra_linkflags}" ${__dir_path}/${__filename}.csproj
${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /ds /m /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} /p:Platform=${CoreRT_BuildArch} /p:RepoLocalBuild=true "/p:FrameworkLibPath=${CoreRT_TestRoot}/../bin/Product/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/lib" "/p:FrameworkObjPath=${CoreRT_TestRoot}/../bin/obj/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/Framework" ${__extra_args} "${__extra_cxxflags}" "${__extra_linkflags}" ${__dir_path}/${__filename}.csproj
local __exitcode=$?
if [ ${CoreRT_TestRun} == true ]; then
runtest ${__dir_path} ${__filename}
__exitcode=$?
fi
if [ ${__exitcode} == 0 ]; then
local __pass_var=__${__mode}PassedTests
eval ${__pass_var}=$((${__pass_var} + 1))
@@ -101,6 +122,7 @@ run_coreclr_tests()
pushd ${CoreRT_TestRoot}/CoreCLR/runtest
export CoreRT_TestRoot
export CoreRT_EnableCoreDumps
CoreRT_TestSelectionArg=
if [ "$SelectedTests" = "top200" ]; then
@@ -121,7 +143,13 @@ CoreRT_CliBinDir=${CoreRT_TestRoot}/../Tools/dotnetcli
CoreRT_BuildArch=x64
CoreRT_BuildType=Debug
CoreRT_TestRun=true
CoreRT_TestCompileMode=ryujit
CoreRT_TestCompileMode=
CoreRT_CrossRootFS=
CoreRT_CrossCXXFlags=
CoreRT_CrossLinkerFlags=
CoreRT_CrossBuild=0
CoreRT_EnableCoreDumps=0
CoreRT_TestName=*
while [ "$1" != "" ]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
@@ -139,6 +167,9 @@ while [ "$1" != "" ]; do
arm)
CoreRT_BuildArch=arm
;;
armel)
CoreRT_BuildArch=armel
;;
arm64)
CoreRT_BuildArch=arm64
;;
@@ -152,6 +183,10 @@ while [ "$1" != "" ]; do
shift
CoreRT_TestCompileMode=$1
;;
-test)
shift
CoreRT_TestName=$1
;;
-runtest)
shift
CoreRT_TestRun=$1
@@ -160,6 +195,10 @@ while [ "$1" != "" ]; do
shift
CoreRT_CliBinDir=$1
;;
-cross)
shift
CoreRT_CrossBuild=$1
;;
-coreclr)
CoreRT_RunCoreCLRTests=true;
shift
@@ -172,12 +211,62 @@ while [ "$1" != "" ]; do
exit -1
fi
;;
-multimodule)
CoreRT_MultiFileConfiguration=MultiModule;
;;
-coredumps)
CoreRT_EnableCoreDumps=1
;;
*)
;;
esac
shift
done
CoreRT_ExtraCXXFlags=
CoreRT_ExtraLinkFlags=
if [ ${CoreRT_CrossBuild} != 0 ]; then
CoreRT_TestRun=false
CoreRT_CrossRootFS=${CoreRT_TestRoot}/../cross/rootfs/${CoreRT_BuildArch}
# all values are brought from the appropriate toolchain.cmake's
case $CoreRT_BuildArch in
arm)
CoreRT_CrossCXXFlags="-target armv7-linux-gnueabihf -mthumb -mfpu=vfpv3 --sysroot=${CoreRT_CrossRootFS}"
CoreRT_CrossLinkerFlags="-target arm-linux-gnueabihf -B ${CoreRT_CrossRootFS}/usr/lib/gcc/arm-linux-gnueabihf `
`-L${CorRT_CrossRootFS}/lib/arm-linux-gnueabihf --sysroot=${CoreRT_CrossRootFS}"
;;
arm64)
CoreRT_CrossCXXFlags="-target aarch64-linux-gnu --sysroot=${CoreRT_CrossRootFS}"
CoreRT_CrossLinkerFlags="-target aarch64-linux-gnu -B ${CoreRT_CrossRootFS}/usr/lib/gcc/aarch64-linux-gnu `
`-L${CoreRT_CrossRootFS}/lib/aarch64-linux-gnu --sysroot=${CoreRT_CrossRootFS}"
;;
armel)
CoreRT_CrossCXXFlags="-target armv7-linux-gnueabi -mthumb -mfpu=vfpv3 -mfloat-abi=softfp --sysroot=${CoreRT_CrossRootFS}"
CoreRT_CrossLinkerFlags="-target arm-linux-gnueabi --sysroot=${CoreRT_CrossRootFS}"
ID=
if [ -e $ROOTFS_DIR/etc/os-release ]; then
source $ROOTFS_DIR/etc/os-release
fi
if [ "$ID" = "tizen" ]; then
CoreRT_CrossCXXFlags="${CoreRT_CrossCXXFlags} -isystem ${CoreRT_CrossRootFS}/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++ `
`-isystem ${CoreRT_CrossRootFS}//usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/armv7l-tizen-linux-gnueabi `
`-isystem ${CoreRT_CrossRootFS}/armel/usr/include"
TIZEN_TOOLCHAIN="armv7l-tizen-linux-gnueabi/4.9.2"
CoreRT_CrossLinkerFlags="${CoreRT_CrossLinkerFlags} -B${CoreRT_CrossRootFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN} `
`-L${CoreRT_CrossRootFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}"
else
TOOLCHAIN="arm-linux-gnueabi"
CoreRT_CrossCXXFlags="${CoreRT_CrossCXXFlags} -isystem ${CoreRT_CrossRootFS}/usr/include/c++/4.9 `
`-isystem ${CoreRT_CrossRootFS}/usr/include/arm-linux-gnueabi/c++/4.9 "
CoreRT_CrossLinkerFlags="${CoreRT_CrossLinkerFlags} -B${CoreRT_CrossRootFS}/usr/lib/gcc/${TOOLCHAIN}/4.9 `
`-L${CoreRT_CrossRootFS}/usr/lib/gcc/${TOOLCHAIN}/4.9"
fi
;;
esac
CoreRT_ExtraCXXFlags="$CoreRT_ExtraCXXFlags $CoreRT_CrossCXXFlags"
CoreRT_ExtraLinkFlags="$CoreRT_ExtraLinkFlags $CoreRT_CrossLinkerFlags"
fi
source "$CoreRT_TestRoot/testenv.sh"
__BuildStr=${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}
@@ -185,6 +274,15 @@ __CoreRTTestBinDir=${CoreRT_TestRoot}/../bin/tests
__LogDir=${CoreRT_TestRoot}/../bin/Logs/${__BuildStr}/tests
__build_os_lowcase=$(echo "${CoreRT_BuildOS}" | tr '[:upper:]' '[:lower:]')
if [ "$CoreRT_MultiFileConfiguration" = "MultiModule" ]; then
CoreRT_TestCompileMode=ryujit
fi
if [ "$CoreRT_TestCompileMode" = "jit" ]; then
CoreRT_TestCompileMode=ryujit
fi
if [ ! -d $__LogDir ]; then
mkdir -p $__LogDir
fi
@@ -207,13 +305,17 @@ __JitPassedTests=0
echo > ${__CoreRTTestBinDir}/testResults.tmp
__BuildOsLowcase=$(echo "${CoreRT_BuildOS}" | tr '[:upper:]' '[:lower:]')
for csproj in $(find src -name "*.csproj")
__TestSearchPath=src/Simple/${CoreRT_TestName}
for csproj in $(find ${__TestSearchPath} -name "*.csproj")
do
if [ ! -e `dirname ${csproj}`/no_unix ]; then
run_test_dir ${csproj} "Jit"
if [ "${CoreRT_TestCompileMode}" != "cpp" ]; then
run_test_dir ${csproj} "Jit"
fi
if [ ! -e `dirname ${csproj}`/no_cpp ]; then
run_test_dir ${csproj} "Cpp"
if [ "${CoreRT_TestCompileMode}" != "ryujit" ]; then
run_test_dir ${csproj} "Cpp" "$CoreRT_ExtraCXXFlags" "$CoreRT_ExtraLinkFlags"
fi
fi
fi
done
@@ -222,14 +324,23 @@ __TotalTests=$((${__JitTotalTests} + ${__CppTotalTests}))
__PassedTests=$((${__JitPassedTests} + ${__CppPassedTests}))
__FailedTests=$((${__TotalTests} - ${__PassedTests}))
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > ${__CoreRTTestBinDir}/testResults.xml
echo "<assemblies>" >> ${__CoreRTTestBinDir}/testResults.xml
echo "<assembly name=\"ILCompiler\" total=\"${__TotalTests}\" passed=\"${__PassedTests}\" failed=\"${__FailedTests}\" skipped=\"0\">" >> ${__CoreRTTestBinDir}/testResults.xml
echo "<collection total=\"${__TotalTests}\" passed=\"${__PassedTests}\" failed=\"${__FailedTests}\" skipped=\"0\">" >> ${__CoreRTTestBinDir}/testResults.xml
cat "${__CoreRTTestBinDir}/testResults.tmp" >> ${__CoreRTTestBinDir}/testResults.xml
echo "</collection>" >> ${__CoreRTTestBinDir}/testResults.xml
echo "</assembly>" >> ${__CoreRTTestBinDir}/testResults.xml
echo "</assemblies>" >> ${__CoreRTTestBinDir}/testResults.xml
if [ "$CoreRT_MultiFileConfiguration" = "MultiModule" ]; then
__TestResultsLog=${__CoreRTTestBinDir}/${CoreRT_MultiFileConfiguration}/testResults.xml
if [ ! -d ${__CoreRTTestBinDir}/${CoreRT_MultiFileConfiguration} ]; then
mkdir -p ${__CoreRTTestBinDir}/${CoreRT_MultiFileConfiguration}
fi
else
__TestResultsLog=${__CoreRTTestBinDir}/testResults.xml
fi
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > ${__TestResultsLog}
echo "<assemblies>" >> ${__TestResultsLog}
echo "<assembly name=\"ILCompiler\" total=\"${__TotalTests}\" passed=\"${__PassedTests}\" failed=\"${__FailedTests}\" skipped=\"0\">" >> ${__TestResultsLog}
echo "<collection total=\"${__TotalTests}\" passed=\"${__PassedTests}\" failed=\"${__FailedTests}\" skipped=\"0\">" >> ${__TestResultsLog}
cat "${__CoreRTTestBinDir}/testResults.tmp" >> ${__TestResultsLog}
echo "</collection>" >> ${__TestResultsLog}
echo "</assembly>" >> ${__TestResultsLog}
echo "</assemblies>" >> ${__TestResultsLog}
echo "JIT - TOTAL: ${__JitTotalTests} PASSED: ${__JitPassedTests}"

View File

@@ -1,23 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
using System;
using System.Runtime.CompilerServices;
public class BringUpTest
{
const int Pass = 100;
const int Fail = -1;
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static int Add1(int x) { return x+1; }
public static int Main()
{
int y = Add1(1);
if (y == 2) return Pass;
else return Fail;
}
}

View File

@@ -6,7 +6,7 @@ IF "%ErrorCode%"=="100" (
echo %~n0: pass
EXIT /b 0
) ELSE (
echo %~n0: fail
echo %~n0: fail - %ErrorCode%
EXIT /b 1
)
endlocal

View File

@@ -3,15 +3,70 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
class Program
{
public const int Pass = 100;
public const int Fail = -1;
static int Main()
{
SimpleReadWriteThreadStaticTest.Run(42, "SimpleReadWriteThreadStatic");
// TODO: After issue https://github.com/dotnet/corert/issues/2695 is fixed, move FinalizeTest to run at the end
if (FinalizeTest.Run() != Pass)
return Fail;
ThreadStaticsTestWithTasks.Run();
return 100;
if (ThreadTest.Run() != Pass)
return Fail;
return Pass;
}
public static bool IsRunnningOnWindows()
{
// Note: Environment.OSVersion is not yet available.
// This is a temporary hack that allows to skip Task related tests on Unix.
return System.IO.Path.DirectorySeparatorChar == '\\';
}
}
class FinalizeTest
{
public static bool visited = false;
public class Dummy
{
~Dummy()
{
FinalizeTest.visited = true;
}
}
public static int Run()
{
int iterationCount = 0;
while (!visited && iterationCount++ < 10000)
{
GC.KeepAlive(new Dummy());
GC.Collect();
}
if (visited)
{
Console.WriteLine("FinalizeTest passed");
return Program.Pass;
}
else
{
Console.WriteLine("FinalizeTest failed");
return Program.Fail;
}
}
}
@@ -108,6 +163,12 @@ class ThreadStaticsTestWithTasks
public static void Run()
{
if (!Program.IsRunnningOnWindows())
{
// Tasks are not supported on Unix yet
return;
}
Task[] tasks = new Task[TotalTaskCount];
for (int i = 0; i < tasks.Length; ++i)
{
@@ -137,3 +198,381 @@ class ThreadStaticsTestWithTasks
}
}
}
class ThreadTest
{
private static readonly List<Thread> s_startedThreads = new List<Thread>();
private static int s_passed;
private static int s_failed;
private static void Expect(bool condition, string message)
{
if (condition)
{
Interlocked.Increment(ref s_passed);
}
else
{
Interlocked.Increment(ref s_failed);
Console.WriteLine("ERROR: " + message);
}
}
private static void ExpectException<T>(Action action, string message)
{
Exception ex = null;
try
{
action();
}
catch (Exception e)
{
ex = e;
}
if (!(ex is T))
{
message += string.Format(" (caught {0})", (ex == null) ? "no exception" : ex.GetType().Name);
}
Expect(ex is T, message);
}
private static void ExpectPassed(string testName, int expectedPassed)
{
// Wait for all started threads to finish execution
foreach (Thread t in s_startedThreads)
{
t.Join();
}
s_startedThreads.Clear();
Expect(s_passed == expectedPassed, string.Format("{0}: Expected s_passed == {1}, got {2}", testName, expectedPassed, s_passed));
s_passed = 0;
}
private static void TestStartMethod()
{
// Case 1: new Thread(ThreadStart).Start()
var t1 = new Thread(() => Expect(true, "Expected t1 to start"));
t1.Start();
s_startedThreads.Add(t1);
// Case 2: new Thread(ThreadStart).Start(parameter)
var t2 = new Thread(() => Expect(false, "This thread must not be started"));
// InvalidOperationException: The thread was created with a ThreadStart delegate that does not accept a parameter.
ExpectException<InvalidOperationException>(() => t2.Start(null), "Expected InvalidOperationException for t2.Start()");
// Case 3: new Thread(ParameterizedThreadStart).Start()
var t3 = new Thread(obj => Expect(obj == null, "Expected obj == null"));
t3.Start();
s_startedThreads.Add(t3);
// Case 4: new Thread(ParameterizedThreadStart).Start(parameter)
var t4 = new Thread(obj => Expect((int)obj == 42, "Expected (int)obj == 42"));
t4.Start(42);
s_startedThreads.Add(t4);
// Start an unstarted resurrected thread.
// CoreCLR: ThreadStateException, CoreRT: no exception.
Thread unstartedResurrected = Resurrector.CreateUnstartedResurrected();
unstartedResurrected.Start();
s_startedThreads.Add(unstartedResurrected);
// Threads cannot started more than once
t1.Join();
ExpectException<ThreadStateException>(() => t1.Start(), "Expected ThreadStateException for t1.Start()");
ExpectException<ThreadStateException>(() => Thread.CurrentThread.Start(),
"Expected ThreadStateException for CurrentThread.Start()");
Thread stoppedResurrected = Resurrector.CreateStoppedResurrected();
ExpectException<ThreadStateException>(() => stoppedResurrected.Start(),
"Expected ThreadStateException for stoppedResurrected.Start()");
ExpectPassed(nameof(TestStartMethod), 7);
}
private static void TestJoinMethod()
{
var t = new Thread(() => { });
ExpectException<InvalidOperationException>(() => t.Start(null), "Expected InvalidOperationException for t.Start()");
ExpectException<ThreadStateException>(() => t.Join(), "Expected ThreadStateException for t.Join()");
Thread stoppedResurrected = Resurrector.CreateStoppedResurrected();
Expect(stoppedResurrected.Join(1), "Expected stoppedResurrected.Join(1) to return true");
Expect(!Thread.CurrentThread.Join(1), "Expected CurrentThread.Join(1) to return false");
ExpectPassed(nameof(TestJoinMethod), 4);
}
private static void TestCurrentThreadProperty()
{
Thread t = null;
t = new Thread(() => Expect(Thread.CurrentThread == t, "Expected CurrentThread == t on thread t"));
t.Start();
s_startedThreads.Add(t);
Expect(Thread.CurrentThread != t, "Expected CurrentThread != t on main thread");
ExpectPassed(nameof(TestCurrentThreadProperty), 2);
}
private static void TestNameProperty()
{
var t = new Thread(() => { });
t.Name = null;
// It is OK to set the null Name multiple times
t.Name = null;
Expect(t.Name == null, "Expected t.Name == null");
const string ThreadName = "My thread";
t.Name = ThreadName;
Expect(t.Name == ThreadName, string.Format("Expected t.Name == \"{0}\"", ThreadName));
ExpectException<InvalidOperationException>(() => { t.Name = null; },
"Expected InvalidOperationException setting Thread.Name back to null");
ExpectPassed(nameof(TestNameProperty), 3);
}
private static void TestIsBackgroundProperty()
{
if (!Program.IsRunnningOnWindows())
{
// This test uses tasks which are not supported on Unix yet
return;
}
// Thread created using Thread.Start
var t_event = new AutoResetEvent(false);
var t = new Thread(() => t_event.WaitOne());
t.Start();
s_startedThreads.Add(t);
Expect(!t.IsBackground, "Expected t.IsBackground == false");
t_event.Set();
t.Join();
ExpectException<ThreadStateException>(() => Console.WriteLine(t.IsBackground),
"Expected ThreadStateException for t.IsBackground");
// Thread pool thread
Task.Factory.StartNew(() => Expect(Thread.CurrentThread.IsBackground, "Expected IsBackground == true")).Wait();
// Resurrected threads
Thread unstartedResurrected = Resurrector.CreateUnstartedResurrected();
Expect(unstartedResurrected.IsBackground == false, "Expected unstartedResurrected.IsBackground == false");
Thread stoppedResurrected = Resurrector.CreateStoppedResurrected();
ExpectException<ThreadStateException>(() => Console.WriteLine(stoppedResurrected.IsBackground),
"Expected ThreadStateException for stoppedResurrected.IsBackground");
// Main thread
Expect(!Thread.CurrentThread.IsBackground, "Expected CurrentThread.IsBackground == false");
ExpectPassed(nameof(TestIsBackgroundProperty), 6);
}
private static void TestIsThreadPoolThreadProperty()
{
#if false // The IsThreadPoolThread property is not in the contract version we compile against at present
var t = new Thread(() => { });
Expect(!t.IsThreadPoolThread, "Expected t.IsThreadPoolThread == false");
Task.Factory.StartNew(() => Expect(Thread.CurrentThread.IsThreadPoolThread, "Expected IsThreadPoolThread == true")).Wait();
Expect(!Thread.CurrentThread.IsThreadPoolThread, "Expected CurrentThread.IsThreadPoolThread == false");
ExpectPassed(nameof(TestIsThreadPoolThreadProperty), 3);
#endif
}
private static void TestManagedThreadIdProperty()
{
int t_id = 0;
var t = new Thread(() => {
Expect(Thread.CurrentThread.ManagedThreadId == t_id, "Expected CurrentTread.ManagedThreadId == t_id on thread t");
Expect(Environment.CurrentManagedThreadId == t_id, "Expected Environment.CurrentManagedThreadId == t_id on thread t");
});
t_id = t.ManagedThreadId;
Expect(t_id != 0, "Expected t_id != 0");
Expect(Thread.CurrentThread.ManagedThreadId != t_id, "Expected CurrentTread.ManagedThreadId != t_id on main thread");
Expect(Environment.CurrentManagedThreadId != t_id, "Expected Environment.CurrentManagedThreadId != t_id on main thread");
t.Start();
s_startedThreads.Add(t);
// Resurrected threads
Thread unstartedResurrected = Resurrector.CreateUnstartedResurrected();
Expect(unstartedResurrected.ManagedThreadId != 0, "Expected unstartedResurrected.ManagedThreadId != 0");
Thread stoppedResurrected = Resurrector.CreateStoppedResurrected();
Expect(stoppedResurrected.ManagedThreadId != 0, "Expected stoppedResurrected.ManagedThreadId != 0");
ExpectPassed(nameof(TestManagedThreadIdProperty), 7);
}
private static void TestThreadStateProperty()
{
var t_event = new AutoResetEvent(false);
var t = new Thread(() => t_event.WaitOne());
Expect(t.ThreadState == ThreadState.Unstarted, "Expected t.ThreadState == ThreadState.Unstarted");
t.Start();
s_startedThreads.Add(t);
Expect(t.ThreadState == ThreadState.Running || t.ThreadState == ThreadState.WaitSleepJoin,
"Expected t.ThreadState is either ThreadState.Running or ThreadState.WaitSleepJoin");
t_event.Set();
t.Join();
Expect(t.ThreadState == ThreadState.Stopped, "Expected t.ThreadState == ThreadState.Stopped");
// Resurrected threads
Thread unstartedResurrected = Resurrector.CreateUnstartedResurrected();
Expect(unstartedResurrected.ThreadState == ThreadState.Unstarted,
"Expected unstartedResurrected.ThreadState == ThreadState.Unstarted");
Thread stoppedResurrected = Resurrector.CreateStoppedResurrected();
Expect(stoppedResurrected.ThreadState == ThreadState.Stopped,
"Expected stoppedResurrected.ThreadState == ThreadState.Stopped");
ExpectPassed(nameof(TestThreadStateProperty), 5);
}
private static unsafe void DoStackAlloc(int size)
{
byte* buffer = stackalloc byte[size];
Volatile.Write(ref buffer[0], 0);
}
private static void TestMaxStackSize()
{
#if false // The constructors with maxStackSize are not in the contract version we compile against at present
// Allocate a 3 MiB buffer on the 4 MiB stack
var t = new Thread(() => DoStackAlloc(3 << 20), 4 << 20);
t.Start();
s_startedThreads.Add(t);
#endif
ExpectPassed(nameof(TestMaxStackSize), 0);
}
static int s_startedThreadCount = 0;
private static void TestStartShutdown()
{
Thread[] threads = new Thread[2048];
// Creating a large number of threads
for (int i = 0; i < threads.Length; i++)
{
threads[i] = new Thread(() => { Interlocked.Increment(ref s_startedThreadCount); });
threads[i].Start();
}
// Wait for all threads to shutdown;
for (int i = 0; i < threads.Length; i++)
{
threads[i].Join();
}
Expect(s_startedThreadCount == threads.Length,
String.Format("Not all threads completed. Expected: {0}, Actual: {1}", threads.Length, s_startedThreadCount));
}
public static int Run()
{
TestStartMethod();
TestJoinMethod();
TestCurrentThreadProperty();
TestNameProperty();
TestIsBackgroundProperty();
TestIsThreadPoolThreadProperty();
TestManagedThreadIdProperty();
TestThreadStateProperty();
TestMaxStackSize();
TestStartShutdown();
return (s_failed == 0) ? Program.Pass : Program.Fail;
}
/// <summary>
/// Creates resurrected Thread objects.
/// </summary>
class Resurrector
{
static Thread s_unstartedResurrected;
static Thread s_stoppedResurrected;
bool _unstarted;
Thread _thread = new Thread(() => { });
Resurrector(bool unstarted)
{
_unstarted = unstarted;
if (!unstarted)
{
_thread.Start();
_thread.Join();
}
}
~Resurrector()
{
if (_unstarted && (s_unstartedResurrected == null))
{
s_unstartedResurrected = _thread;
}
else if(!_unstarted && (s_stoppedResurrected == null))
{
s_stoppedResurrected = _thread;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void CreateInstance(bool unstarted)
{
GC.KeepAlive(new Resurrector(unstarted));
}
static Thread CreateResurrectedThread(ref Thread trap, bool unstarted)
{
trap = null;
while (trap == null)
{
// Call twice to override the address of the first allocation on the stack (for conservative GC)
CreateInstance(unstarted);
CreateInstance(unstarted);
GC.Collect();
GC.WaitForPendingFinalizers();
}
// We would like to get a Thread object with its internal SafeHandle member disposed.
// The current implementation of SafeHandle postpones disposing until the next garbage
// collection. For this reason we do a couple more collections.
for (int i = 0; i < 2; i++)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
return trap;
}
public static Thread CreateUnstartedResurrected()
{
return CreateResurrectedThread(ref s_unstartedResurrected, unstarted: true);
}
public static Thread CreateStoppedResurrected()
{
return CreateResurrectedThread(ref s_stoppedResurrected, unstarted: false);
}
}
}

0
external/corert/tests/src/Simple/BasicThreading/BasicThreading.sh vendored Normal file → Executable file
View File

View File

@@ -1,9 +1,5 @@
<Project ToolsVersion="14.0" DefaultTargets="BuildAllFrameworkLibraries" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NativeIntermediateOutputPath>$(MSBuildProjectDirectory)\obj\$(Configuration)\native\</NativeIntermediateOutputPath>
</PropertyGroup>
<Import Project="..\..\..\..\src\BuildIntegration\BuildFrameworkNativeObjects.proj" />
</Project>

View File

@@ -6,7 +6,7 @@ IF "%ErrorCode%"=="100" (
echo %~n0: pass
EXIT /b 0
) ELSE (
echo %~n0: fail
echo %~n0: fail - %ErrorCode%
EXIT /b 1
)
endlocal

View File

@@ -6,7 +6,7 @@ IF "%ErrorCode%"=="100" (
echo %~n0: pass
EXIT /b 0
) ELSE (
echo %~n0: fail
echo %~n0: fail - %ErrorCode%
EXIT /b 1
)
endlocal

View File

@@ -1,29 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Globalization;
internal class Program
{
private static int Main(string[] args)
{
string s123 = 123.ToString();
if (s123 != "123")
{
Console.WriteLine("Unexpected: " + s123);
return 1;
}
string s123dot5 = (123.5).ToString(CultureInfo.InvariantCulture);
if (s123dot5 != "123.5")
{
Console.WriteLine("Unexpected: " + s123dot5);
return 1;
}
Console.WriteLine("{0}", "Hi");
return 100;
}
}

View File

@@ -6,7 +6,7 @@ IF "%ErrorCode%"=="100" (
echo %~n0: pass
EXIT /b 0
) ELSE (
echo %~n0: fail
echo %~n0: fail - %ErrorCode%
EXIT /b 1
)
endlocal

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More