Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Intermittent checkin - Build helper projects
Browse files Browse the repository at this point in the history
  • Loading branch information
A-And committed Jan 30, 2018
1 parent 48d4acc commit ba7c398
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 3 deletions.
82 changes: 82 additions & 0 deletions tests/CoreFX/corerun
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

# This is the Unix equivalent of build-and-run-test.cmd
# It is invoked by each test's bash script. The reason it's called corerun is that
# the unix CoreCLR tests don't have a custom runner override environment variable.
# See issue https://github.com/dotnet/coreclr/issues/9007
# The CoreFX alternative is named corerun to keep parity with CoreCLR's testing infrastructure

#!/usr/bin/env bash

# This is the Unix equivalent of build-and-run-test.cmd
# It is invoked by each test's bash script. The reason it's called corerun is that
# the unix CoreCLR tests don't have a custom runner override environment variable.
# See issue https://github.com/dotnet/coreclr/issues/9007

export TestExecutable=$1
export TestFileName=${TestExecutable%.*}

source "$CoreRT_TestRoot/coredump_handling.sh"

if [[ $CoreRT_EnableCoreDumps == 1 ]]; then
set_up_core_dump_generation
fi

cp -ar $CoreRT_TestRoot/CoreCLR/. .

# Workaround until we have a better reflection engine
# Add name of currently executing test to rd.xml

$__dotnetclipath/dotnet publish


__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

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

testExtRepo=$( dirname ${CoreRT_TestRoot} )/tests_downloaded/CoreCLR/
nativeArtifactRepo=${testExtRepo}native/
dirSuffix=$(dirname ${PWD#$testExtRepo})/
nativeDir=${nativeArtifactRepo}tests/src/${dirSuffix}

# In OSX we copy the native component to the directory where the exectuable resides.
# However, in Linux dlopen doesn't seem to look for current directory to resolve the dynamic library.
# So instead we point LD_LIBRARY_PATH to the directory where the native component is.
if [ -e ${nativeDir} ]; then
if [ "${CoreRT_BuildOS}" == "OSX" ]; then
echo "Copying native component from :"${nativeDir}
cp ${nativeDir}*.dylib native/ 2>/dev/null
fi
if [ "${CoreRT_BuildOS}" == "Linux" ]; then
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${nativeDir}
export LD_LIBRARY_PATH
fi
fi

if [[ ! -f native/${TestFileName} ]]; then
echo "ERROR: Native binary not found. Unable to run test."
exit -1
fi

pushd native/
./${TestFileName} "$@"
testScriptExitCode=$?
popd

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

exit $testScriptExitCode
Empty file added tests/CoreFX/runtest/runtest.sh
Empty file.
88 changes: 85 additions & 3 deletions tests/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ usage()
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 " -corefx : Download and run the CoreFX repo tests"
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"
Expand Down Expand Up @@ -81,7 +82,7 @@ run_test_dir()
return $?
}

download_and_unzip_tests_artifacts()
download_and_unzip_coreclr_tests_artifacts()
{
url=$1
location=$2
Expand All @@ -101,6 +102,42 @@ download_and_unzip_tests_artifacts()
fi
}

download_and_unzip_corefx_tests_artifacts()
{
# Build and restore test helper projects
${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /t:Restore "${CoreRT_TestFileHelperProjectPath}"
__exitcode = $?
if [__exitcode != 0];
then
exit __exitcode
fi

${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /t:Restore "${CoreRT_XunitHelperProjectPath}"
__exitcode = $?
if [__exitcode != 0];
then
exit __exitcode
fi

:: Build the test helper projects
${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /m /ConsoleLoggerParameters:ForceNoAlign /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} /p:Platform=${CoreRT_BuildArch} /p:OSGroup=${CoreRT_BuildOS} /p:RepoLocalBuild=true "/p:FrameworkLibPath=${CoreRT_TestRoot}/../bin/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/lib" "/p:FrameworkObjPath=${CoreRT_TestRoot}/../bin/obj/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/Framework" "${CoreRT_TestFileHelperProjectPath}"

__exitcode = $?
if [__exitcode != 0];
then
exit __exitcode
fi

${__msbuild_dir}/dotnetcli/dotnet ${__msbuild_dir}/MSBuild.dll /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:OSGroup=%CoreRT_BuildOS%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%CoreRT_TestRoot%..\bin\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" "/p:OutputPath=%CoreRT_TestingUtilitiesOutputDir%" /p:RepoLocalBuild=true "${CoreRT_TestFileHelperProjectPath}"
__exitcode = $?
if [__exitcode != 0];
then
exit __exitcode
fi

}


restore_coreclr_tests()
{
CoreRT_Test_Download_Semaphore=${CoreRT_TestExtRepo}/init-tests.completed
Expand All @@ -115,10 +152,10 @@ restore_coreclr_tests()
CoreRT_NativeArtifactRepo=${CoreRT_TestExtRepo}/native

echo "Restoring tests (this may take a few minutes).."
download_and_unzip_tests_artifacts ${TESTS_REMOTE_URL} ${CoreRT_TestExtRepo} ${CoreRT_Test_Download_Semaphore}
download_and_unzip_coreclr_tests_artifacts ${TESTS_REMOTE_URL} ${CoreRT_TestExtRepo} ${CoreRT_Test_Download_Semaphore}

echo "Restoring native test artifacts..."
download_and_unzip_tests_artifacts ${NATIVE_REMOTE_URL} ${CoreRT_NativeArtifactRepo} ${CoreRT_NativeArtifact_Download_Semaphore}
download_and_unzip_coreclr_tests_artifacts ${NATIVE_REMOTE_URL} ${CoreRT_NativeArtifactRepo} ${CoreRT_NativeArtifact_Download_Semaphore}
}

run_coreclr_tests()
Expand Down Expand Up @@ -156,6 +193,43 @@ run_coreclr_tests()
./runtest.sh --testRootDir=${CoreRT_TestExtRepo} --coreOverlayDir=${CoreRT_TestRoot}/CoreCLR ${CoreRT_TestSelectionArg} --logdir=$__LogDir --disableEventLogging
}

run_corefx_tests()
{
CoreRT_TestExtRepo_CoreFX=%CoreRT_TestRoot%\..\tests_downloaded\CoreFX
CoreRT_TestingUtilitiesOutputDir=%CoreRT_TestExtRepo_CoreFX%\Utilities

# Set paths to helpers
CoreRT_TestFileHelperName=CoreFX.TestUtils.TestFileSetup
CoreRT_TestFileHelperProjectPath="%CoreRT_TestRoot%\CoreFX\runtest\src\TestUtils\TestFileSetup\%CoreRT_TestFileHelperName%.csproj"

CoreRT_XunitHelperName=CoreFX.TestUtils.XUnit
CoreRT_XunitHelperProjectPath="%CoreRT_TestRoot%\CoreFX\runtest\src\TestUtils\XUnit\%CoreRT_XunitHelperName%.csproj"

download_and_unzip_corefx_tests_artifacts ${CoreRT_TestFileHelperProjectPath} ${CoreRT_XunitHelperProjectPath} ARGS_HERE
__exitcode = $?
if [__exitcode != 0];
then
exit __exitcode
fi
# FXCustomTestLauncher=%CoreRT_TestRoot%\CoreFX\build-and-run-test.cmd
# XunitTestBinBase=%CoreRT_TestExtRepo_CoreFX%
# XunitLogDir= %__LogDir%\CoreFX
# pushd %CoreRT_TestRoot%\CoreFX\runtest

# # TODO Add single test/target test support; add exclude tests argument

# runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% LogsDir %XunitLogDir%
# runtest.cmd %CoreRT_BuildArch% %CoreRT_BuildType% LogsDir %XunitLogDir%
# if errorlevel 1
# then
# exit /b 1


# "%CoreRT_CliDir%\dotnet.exe" !CoreRT_TestingUtilitiesOutputDir!\!CoreRT_XunitHelperName!.dll --logDir "%XunitLogDir%" --pattern "*.xml"


}

CoreRT_TestRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CoreRT_CliBinDir=${CoreRT_TestRoot}/../Tools/dotnetcli
CoreRT_BuildArch=x64
Expand Down Expand Up @@ -229,6 +303,10 @@ while [ "$1" != "" ]; do
exit -1
fi
;;
-corefx)
CoreRT_RunCoreFXTests=true;
shift
;;
-multimodule)
CoreRT_MultiFileConfiguration=MultiModule;
;;
Expand Down Expand Up @@ -315,6 +393,10 @@ if [ ${CoreRT_RunCoreCLRTests} ]; then
exit $?
fi

if [ ${CoreRT_RunCoreFXTests} ]; then
run_corefx_tests
exit $?

__CppTotalTests=0
__CppPassedTests=0
__JitTotalTests=0
Expand Down

0 comments on commit ba7c398

Please sign in to comment.