From 69ea93da545052013c7c689bdac53aded6cd7b1d Mon Sep 17 00:00:00 2001 From: William Godbe Date: Fri, 20 Nov 2015 15:11:19 -0800 Subject: [PATCH] runtest.sh now works on Mac as well as Linux --- tests/runtest.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/runtest.sh b/tests/runtest.sh index d1f312a7f652..c44508a99340 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -64,6 +64,24 @@ countSkippedTests=0 xunitOutputPath= xunitTestOutputPath= +# libExtension determines extension for dynamic library files +OSName=$(uname -s) +libExtension= +case $OSName in + Linux) + libExtension="so" + ;; + + Darwin) + libExtension="dylib" + ;; + *) + echo "Unsupported OS $OSName detected, configuring as if for Linux" + libExtension="so" + ;; +esac + + function xunit_output_begin { xunitOutputPath=$testRootDir/coreclrtests.xml xunitTestOutputPath=${xunitOutputPath}.test @@ -86,7 +104,7 @@ function xunit_output_add_test { local testResult=$3 # Pass, Fail, or Skip local testScriptExitCode=$4 - local testPath=${scriptFilePath:0:(-3)} # Remove trailing ".sh" + local testPath=${scriptFilePath%.sh} # Remove trailing ".sh" local testDir=$(dirname "$testPath") local testName=$(basename "$testPath") @@ -311,8 +329,10 @@ function create_core_overlay { rm -f -r "$coreOverlayDir" fi mkdir "$coreOverlayDir" - (cd $coreFxBinDir && find . -iname '*.dll' \! -iwholename '*test*' \! -iwholename '*/ToolRuntime/*' -exec cp -f -u '{}' "$coreOverlayDir/" \;) - cp -f "$coreFxNativeBinDir/Native/"*.so "$coreOverlayDir/" 2>/dev/null + + (cd $coreFxBinDir && find . -iname '*.dll' \! -iwholename '*test*' \! -iwholename '*/ToolRuntime/*' -exec cp -f '{}' "$coreOverlayDir/" \;) + cp -f "$coreFxNativeBinDir/Native/"*."$libExtension" "$coreOverlayDir/" 2>/dev/null + cp -f "$coreClrBinDir/"* "$coreOverlayDir/" 2>/dev/null cp -f "$mscorlibDir/mscorlib.dll" "$coreOverlayDir/" cp -n "$testDependenciesDir"/* "$coreOverlayDir/" 2>/dev/null @@ -333,7 +353,7 @@ function copy_test_native_bin_to_test_root { fi # Copy native test components from the native test build into the respective test directory in the test root directory - find "$testNativeBinDir" -type f -iname '*.so' | + find "$testNativeBinDir" -type f -iname '*.$libExtension' | while IFS='' read -r filePath || [ -n "$filePath" ]; do local dirPath=$(dirname "$filePath") local destinationDirPath=${testRootDir}${dirPath:${#testNativeBinDir}} @@ -418,8 +438,8 @@ function run_test { local outputFileName=$(basename "$outputFilePath") # Convert DOS line endings to Unix if needed - sed -i 's/\r$//' "$scriptFileName" - + perl -pi -e 's/\r\n|\n|\r/\n/g' "$scriptFileName" + # Add executable file mode bit if needed chmod +x "$scriptFileName"