From c8ac9307fb3585e217a4f07860b12205aa2debb2 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 5 Nov 2010 17:52:00 -0400 Subject: [PATCH 1/3] Add contract test for Trilinos 10.6.1 snapshot. --- Tests/Contracts/Trilinos-10-6/CMakeLists.txt | 96 +++++++++++++++++++ .../Trilinos-10-6/Dashboard.cmake.in | 62 ++++++++++++ Tests/Contracts/Trilinos-10-6/EnvScript.cmake | 32 +++++++ Tests/Contracts/Trilinos-10-6/RunTest.cmake | 4 + .../Trilinos-10-6/ValidateBuild.cmake | 4 + 5 files changed, 198 insertions(+) create mode 100644 Tests/Contracts/Trilinos-10-6/CMakeLists.txt create mode 100644 Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in create mode 100644 Tests/Contracts/Trilinos-10-6/EnvScript.cmake create mode 100644 Tests/Contracts/Trilinos-10-6/RunTest.cmake create mode 100644 Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake diff --git a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt new file mode 100644 index 000000000..48a467ab0 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt @@ -0,0 +1,96 @@ +cmake_minimum_required(VERSION 2.8) +project(Trilinos-10-6) + +include(ExternalProject) + +include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL) +include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL) + +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() + + if(NOT HOME AND WIN32) + # Try for USERPROFILE as HOME equivalent: + string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") + + # But just use root of SystemDrive if USERPROFILE contains any spaces: + # (Default on XP and earlier...) + if(HOME MATCHES " ") + string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") + endif() + endif() +endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED url) + set(url "http://www.cmake.org/files/contracts/trilinos-10.6.1.tar.gz") +endif() +message(STATUS "url='${url}'") + +if(NOT DEFINED md5) + set(md5 "690230465dd21a76e3c6636fd07bd2f0") +endif() +message(STATUS "md5='${md5}'") + +string(SUBSTRING "${md5}" 0 8 shorttag) + +set(download_dir "${HOME}/.cmake/Downloads") + +set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}") +set(binary_dir "${base_dir}/build") +set(script_dir "${base_dir}") +set(source_dir "${base_dir}/src") + +if(NOT DEFINED BUILDNAME) + set(BUILDNAME "CMakeContract-${shorttag}") +endif() +message(STATUS "BUILDNAME='${BUILDNAME}'") + +if(NOT DEFINED SITE) + site_name(SITE) +endif() +message(STATUS "SITE='${SITE}'") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" + "${script_dir}/Dashboard.cmake" + @ONLY) + +# Source dir for this project exists outside the CMake build tree because it +# is absolutely huge. Source dir is therefore cached under a '.cmake/Contracts' +# dir in your HOME directory. Downloads are cached under '.cmake/Downloads' +# +if(EXISTS "${source_dir}/cmake/ctest/TrilinosCTestDriverCore.cmake") + # If it exists already, download is a complete no-op: + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +else() + # If it does not yet exist, download pulls the tarball from the web (or + # no-ops if it already exists with the given md5 sum): + # + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_DIR "${download_dir}" + URL "${url}" + URL_MD5 "${md5}" + SOURCE_DIR "${source_dir}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endif() + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -P "${script_dir}/Dashboard.cmake" + INSTALL_COMMAND "" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in new file mode 100644 index 000000000..1209dc87e --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in @@ -0,0 +1,62 @@ +# This "cmake -P" script may be configured to drive a dashboard on any machine. +# +set(CTEST_BINARY_DIRECTORY "@binary_dir@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_SITE "@SITE@") +set(CTEST_SOURCE_DIRECTORY "@source_dir@") + +# Set the environment: +# +set(ENV{CTEST_BUILD_NAME} "${CTEST_BUILD_NAME}") +set(ENV{CTEST_CMAKE_GENERATOR} "${CTEST_CMAKE_GENERATOR}") +set(ENV{CTEST_SITE} "${CTEST_SITE}") + +# Allow override of the environment on a per-client basis: +# +set(ENV_SCRIPT "$ENV{CMAKE_CONTRACT_Trilinos_10_6_ENV_SCRIPT}") +if(ENV_SCRIPT AND EXISTS "${ENV_SCRIPT}") + include("${ENV_SCRIPT}") +endif() + +# Empty build dir to start with: +# +message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}") + +# Generate 'do-configure' script: +# +file(WRITE "${CTEST_BINARY_DIRECTORY}/do-configure" " +\"${CMAKE_COMMAND}\" -G \"${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\" +") + +# Make the 'do-configure' script executable and execute it: +# +if(WIN32) + configure_file( + "${CTEST_BINARY_DIRECTORY}/do-configure" + "${CTEST_BINARY_DIRECTORY}/do-configure.cmd" + COPYONLY) + execute_process(COMMAND "${CTEST_BINARY_DIRECTORY}/do-configure.cmd" + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +else() + execute_process(COMMAND chmod +x "${CTEST_BINARY_DIRECTORY}/do-configure") + execute_process(COMMAND "${CTEST_BINARY_DIRECTORY}/do-configure" + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +endif() + +# Run an experimental Trilinos dashboard: +# +execute_process(COMMAND + "${CMAKE_CTEST_COMMAND}" + -S "${CTEST_SOURCE_DIRECTORY}/cmake/ctest/experimental_build_test.cmake" + -VV + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}" + RESULT_VARIABLE rv + ) + +if(NOT "${rv}" STREQUAL "0") + message(FATAL_ERROR "error(s) running Trilinos dashboard script experimental_build_test.cmake +ctest returned rv='${rv}' +") +endif() diff --git a/Tests/Contracts/Trilinos-10-6/EnvScript.cmake b/Tests/Contracts/Trilinos-10-6/EnvScript.cmake new file mode 100644 index 000000000..dacb704f7 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/EnvScript.cmake @@ -0,0 +1,32 @@ +# Site specific settings: +# +if(CTEST_SITE MATCHES "faraway") + set(CTEST_SITE "faraway.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") +endif() + +if(CTEST_SITE STREQUAL "HUT11") + set(CTEST_SITE "hut11.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") + + set(ENV{CLAPACK_DIR} "C:/T/clapack/b/clapack-prefix/src/clapack-build") +endif() + +if(CTEST_SITE MATCHES "qwghlm") + set(CTEST_SITE "qwghlm.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") + + set(ENV{PATH} "/opt/local/bin:$ENV{PATH}") + set(ENV{CC} "gcc-mp-4.3") + set(ENV{CXX} "g++-mp-4.3") + set(ENV{FC} "gfortran-mp-4.3") +endif() + +# Submit to alternate CDash server: +# +#set(ENV{CTEST_DROP_SITE} "localhost") +#set(ENV{CTEST_DROP_LOCATION} "/CDash/submit.php?project=Trilinos") + +# Limit packages built: +# +set(ENV{Trilinos_PACKAGES} "Teuchos;Kokkos") diff --git a/Tests/Contracts/Trilinos-10-6/RunTest.cmake b/Tests/Contracts/Trilinos-10-6/RunTest.cmake new file mode 100644 index 000000000..93c1505ed --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/RunTest.cmake @@ -0,0 +1,4 @@ +get_filename_component(dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(exe "${CMAKE_COMMAND}") +set(args -P "${dir}/ValidateBuild.cmake") +set(Trilinos-10-6_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake new file mode 100644 index 000000000..6942b09ef --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake @@ -0,0 +1,4 @@ +# TODO: put some actual code here to validate that the Trilinos build was +# "successful enough" +# +message(STATUS "Trilinos-10-6 build validated") From 73485615b2d66123b4952118440612d4f7bc9d0a Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 28 Dec 2010 08:53:04 -0500 Subject: [PATCH 2/3] Use m prefix in shorttag value to indicate "md5 of tarball" --- Tests/Contracts/Trilinos-10-6/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt index 48a467ab0..3e06d4f27 100644 --- a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt +++ b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt @@ -37,6 +37,7 @@ endif() message(STATUS "md5='${md5}'") string(SUBSTRING "${md5}" 0 8 shorttag) +set(shorttag "m${shorttag}") set(download_dir "${HOME}/.cmake/Downloads") From 81136214f3a45c84686461eab3917b6e1115f771 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 28 Dec 2010 11:27:56 -0500 Subject: [PATCH 3/3] Establish pass criteria for the Trilinos contract test. Add a ValidateBuild.cmake script that runs after the Trilinos dashboard run is complete. In that script, look for some expected Trilinos executable files. Run the basic Teuchos unit tests executable and expect it to return 0 for no errors. Also, patch the main CMakeLists.txt file to get rid of new warnings from CMake when variables passed in on the command line go un-referenced in the CMakeLists processing. --- Tests/Contracts/Trilinos-10-6/CMakeLists.txt | 6 +++ .../Trilinos-10-6/Dashboard.cmake.in | 3 +- Tests/Contracts/Trilinos-10-6/Patch.cmake | 20 ++++++++++ Tests/Contracts/Trilinos-10-6/RunTest.cmake | 5 ++- .../Trilinos-10-6/ValidateBuild.cmake | 4 -- .../Trilinos-10-6/ValidateBuild.cmake.in | 39 +++++++++++++++++++ 6 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 Tests/Contracts/Trilinos-10-6/Patch.cmake delete mode 100644 Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake create mode 100644 Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in diff --git a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt index 3e06d4f27..79ed669a2 100644 --- a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt +++ b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt @@ -61,6 +61,11 @@ configure_file( "${script_dir}/Dashboard.cmake" @ONLY) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/ValidateBuild.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" + @ONLY) + # Source dir for this project exists outside the CMake build tree because it # is absolutely huge. Source dir is therefore cached under a '.cmake/Contracts' # dir in your HOME directory. Downloads are cached under '.cmake/Downloads' @@ -82,6 +87,7 @@ else() URL "${url}" URL_MD5 "${md5}" SOURCE_DIR "${source_dir}" + PATCH_COMMAND ${CMAKE_COMMAND} -Dsource_dir=${source_dir} -P "${CMAKE_CURRENT_SOURCE_DIR}/Patch.cmake" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in index 1209dc87e..cc2950232 100644 --- a/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in +++ b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in @@ -56,7 +56,8 @@ execute_process(COMMAND ) if(NOT "${rv}" STREQUAL "0") - message(FATAL_ERROR "error(s) running Trilinos dashboard script experimental_build_test.cmake + message("error(s) (or warnings or test failures) running Trilinos dashboard +script experimental_build_test.cmake... ctest returned rv='${rv}' ") endif() diff --git a/Tests/Contracts/Trilinos-10-6/Patch.cmake b/Tests/Contracts/Trilinos-10-6/Patch.cmake new file mode 100644 index 000000000..a7aae2724 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/Patch.cmake @@ -0,0 +1,20 @@ +if(NOT DEFINED source_dir) + message(FATAL_ERROR "variable 'source_dir' not defined") +endif() + +if(NOT EXISTS "${source_dir}/CMakeLists.txt") + message(FATAL_ERROR "error: No CMakeLists.txt file to patch!") +endif() + +set(text " + +# +# Reference variables typically given as experimental_build_test configure +# options to avoid CMake warnings about unused variables +# + +MESSAGE(\"Trilinos_ALLOW_NO_PACKAGES='\${Trilinos_ALLOW_NO_PACKAGES}'\") +MESSAGE(\"Trilinos_WARNINGS_AS_ERRORS_FLAGS='\${Trilinos_WARNINGS_AS_ERRORS_FLAGS}'\") +") + +file(APPEND "${source_dir}/CMakeLists.txt" "${text}") diff --git a/Tests/Contracts/Trilinos-10-6/RunTest.cmake b/Tests/Contracts/Trilinos-10-6/RunTest.cmake index 93c1505ed..30124d8e9 100644 --- a/Tests/Contracts/Trilinos-10-6/RunTest.cmake +++ b/Tests/Contracts/Trilinos-10-6/RunTest.cmake @@ -1,4 +1,7 @@ -get_filename_component(dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +# ValidateBuild.cmake is configured into this location when the test is built: +set(dir "${CMAKE_CURRENT_BINARY_DIR}/Contracts/${project}") + set(exe "${CMAKE_COMMAND}") set(args -P "${dir}/ValidateBuild.cmake") + set(Trilinos-10-6_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake deleted file mode 100644 index 6942b09ef..000000000 --- a/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake +++ /dev/null @@ -1,4 +0,0 @@ -# TODO: put some actual code here to validate that the Trilinos build was -# "successful enough" -# -message(STATUS "Trilinos-10-6 build validated") diff --git a/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in new file mode 100644 index 000000000..04bbf214e --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in @@ -0,0 +1,39 @@ +# +# This code validates that the Trilinos build was "successful enough" (since it +# is difficult to detect this from the caller of the experimental_build_test +# dashboard script...) +# +set(binary_dir "@binary_dir@") +message("binary_dir='${binary_dir}'") + + +# Count *.exe files: +# +file(GLOB_RECURSE exes "${binary_dir}/*.exe") +message(STATUS "exes='${exes}'") +list(LENGTH exes len) +if(len LESS 47) + message(FATAL_ERROR "len='${len}' is less than minimum expected='47' (count of executables)") +endif() +message(STATUS "Found len='${len}' *.exe files") + + +# Try to find the Teuchos unit tests executable: +# +file(GLOB_RECURSE exe "${binary_dir}/Teuchos_UnitTest_UnitTests.exe") +list(LENGTH exe len) +if(NOT len EQUAL 1) + message(FATAL_ERROR "len='${len}' is not the expected='1' (count of Teuchos_UnitTest_UnitTests.exe)") +endif() +message(STATUS "Found exe='${exe}'") + + +# Try to run it: +execute_process(COMMAND ${exe} RESULT_VARIABLE rv) +if(NOT "${rv}" STREQUAL "0") + message(FATAL_ERROR "rv='${rv}' is not the expected='0' (result of running Teuchos_UnitTest_UnitTests.exe)") +endif() +message(STATUS "Ran exe='${exe}' rv='${rv}'") + + +message(STATUS "All Trilinos build validation tests pass.")