diff options
Diffstat (limited to 'Tests')
72 files changed, 1410 insertions, 200 deletions
diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt new file mode 100644 index 0000000..bc767fe --- /dev/null +++ b/Tests/Architecture/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8) +project(Architecture C) + +add_library(foo foo.c) +if(CMAKE_OSX_ARCHITECTURES) + get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES) + if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${archs}") + message(FATAL_ERROR + "OSX_ARCHITECTURES property not initialized by CMAKE_OSX_ARCHITECTURES.\n" + "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]." + ) + endif() +endif() +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc) + +add_executable(bar bar.c) +target_link_libraries(bar foo) +set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ppc) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG i386) diff --git a/Tests/Architecture/bar.c b/Tests/Architecture/bar.c new file mode 100644 index 0000000..923c89c --- /dev/null +++ b/Tests/Architecture/bar.c @@ -0,0 +1,2 @@ +extern int foo(void); +int main() { return foo(); } diff --git a/Tests/Architecture/foo.c b/Tests/Architecture/foo.c new file mode 100644 index 0000000..e35694b --- /dev/null +++ b/Tests/Architecture/foo.c @@ -0,0 +1 @@ +int foo(void) { return 0; } diff --git a/Tests/CMakeCommands/build_command/CMakeLists.txt b/Tests/CMakeCommands/build_command/CMakeLists.txt new file mode 100644 index 0000000..990ac90 --- /dev/null +++ b/Tests/CMakeCommands/build_command/CMakeLists.txt @@ -0,0 +1,58 @@ +# This CMakeLists file is *sometimes expected* to result in a configure error. +# +# expect this to succeed: +# ../bin/Release/cmake -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# expect this to fail: +# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# This project exists merely to test the CMake command 'build_command'... +# ...even purposefully calling it with known-bad argument lists to cover +# error handling code. +# +cmake_minimum_required(VERSION 2.8) +project(test_build_command) + +set(cmd "initial") + +message("CTEST_FULL_OUTPUT") +message("0. begin") + +if(TEST_ERROR_CONDITIONS) + # Test with no arguments (an error): + build_command() + message("1. cmd='${cmd}'") + + # Test with unknown arguments (also an error): + build_command(cmd BOGUS STUFF) + message("2. cmd='${cmd}'") + + build_command(cmd STUFF BOGUS) + message("3. cmd='${cmd}'") +else() + message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)") +endif() + +# Test the one arg signature with none of the optional KEYWORD arguments: +build_command(cmd) +message("4. cmd='${cmd}'") + +# Test the two-arg legacy signature: +build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) +message("5. legacy_cmd='${legacy_cmd}'") +message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") + +# Test the optional KEYWORDs: +build_command(cmd CONFIGURATION hoohaaConfig) +message("6. cmd='${cmd}'") + +build_command(cmd PROJECT_NAME hoohaaProject) +message("7. cmd='${cmd}'") + +build_command(cmd TARGET hoohaaTarget) +message("8. cmd='${cmd}'") + +set(cmd "final") +message("9. cmd='${cmd}'") diff --git a/Tests/CMakeCommands/build_command/RunCMake.cmake b/Tests/CMakeCommands/build_command/RunCMake.cmake new file mode 100644 index 0000000..55d9359 --- /dev/null +++ b/Tests/CMakeCommands/build_command/RunCMake.cmake @@ -0,0 +1,86 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +# Run cmake: +# +function(run_cmake build_dir extra_args expected_result expected_output expected_error) + message(STATUS "run_cmake build_dir='${build_dir}' extra_args='${extra_args}'") + + # Ensure build_dir exists: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}) + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} + ${extra_args} + -G ${gen} ${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${build_dir} + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") + + # Verify result and output match expectations: + # + if("0" STREQUAL "${expected_result}") + if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is non-zero and different than expected_result='${expected_result}'") + endif() + else() + if("${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is zero and different than expected_result='${expected_result}'") + endif() + endif() + + foreach(e ${expected_output}) + if(NOT stdout MATCHES "${e}") + message(FATAL_ERROR + "error: stdout does not match expected_output item e='${e}'") + else() + message(STATUS "info: stdout matches '${e}'") + endif() + endforeach() + + foreach(e ${expected_error}) + if(NOT stderr MATCHES "${e}") + message(FATAL_ERROR + "error: stderr does not match expected_error item e='${e}'") + else() + message(STATUS "info: stderr matches '${e}'") + endif() + endforeach() + + message(STATUS "result, stdout and stderr match all expectations: test passes") + message(STATUS "") +endfunction() + + +# Expect this case to succeed: +run_cmake("${dir}/b1" "" 0 + "Build files have been written to:" + "skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF") + + +# Expect this one to fail: +run_cmake("${dir}/b2" "-DTEST_ERROR_CONDITIONS:BOOL=ON" 1 + "Configuring incomplete, errors occurred!" + "build_command requires at least one argument naming a CMake variable;build_command unknown argument ") diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake new file mode 100644 index 0000000..f141b53 --- /dev/null +++ b/Tests/CMakeInstall.cmake @@ -0,0 +1,48 @@ +# Define option CMake_TEST_INSTALL, and enable by default for dashboards. +set(_default 0) +if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) + set(_default 1) +endif() +option(CMake_TEST_INSTALL "Test CMake Installation" ${_default}) +mark_as_advanced(CMake_TEST_INSTALL) + +if(CMake_TEST_INSTALL) + # Do not build during the test. + set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) + + # Install to a test directory. + set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall) + set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}") + + if(CMAKE_CONFIGURATION_TYPES) + # There are multiple configurations. Make sure the tested + # configuration is the one that is installed. + set(CMake_TEST_INSTALL_CONFIG -C "\${CTEST_CONFIGURATION_TYPE}") + else() + set(CMake_TEST_INSTALL_CONFIG) + endif() + + # The CTest of the CMake used to build this CMake. + if(CMAKE_CTEST_COMMAND) + set(CMake_TEST_INSTALL_CTest ${CMAKE_CTEST_COMMAND}) + else() + set(CMake_TEST_INSTALL_CTest ${CMake_BIN_DIR}/ctest) + endif() + + # Add a test to install CMake through the build system install target. + add_test(CMake.Install + ${CMake_TEST_INSTALL_CTest} + ${CMake_TEST_INSTALL_CONFIG} + --build-and-test ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR + --build-project CMake + --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM + --build-nocmake + --build-noclean + --build-target install) + + # TODO: Make all other tests depend on this one, and then drive them + # with the installed CTest. +else() + set(CMake_TEST_INSTALL_PREFIX) +endif() diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt new file mode 100644 index 0000000..bda2fa5 --- /dev/null +++ b/Tests/CMakeLib/CMakeLists.txt @@ -0,0 +1,32 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMake_BINARY_DIR}/Source + ${CMake_SOURCE_DIR}/Source + ) + +set(CMakeLib_TESTS + testUTF8 + testXMLParser + testXMLSafe + ) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in + ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY) + +create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) +add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) +target_link_libraries(CMakeLibTests CMakeLib) + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE + AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command( + TARGET CMakeLibTests + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() + +foreach(test ${CMakeLib_TESTS}) + add_test(CMakeLib.${test} CMakeLibTests ${test}) +endforeach() diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx new file mode 100644 index 0000000..4ab96cf --- /dev/null +++ b/Tests/CMakeLib/testUTF8.cxx @@ -0,0 +1,125 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include <cm_utf8.h> + +#include <string.h> +#include <stdio.h> + +typedef char test_utf8_char[5]; + +static void test_utf8_char_print(test_utf8_char const c) +{ + unsigned char const* d = reinterpret_cast<unsigned char const*>(c); + printf("[0x%02X,0x%02X,0x%02X,0x%02X]", + (int)d[0], (int)d[1], (int)d[2], (int)d[3]); +} + +struct test_utf8_entry +{ + int n; + test_utf8_char str; + unsigned int chr; +}; + +static test_utf8_entry const good_entry[] = { + {1, "\x20\x00\x00\x00", 0x0020}, /* Space. */ + {2, "\xC2\xA9\x00\x00", 0x00A9}, /* Copyright. */ + {3, "\xE2\x80\x98\x00", 0x2018}, /* Open-single-quote. */ + {3, "\xE2\x80\x99\x00", 0x2019}, /* Close-single-quote. */ + {4, "\xF0\xA3\x8E\xB4", 0x233B4}, /* Example from RFC 3629. */ + {0, {0,0,0,0,0}, 0} +}; + +static test_utf8_char const bad_chars[] = { + "\x80\x00\x00\x00", + "\xC0\x00\x00\x00", + "\xE0\x00\x00\x00", + "\xE0\x80\x80\x00", + "\xF0\x80\x80\x80", + {0,0,0,0,0} +}; + +static void report_good(bool passed, test_utf8_char const c) +{ + printf("%s: decoding good ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" (%s) ", c); +} + +static void report_bad(bool passed, test_utf8_char const c) +{ + printf("%s: decoding bad ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" "); +} + +static bool decode_good(test_utf8_entry const entry) +{ + unsigned int uc; + if(const char* e = cm_utf8_decode_character(entry.str, entry.str+4, &uc)) + { + int used = static_cast<int>(e-entry.str); + if(uc != entry.chr) + { + report_good(false, entry.str); + printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc); + return false; + } + if(used != entry.n) + { + report_good(false, entry.str); + printf("had %d bytes, used %d\n", entry.n, used); + return false; + } + report_good(true, entry.str); + printf("got 0x%04X\n", uc); + return true; + } + report_good(false, entry.str); + printf("failed\n"); + return false; +} + +static bool decode_bad(test_utf8_char const s) +{ + unsigned int uc = 0xFFFFu; + const char* e = cm_utf8_decode_character(s, s+4, &uc); + if(e) + { + report_bad(false, s); + printf("expected failure, got 0x%04X\n", uc); + return false; + } + report_bad(true, s); + printf("failed as expected\n"); + return true; +} + +int testUTF8(int, char*[]) +{ + int result = 0; + for(test_utf8_entry const* e = good_entry; e->n; ++e) + { + if(!decode_good(*e)) + { + result = 1; + } + } + for(test_utf8_char const* c = bad_chars; (*c)[0]; ++c) + { + if(!decode_bad(*c)) + { + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx new file mode 100644 index 0000000..54ed5dc --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.cxx @@ -0,0 +1,17 @@ +#include "testXMLParser.h" + +#include "cmXMLParser.h" + +#include <cmsys/ios/iostream> + +int testXMLParser(int, char*[]) +{ + // TODO: Derive from parser and check attributes. + cmXMLParser parser; + if(!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) + { + cmsys_ios::cerr << "cmXMLParser failed!" << cmsys_ios::endl; + return 1; + } + return 0; +} diff --git a/Tests/CMakeLib/testXMLParser.h.in b/Tests/CMakeLib/testXMLParser.h.in new file mode 100644 index 0000000..da0b275 --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.h.in @@ -0,0 +1,6 @@ +#ifndef testXMLParser_h +#define testXMLParser_h + +#define SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@" + +#endif diff --git a/Tests/CMakeLib/testXMLParser.xml b/Tests/CMakeLib/testXMLParser.xml new file mode 100644 index 0000000..5a13f07 --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Document> + <Element attr="1"/> +</Document> diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx new file mode 100644 index 0000000..60442fa --- /dev/null +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include <cmXMLSafe.h> + +#include "cmStandardIncludes.h" + +struct test_pair +{ + const char* in; + const char* out; +}; + +static test_pair const pairs[] = { + {"copyright \xC2\xA9", "copyright \xC2\xA9"}, + {"form-feed \f", "form-feed [NON-XML-CHAR-0xC]"}, + {"angles <>", "angles <>"}, + {"ampersand &", "ampersand &"}, + {"bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]"}, + {0,0} +}; + +int testXMLSafe(int, char*[]) +{ + int result = 0; + for(test_pair const* p = pairs; p->in; ++p) + { + cmXMLSafe xs(p->in); + cmOStringStream oss; + oss << xs; + std::string out = oss.str(); + if(out != p->out) + { + printf("expected [%s], got [%s]\n", p->out, out.c_str()); + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6fbe57d..7defb28 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,27 +1,42 @@ # a macro for tests that have a simple format where the name matches the # directory and project MACRO(ADD_TEST_MACRO NAME COMMAND) + STRING(REPLACE "." "/" dir "${NAME}") + STRING(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") ADD_TEST(${NAME} ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/${NAME}" - "${CMake_BINARY_DIR}/Tests/${NAME}" + "${CMake_SOURCE_DIR}/Tests/${dir}" + "${CMake_BINARY_DIR}/Tests/${dir}" --build-two-config --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project ${NAME} + --build-project ${proj} --test-command ${COMMAND}) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${NAME}") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) -# Make sure the 'testing' test gets a proper configuration. +# Fake a user home directory to avoid polluting the real one. +IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) + SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") + FILE(MAKE_DIRECTORY "${TEST_HOME}") + FILE(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") + SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. +SET(ENV{HOME} \"${TEST_HOME}\")") +ENDIF() + +# Choose a default configuration for CTest tests. +SET(CTestTest_CONFIG Debug) +IF(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + SET(CTestTest_CONFIG ${CMAKE_BUILD_TYPE}) +ENDIF() + CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY) -SET_DIRECTORY_PROPERTIES(PROPERTIES - TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake" - ) # Testing IF(BUILD_TESTING) + ADD_SUBDIRECTORY(CMakeLib) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) @@ -77,7 +92,8 @@ IF(BUILD_TESTING) "Should the tests that use '--build-target package' be run?" ON) MARK_AS_ADVANCED(CTEST_TEST_CPACK) - IF(APPLE AND CTEST_TEST_CPACK) + SET(CTEST_TEST_OSX_ARCH 0) + IF(APPLE) EXECUTE_PROCESS( COMMAND sw_vers -productVersion OUTPUT_VARIABLE OSX_VERSION @@ -87,8 +103,10 @@ IF(BUILD_TESTING) MESSAGE(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4") MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") SET(CTEST_TEST_CPACK OFF) + ELSE(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + SET(CTEST_TEST_OSX_ARCH 1) ENDIF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") - ENDIF(APPLE AND CTEST_TEST_CPACK) + ENDIF(APPLE) # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, # whichever is greater. @@ -114,10 +132,12 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) + ADD_TEST_MACRO(OutDir runtime/OutDir) ADD_TEST_MACRO(NewlineArgs NewlineArgs) ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) ADD_TEST_MACRO(LoadCommand LoadedCommand) + ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) ADD_TEST_MACRO(LinkLanguage LinkLanguage) ADD_TEST_MACRO(LinkLine LinkLine) ADD_TEST_MACRO(MacroTest miniMacroTest) @@ -130,9 +150,19 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) + ADD_TEST_MACRO(CrossCompile CrossCompile) + SET_TESTS_PROPERTIES(CrossCompile PROPERTIES + PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") IF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") ADD_TEST_MACRO(Policy0002 Policy0002) ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + IF(CTEST_TEST_OSX_ARCH) + ADD_TEST_MACRO(Architecture Architecture) + SET_TESTS_PROPERTIES(Architecture PROPERTIES + PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype)") + ENDIF(CTEST_TEST_OSX_ARCH) + + LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") @@ -140,6 +170,9 @@ IF(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY) ADD_TEST(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake") + LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) + + ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) # If we are running right now with a UnixMakefiles based generator, # build the "Simple" test with the ExtraGenerators, if available @@ -393,6 +426,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel --build-two-config --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" + "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall") ADD_TEST(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} @@ -1151,7 +1185,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ) SET_TESTS_PROPERTIES(CTestTestNoBuild PROPERTIES FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true) - + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" @@ -1164,6 +1198,50 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel PASS_REGULAR_EXPRESSION "Could not find executable" FAIL_REGULAR_EXPRESSION "SegFault") + + # Use macro, not function so that build can still be driven by CMake 2.4. + # After 2.6 is required, this could be a function without the extra 'set' + # calls. + # + macro(add_config_tests cfg) + set(cfg "${cfg}") + set(base "${CMake_BINARY_DIR}/Tests/CTestConfig") + + # Test -S script with a -C config arg to ctest: + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in" + "${base}/${cfg}-script.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND} + -C ${cfg} + -S "${base}/${cfg}-script.cmake" -VV + --output-log "${base}/${cfg}-script.log" + ) + + # Test -D dashboard with a -C config arg to ctest. + # (Actual commands inside a cmake -P script because we need to be able to set + # the working directory reliably...) + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in" + "${base}/${cfg}-dashboard.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND} + -P "${base}/${cfg}-dashboard.cmake" -VV + ) + endmacro() + + add_config_tests(Debug) + add_config_tests(MinSizeRel) + add_config_tests(Release) + add_config_tests(RelWithDebInfo) + + add_test(CMakeCommands.build_command ${CMAKE_CMAKE_COMMAND} + -DCMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -Ddir=${CMake_BINARY_DIR}/Tests/CMakeCommands/build_command + -Dgen=${CMAKE_TEST_GENERATOR} + -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" + ) + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" @@ -1182,6 +1260,23 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ENDIF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestBadExe ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log" + ) + SET(CTestTestBadExe_REGEX "BAD_COMMAND") + # cygwin can not be made to produce a BAD_COMMAND error + # the best we can get from it is a failed test + IF(CYGWIN) + SET(CTestTestBadExe_REGEX "\\*\\*\\*Failed") + ENDIF() + SET_TESTS_PROPERTIES(CTestTestBadExe PROPERTIES + PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}") + + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" @ONLY ESCAPE_QUOTES) @@ -1207,11 +1302,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" @ONLY ESCAPE_QUOTES) ADD_TEST(CTestTestTimeout ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log" ) SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES - PASS_REGULAR_EXPRESSION "\\*\\*\\*Timeout") + PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in" @@ -1225,11 +1321,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log" ) - + ADD_TEST(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N) - + ADD_TEST(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B) - + # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' # calls. @@ -1249,6 +1345,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel set(regex "${regex}|Error message was: ") set(regex "${regex}([Cc]ould *n.t resolve host") set(regex "${regex}|[Cc]ould *n.t connect to host") + set(regex "${regex}|The requested URL returned error") set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)") set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest") set(regex "${regex}|Submission successful)") @@ -1380,23 +1477,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel GET_TEST_PROPERTY(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) IF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) SET_TESTS_PROPERTIES ( BootstrapTest - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + PROPERTIES TIMEOUT 5400) ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF(UNIX AND CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST) # fortran does not work for IDE builds because # CMAKE_STANDARD_LIBRARIES needs to be per language - IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" - OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") - # see if we can find a fortran compiler on the machine - # if so, add the fortran test and see if it works. - SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95 - lf95 xlf95 fort gfortran gfortran-4 f90 pgf90 xlf90 - epcf90 f77 fort77 frt pgf77 xlf fl32 af77 g77 ) - FIND_PROGRAM(CMAKE_Fortran_COMPILER_FULLPATH NAMES - ${CMAKE_Fortran_COMPILER_LIST} ) - MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER_FULLPATH) - IF(CMAKE_Fortran_COMPILER_FULLPATH) + IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + IF(CMAKE_Fortran_COMPILER) ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Fortran" @@ -1407,9 +1496,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel --build-two-config --test-command testf) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") - ENDIF(CMAKE_Fortran_COMPILER_FULLPATH) - ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" - OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ENDIF() + ENDIF() + ENDIF() IF(NOT CMAKE_TEST_GENERATOR MATCHES "Xcode") INCLUDE(FindJava) @@ -1492,6 +1589,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ENDIF(PREFIX_IS_FOR_TEST) ENDIF(UNIX) + IF(CMAKE_TEST_PROJECT_CSE_DIR) + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake") + IF(NOT EXISTS "${script}") + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake") + ENDIF(NOT EXISTS "${script}") + IF(NOT EXISTS "${script}") + MESSAGE("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...") + ENDIF(NOT EXISTS "${script}") + + ADD_TEST(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}") + SET_TESTS_PROPERTIES(BuildCSE PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_PROJECT_CSE_DIR) + IF(CMAKE_TEST_PLPLOT_DIR) ADD_TEST(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake ) SET_TESTS_PROPERTIES ( plplot PROPERTIES TIMEOUT 5400) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index adaf247..161ca44 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -1,4 +1,4 @@ -SET(CMAKE_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/cmake") +SET(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") MACRO(AddCMakeTest TestName PreArgs) @@ -50,6 +50,7 @@ if(do_cvs_tests) "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" "-DCVS_EXECUTABLE:STRING=${CVS_EXECUTABLE}" + "-DHOME:STRING=$ENV{HOME}" ) AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") endif(do_cvs_tests) diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index fab5662..1cfadcb 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -6,8 +6,10 @@ message("") message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") +message("HOME='${HOME}'") message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") message("") +string(REPLACE "\\" "\\\\" HOME "${HOME}") # Is the build directory the same as or underneath the source directory? @@ -40,6 +42,16 @@ message("in_source_build='${in_source_build}'") message("") +# If this does not appear to be a CVS checkout, just pass the test here and now. +# (Do not let the test fail if it is run in a tree *exported* from CVS or +# unpacked from a .zip file source installer...) +# +if(NOT EXISTS "${CMake_SOURCE_DIR}/CVS/Root") + message("source tree is not a CVS checkout... test passes by early return...") + return() +endif() + + # Check with "cvs -q -n up -dP" if there are any local modifications to the # CMake source tree: # @@ -47,18 +59,31 @@ message("======================================================================= message("Copy/paste this command to reproduce:") message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") message("") + +# Use the HOME value passed in to the script for calling cvs so it can find +# its .cvspass and other file(s) +# +set(original_ENV_HOME "$ENV{HOME}") +set(ENV{HOME} "${HOME}") + execute_process(COMMAND ${CVS_EXECUTABLE} -q -n up -dP WORKING_DIRECTORY ${CMake_SOURCE_DIR} OUTPUT_VARIABLE ov ERROR_VARIABLE ev RESULT_VARIABLE rv) +set(ENV{HOME} "${original_ENV_HOME}") + message("Results of running '${CVS_EXECUTABLE} -q -n up -dP'") message("rv='${rv}'") message("ov='${ov}'") message("ev='${ev}'") message("") +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error: 'cvs -q -n up -dP' attempt failed... (see output above)") +endif() + # Analyze cvs output: # set(additions 0) diff --git a/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in index c795512..7adc240 100644 --- a/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in +++ b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in @@ -13,6 +13,21 @@ if(NOT nonexistent2 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE") endif() # +# Test treatment of relative paths +# +foreach(c REALPATH ABSOLUTE) + get_filename_component(dir "subdir/THIS_IS_A_NONEXISTENT_FILE" ${c}) + if(NOT "${dir}" STREQUAL "${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE") + message(FATAL_ERROR + "${c} does not handle relative paths. Expected:\n" + " ${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE\n" + "but got:\n" + " ${nonexistent1}\n" + ) + endif() +endforeach() + +# # Test symbolic link resolution # if(UNIX) diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt new file mode 100644 index 0000000..f46d89a --- /dev/null +++ b/Tests/CTestConfig/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestConfig) + +include(CTest) + + +# We expect this configure to occur through a 'ctest -D Experimental' or a +# 'ctest -S script.cmake' call. +# +# In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration +# build trees and not defined for multi-configuration build trees. +# +if(CMAKE_CONFIGURATION_TYPES) + # multi-configuration: expect not defined, error if defined + if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)") + endif() +else() + # single-configuration: expect defined, error if not defined + if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)") + endif() +endif() + + +if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") +endif() + +add_executable(ctc CTestConfig.cxx) + + +foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) + add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>) + + if(CMAKE_CONFIGURATION_TYPES) + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is") + else() + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_INTDIR is") + endif() +endforeach() diff --git a/Tests/CTestConfig/CTestConfig.cxx b/Tests/CTestConfig/CTestConfig.cxx new file mode 100644 index 0000000..49c5324 --- /dev/null +++ b/Tests/CTestConfig/CTestConfig.cxx @@ -0,0 +1,20 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + int i = 0; + for (; i<argc; ++i) + { + fprintf(stdout, "%s\n", argv[i]); + } + +#ifdef CMAKE_BUILD_TYPE + fprintf(stdout, "CMAKE_BUILD_TYPE is %s\n", CMAKE_BUILD_TYPE); +#endif + +#ifdef CMAKE_INTDIR + fprintf(stdout, "CMAKE_INTDIR is %s\n", CMAKE_INTDIR); +#endif + + return 0; +} diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in new file mode 100644 index 0000000..c7ac210 --- /dev/null +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -0,0 +1,43 @@ +set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard") + +file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + +get_filename_component(dir "${CMAKE_COMMAND}" PATH) +set(CMAKE_CTEST_COMMAND "${dir}/ctest") + +message("CMAKE_COMMAND='${CMAKE_COMMAND}'") +message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") + +set(arg "") +if(NOT CMAKE_CONFIGURATION_TYPES) + set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") +endif() + +message("cmake initial configure") +execute_process(COMMAND ${CMAKE_COMMAND} + ${arg} -G "@CMAKE_TEST_GENERATOR@" ${CTEST_SOURCE_DIRECTORY} + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling cmake: rv='${rv}'") +endif() + + +function(call_ctest arg) + message("call_ctest ${arg}") + execute_process(COMMAND ${CMAKE_CTEST_COMMAND} + -C "@cfg@" -D ${arg} -VV + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) + if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling ctest: rv='${rv}'") + endif() +endfunction() + + +call_ctest(ExperimentalStart) +call_ctest(ExperimentalConfigure) +call_ctest(ExperimentalBuild) +call_ctest(ExperimentalTest) diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in new file mode 100644 index 0000000..5ceb7c3 --- /dev/null +++ b/Tests/CTestConfig/script.cmake.in @@ -0,0 +1,21 @@ +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_PROJECT_NAME "CTestConfig") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") + +ctest_start(Experimental) + +ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_configure ***") +endif() + +ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_build ***") +endif() + +ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_test ***") +endif() diff --git a/Tests/CTestTest/CMakeLists.txt b/Tests/CTestTest/CMakeLists.txt deleted file mode 100644 index 7d87612..0000000 --- a/Tests/CTestTest/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -PROJECT(CTestTest) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") - -CONFIGURE_FILE(${CTestTest_SOURCE_DIR}/test.cmake.in - ${CTestTest_BINARY_DIR}/test.cmake @ONLY) diff --git a/Tests/CTestTest2/CMakeLists.txt b/Tests/CTestTest2/CMakeLists.txt deleted file mode 100644 index ec793c4..0000000 --- a/Tests/CTestTest2/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -PROJECT(CTestTest2) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") - - -CONFIGURE_FILE(${CTestTest2_SOURCE_DIR}/test.cmake.in - ${CTestTest2_BINARY_DIR}/test.cmake @ONLY) diff --git a/Tests/CTestTest3/test.cmake.in b/Tests/CTestTest3/test.cmake.in index 734bdf4..d0a1f88 100644 --- a/Tests/CTestTest3/test.cmake.in +++ b/Tests/CTestTest3/test.cmake.in @@ -50,7 +50,7 @@ CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_SUBMIT(RETURN_VALUE res) @@ -97,7 +97,7 @@ IF(svncommand) CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) + CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_SUBMIT(RETURN_VALUE res) diff --git a/Tests/CTestTestBadExe/CMakeLists.txt b/Tests/CTestTestBadExe/CMakeLists.txt new file mode 100644 index 0000000..8a925b6 --- /dev/null +++ b/Tests/CTestTestBadExe/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestBadExe) +INCLUDE(CTest) + +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/notAnExe.txt" "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt" COPYONLY) + +ADD_TEST (TestBadExe "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt") diff --git a/Tests/CTestTestBadExe/CTestConfig.cmake b/Tests/CTestTestBadExe/CTestConfig.cmake new file mode 100644 index 0000000..1d46ea3 --- /dev/null +++ b/Tests/CTestTestBadExe/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestBadExe") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestBadExe/notAnExe.txt b/Tests/CTestTestBadExe/notAnExe.txt new file mode 100644 index 0000000..f2a0aa4 --- /dev/null +++ b/Tests/CTestTestBadExe/notAnExe.txt @@ -0,0 +1 @@ +This is not an executable file. diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in new file mode 100644 index 0000000..743e835 --- /dev/null +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -0,0 +1,24 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-BadExe") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestCrash/CMakeLists.txt b/Tests/CTestTestCrash/CMakeLists.txt index 5c8cc0b..0ac6ba0 100644 --- a/Tests/CTestTestCrash/CMakeLists.txt +++ b/Tests/CTestTestCrash/CMakeLists.txt @@ -1,19 +1,7 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestCrash) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (Crash crash.cxx) -TARGET_LINK_LIBRARIES (NoBuild ${EXTRA_LIBS}) - -ENABLE_TESTING () ADD_TEST (TestCrash Crash) - -INCLUDE (CTest) - diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 794b8ff..259c8659 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,13 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailedSubmits/test.cmake.in b/Tests/CTestTestFailedSubmits/test.cmake.in index 42bc79c..9b581eb 100644 --- a/Tests/CTestTestFailedSubmits/test.cmake.in +++ b/Tests/CTestTestFailedSubmits/test.cmake.in @@ -45,3 +45,7 @@ CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" @ctest_coverage_labels_args@ RE # ok to call ctest_submit - still avoids network activity because there is # not a valid drop location given above... CTEST_SUBMIT(RETURN_VALUE res) + +# Add coverage for the new APPEND arg to ctest_start: +# +CTEST_START(Experimental APPEND) diff --git a/Tests/CTestTestFailure/CMakeLists.txt b/Tests/CTestTestFailure/CMakeLists.txt index 62ce7c5..690fbfc 100644 --- a/Tests/CTestTestFailure/CMakeLists.txt +++ b/Tests/CTestTestFailure/CMakeLists.txt @@ -1,19 +1,8 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestFailure) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (NoBuild badCode.cxx) TARGET_LINK_LIBRARIES (NoBuild ${EXTRA_LIBS}) -ENABLE_TESTING () - ADD_TEST (TestNoExe NoBuild) - -INCLUDE (CTest) - diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 7870723..b0bb039 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,13 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) #CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 7c40f48..69d4f84 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,5 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestParallel/CMakeLists.txt b/Tests/CTestTestParallel/CMakeLists.txt index 1e57074..8fab44b 100644 --- a/Tests/CTestTestParallel/CMakeLists.txt +++ b/Tests/CTestTestParallel/CMakeLists.txt @@ -1,17 +1,9 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestParallel) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_EXECUTABLE (LockFile lockFile.c) -ENABLE_TESTING () - ADD_TEST (TestRunSerial1 LockFile) ADD_TEST (TestRunSerial2 LockFile) SET_TESTS_PROPERTIES(TestRunSerial1 TestRunSerial2 PROPERTIES RUN_SERIAL true) @@ -19,5 +11,3 @@ SET_TESTS_PROPERTIES(TestRunSerial1 TestRunSerial2 PROPERTIES RUN_SERIAL true) ADD_TEST (TestProcessorsGreaterThanMPL1 LockFile) ADD_TEST (TestProcessorsGreaterThanMPL2 LockFile) SET_TESTS_PROPERTIES(TestProcessorsGreaterThanMPL1 PROPERTIES PROCESSORS 10) - -INCLUDE (CTest) diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index aaa93fc..6ca15f6 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestSubdir/CMakeLists.txt b/Tests/CTestTestSubdir/CMakeLists.txt index 5daa543..5400ee8 100644 --- a/Tests/CTestTestSubdir/CMakeLists.txt +++ b/Tests/CTestTestSubdir/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CTestTestSubdir) - -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +INCLUDE(CTest) ADD_SUBDIRECTORY(subdir) SUBDIRS(subdir2) diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 299f86d..c8d4fda 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -20,12 +18,6 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ -") - CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestTimeout/CMakeLists.txt b/Tests/CTestTestTimeout/CMakeLists.txt index 15942c8..0fd1ceb 100644 --- a/Tests/CTestTestTimeout/CMakeLists.txt +++ b/Tests/CTestTestTimeout/CMakeLists.txt @@ -1,18 +1,28 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) PROJECT(CTestTestTimeout) +INCLUDE(CTest) -SET(DART_ROOT "" CACHE STRING "" FORCE) -ENABLE_TESTING() -INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) - -GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) -SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") +IF(NOT TIMEOUT) + IF(CYGWIN) + SET(TIMEOUT 4) # Cygwin CMake sometimes takes > 1 second to load! + ELSE() + SET(TIMEOUT 1) + ENDIF() +ENDIF() +ADD_DEFINITIONS(-DTIMEOUT=${TIMEOUT}) ADD_EXECUTABLE (Timeout timeout.c) -ENABLE_TESTING () - -ADD_TEST (TestTimeout Timeout) -SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT 1) +ADD_TEST(NAME TestTimeout + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake + ) +SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT}) -INCLUDE (CTest) +ADD_TEST(NAME CheckChild + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake + ) +SET_TESTS_PROPERTIES(CheckChild PROPERTIES DEPENDS TestTimeout) diff --git a/Tests/CTestTestTimeout/check.cmake b/Tests/CTestTestTimeout/check.cmake new file mode 100644 index 0000000..b16f2aa --- /dev/null +++ b/Tests/CTestTestTimeout/check.cmake @@ -0,0 +1,9 @@ +# Block just as long as timeout.cmake would if it were not killed. +execute_process(COMMAND ${Timeout}) + +# Verify that the log is empty, which indicates that the grandchild +# was killed before it finished sleeping. +file(READ "${Log}" LOG) +if(NOT "${LOG}" STREQUAL "") + message(FATAL_ERROR "${LOG}") +endif() diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 4582801..6ed11a4 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -8,8 +8,6 @@ SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout") SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout") SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") -SET(CMAKE_TEST_MAKEPROGRAM "@CMAKE_TEST_MAKEPROGRAM@") -SET(MAKECOMMAND "@MAKECOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") @@ -21,9 +19,7 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@ -CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@ -MAKECOMMAND:STRING=@MAKECOMMAND@ +TIMEOUT:STRING=@CTestTestTimeout_TIME@ ") CTEST_START(Experimental) diff --git a/Tests/CTestTestTimeout/timeout.c b/Tests/CTestTestTimeout/timeout.c index 559b6a5..370ab22 100644 --- a/Tests/CTestTestTimeout/timeout.c +++ b/Tests/CTestTestTimeout/timeout.c @@ -4,12 +4,15 @@ # include <unistd.h> #endif +#include <stdio.h> + int main(void) { #if defined(_WIN32) - Sleep(5000); + Sleep((TIMEOUT+4)*1000); #else - sleep(5); + sleep((TIMEOUT+4)); #endif + printf("timeout process finished sleeping!\n"); return -1; } diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake new file mode 100644 index 0000000..198cc97 --- /dev/null +++ b/Tests/CTestTestTimeout/timeout.cmake @@ -0,0 +1,6 @@ +# Remove the log file. +file(REMOVE ${Log}) + +# Run a child that sleeps longer than the timout of this test. +# Log its output so check.cmake can verify it dies. +execute_process(COMMAND ${Timeout} OUTPUT_FILE ${Log}) diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index 8ac0fa1..1509adf 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -5,6 +5,7 @@ # Test in a directory next to this script. get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) set(TOP "${TOP}/@CTestUpdateCVS_DIR@") +set(UPDATE_NOT_GLOBAL 1) # Include code common to all update tests. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index b680b8e..1f5941d 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -45,6 +45,25 @@ function(check_updates build) endif() endforeach(f) + if(NOT UPDATE_NOT_GLOBAL) + set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS}) + string(REPLACE ";" "|" rev_regex "${rev_elements}") + set(rev_regex "^\t<(${rev_regex})>[^<\n]+</(${rev_regex})>$") + file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS + REGEX "${rev_regex}" + LIMIT_INPUT 4096 + ) + foreach(r IN LISTS UPDATE_XML_REVISIONS) + string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") + set(element_${element} 1) + endforeach() + foreach(element ${rev_elements}) + if(NOT element_${element}) + list(APPEND MISSING "global <${element}> element") + endif() + endforeach() + endif() + # Report the result if(MISSING) # List the missing entries diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index 57d72fd..509597b 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -5,6 +5,7 @@ # Test in a directory next to this script. get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) set(TOP "${TOP}/@CTestUpdateSVN_DIR@") +set(UPDATE_GLOBAL_ELEMENTS SVNPath) # Include code common to all update tests. include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake new file mode 100644 index 0000000..8adcafc --- /dev/null +++ b/Tests/CheckFortran.cmake @@ -0,0 +1,50 @@ + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +if(NOT DEFINED CMAKE_Fortran_COMPILER) + set(_desc "Looking for a Fortran compiler") + message(STATUS ${_desc}) + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.4) +project(CheckFortran Fortran) +file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" + \"set(CMAKE_Fortran_COMPILER \\\"\${CMAKE_Fortran_COMPILER}\\\")\\n\" + \"set(CMAKE_Fortran_FLAGS \\\"\${CMAKE_Fortran_FLAGS}\\\")\\n\" + ) +") + execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran + COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + ) + include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/result.cmake OPTIONAL) + if(CMAKE_Fortran_COMPILER AND "${result}" STREQUAL "0") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${_desc} passed with the following output:\n" + "${output}\n") + else() + set(CMAKE_Fortran_COMPILER NOTFOUND) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${_desc} failed with the following output:\n" + "${output}\n") + endif() + message(STATUS "${_desc} - ${CMAKE_Fortran_COMPILER}") + set(CMAKE_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "Fortran compiler") + mark_as_advanced(CMAKE_Fortran_COMPILER) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" CACHE STRING "Fortran flags") + mark_as_advanced(CMAKE_Fortran_FLAGS) +endif() diff --git a/Tests/CommandLineTest/CMakeLists.txt b/Tests/CommandLineTest/CMakeLists.txt index e01a4c7..0493a0c 100644 --- a/Tests/CommandLineTest/CMakeLists.txt +++ b/Tests/CommandLineTest/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.6) PROJECT(CommandLineTest) GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH) -FIND_PROGRAM(DUMP_DOC_EXE NAMES DumpDocumentation PATHS ${CMAKE_BIN_DIR}) MACRO(EXEC_CMAKE_COMMAND CMAKE_ARGS) EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET) IF(${RET}) @@ -25,15 +24,6 @@ EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"") EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"") EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"") -IF(DUMP_DOC_EXE) - EXEC_PROGRAM(${DUMP_DOC_EXE} ARGS "--all-for-coverage \"${CMAKE_CURRENT_BINARY_DIR}/all_for_coverage.txt\"" RETURN_VALUE RET) - IF(${RET}) - MESSAGE(SEND_ERROR "DumpDoc command failed ") - ENDIF(${RET}) -ELSE(DUMP_DOC_EXE) - MESSAGE(SEND_ERROR "Cannot find DumpDocumentation executable.") -ENDIF(DUMP_DOC_EXE) - ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx) GET_FILENAME_COMPONENT(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH) diff --git a/Tests/CrossCompile/CMakeLists.txt b/Tests/CrossCompile/CMakeLists.txt new file mode 100644 index 0000000..96a57a0 --- /dev/null +++ b/Tests/CrossCompile/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CrossCompile) + +UNSET(run_result CACHE) + +#Simulate the cross compile condition +SET(CMAKE_CROSSCOMPILING ON) + +ADD_EXECUTABLE(CrossCompile main.c) + +TRY_RUN(run_result compile_result + ${CrossCompile_BINARY_DIR} + ${CrossCompile_SOURCE_DIR}/main.c) diff --git a/Tests/CrossCompile/main.c b/Tests/CrossCompile/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/CrossCompile/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index c10d2a3..c9028a3 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -1,17 +1,12 @@ -# Older versions of CMake do not support an empty configuration name in -# CTEST_CONFIGURATION_TYPE for the 'testing' test. -SET(CONFIG_REQUIRED) -IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - SET(CONFIG_REQUIRED 1) -ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL 2.6) - IF("${CMAKE_PATCH_VERSION}" LESS 3) - SET(CONFIG_REQUIRED 1) - ENDIF("${CMAKE_PATCH_VERSION}" LESS 3) - ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL 2.6) -ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) +# Choose a configuration with which to drive CTest tests. +IF(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "${CTEST_CONFIGURATION_TYPE}") +ELSE(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "@CTestTest_CONFIG@") +ENDIF(CTEST_CONFIGURATION_TYPE) -IF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) +# Choose a configuration that was built if none is given. +IF(NOT CTEST_CONFIGURATION_TYPE) SET(CTEST_CMD "@CMAKE_CTEST_COMMAND@@CMAKE_EXECUTABLE_SUFFIX@") GET_FILENAME_COMPONENT(CTEST_DIR "${CTEST_CMD}" PATH) GET_FILENAME_COMPONENT(CTEST_EXE "${CTEST_CMD}" NAME) @@ -26,4 +21,6 @@ IF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) SET(CTEST_CONFIGURATION_TYPE NoConfig) ENDIF(NOT CTEST_CONFIGURATION_TYPE) MESSAGE("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") -ENDIF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) +ENDIF(NOT CTEST_CONFIGURATION_TYPE) + +@TEST_HOME_ENV_CODE@ diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 48ca548..31cf0fc 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -40,6 +40,7 @@ SET(PACKAGES WrongA WrongB WrongC WrongD wibbleA wibbleB RecursiveA RecursiveB RecursiveC + EnvA EnvB ) FOREACH(p ${PACKAGES}) SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) @@ -96,6 +97,13 @@ FIND_PACKAGE(RecursiveA) FIND_PACKAGE(RecursiveB 2) FIND_PACKAGE(RecursiveC 3.1 EXACT) +# Test <Package>_DIR environment variable. +# We erase the main prefix path to ensure the env var is used. +SET(CMAKE_PREFIX_PATH) +SET(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1") +FIND_PACKAGE(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work +FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail + # Expected locations at which packages should be found. SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake") @@ -123,6 +131,8 @@ SET(wibbleB_EXPECTED "B/wibble-config.cmake") SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake") SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake") SET(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(EnvB_MISSING "EnvB_DIR-NOTFOUND") # Check the results. FOREACH(p ${PACKAGES}) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 709ea5f..04563ef 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -34,7 +34,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) @@ -171,13 +171,20 @@ if(TEST_MODULE_DEPENDS) set(External_CONFIG_TYPE) set(External_BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) endif(CMAKE_CONFIGURATION_TYPES) + set(External_SOURCE_DIR "${testf_SOURCE_DIR}/External") + set(External_BINARY_DIR "${testf_BINARY_DIR}/External") + if("${testf_BINARY_DIR}" MATCHES " ") + # Our build tree has a space, so the build tool supports spaces. + # Test using modules from a path with spaces. + set(External_BINARY_DIR "${External_BINARY_DIR} Build") + endif() add_custom_command( OUTPUT ${testf_BINARY_DIR}/ExternalProject COMMAND ${CMAKE_CTEST_COMMAND} ARGS ${External_CONFIG_TYPE} --build-and-test - ${testf_SOURCE_DIR}/External - ${testf_BINARY_DIR}/External + ${External_SOURCE_DIR} + ${External_BINARY_DIR} --build-noclean --build-two-config --build-project ExtFort diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt index 40114e4..55f21ad 100644 --- a/Tests/Fortran/Executable/CMakeLists.txt +++ b/Tests/Fortran/Executable/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${Library_MODDIR}) -include_directories(${testf_BINARY_DIR}/External) -link_directories(${testf_BINARY_DIR}/External) +include_directories(${External_BINARY_DIR}) +link_directories(${External_BINARY_DIR}) add_executable(subdir_exe2 main.f90) target_link_libraries(subdir_exe2 subdir_mods) diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt new file mode 100644 index 0000000..f335583 --- /dev/null +++ b/Tests/FortranC/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.8) +project(FortranC C Fortran) + +# Skip this test for compilers not known to be compatible. +if(NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_Fortran_COMPILER_ID}" OR + "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$")) + message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") + return() +endif() + +# Wipe out all FortranCInterface information to ensure it re-runs. +file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterface) + +if(FortranC_TEST_FLAGS) + # Test whether FortranCInterface checks see C flags. + set(ENV{TEST_OPT_CC} "--test-opt-cc=1") + set(CMAKE_C_FLAGS "$ENV{TEST_OPT_CC} ${CMAKE_C_FLAGS}") + + # Test whether FortranCInterface checks see Fortran flags. + set(ENV{TEST_OPT_FC} "--test-opt-fc=1") + set(CMAKE_Fortran_FLAGS "$ENV{TEST_OPT_FC} ${CMAKE_Fortran_FLAGS}") +endif() + +include(FortranCInterface) +FortranCInterface_VERIFY() diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in new file mode 100644 index 0000000..0b82f0e --- /dev/null +++ b/Tests/FortranC/Flags.cmake.in @@ -0,0 +1,28 @@ +set(src "@CMAKE_CURRENT_SOURCE_DIR@/FortranC") +set(bld "@CMAKE_CURRENT_BINARY_DIR@/FortranC/Flags") + +# Create wrapper scripts for the compilers that check for expected +# flags, remove them, and invoke the real compiler. +set(ID "CC") +set(COMMAND "@CMAKE_C_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/cc.sh" @ONLY) +set(ID "FC") +set(COMMAND "@CMAKE_Fortran_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY) +set(ID) +set(COMMAND) + +execute_process( + WORKING_DIRECTORY "${bld}" + COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@" + "-DFortranC_TEST_FLAGS=1" + "-DCMAKE_C_COMPILER=${bld}/cc.sh" + "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" + "-DCMAKE_Fortran_COMPILER=${bld}/fc.sh" + "-DCMAKE_Fortran_FLAGS:STRING=@CMAKE_Fortran_FLAGS@" + RESULT_VARIABLE result + ) + +if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR "Configuration failed: ${result}") +endif() diff --git a/Tests/FortranC/test_opt.sh.in b/Tests/FortranC/test_opt.sh.in new file mode 100755 index 0000000..f3d93dc --- /dev/null +++ b/Tests/FortranC/test_opt.sh.in @@ -0,0 +1,18 @@ +#!/bin/sh + +TEST_OPT_@ID@_FOUND=0 +ARGS="" +for a in "$@"; do + if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@}" = "x$a" ]; then + TEST_OPT_@ID@_FOUND=1 + else + ARGS="$ARGS \"$a\"" + fi +done + +if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@_FOUND}" != "x1" ]; then + echo "Not given option '${TEST_OPT_@ID@}' as expected!" + exit 1 +fi + +eval "\"@COMMAND@\"" "$ARGS" diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt new file mode 100644 index 0000000..7356b27 --- /dev/null +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectory C) + +# Put the subproject source tree in our build tree so it can refer to +# link directories relative to its source. +if(NOT "${LinkDirectory_SOURCE_DIR}" STREQUAL "${LinkDirectory_BINARY_DIR}") + file(COPY External/ DESTINATION External PATTERN CVS EXCLUDE) +endif() + +# Build a library into the subproject source tree. +add_library(mylibA STATIC mylibA.c) +set_property(TARGET mylibA PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/External/lib") +get_property(mylibA TARGET mylibA PROPERTY LOCATION) + +# Build a library into our build tree relative to the subproject build tree. +add_library(mylibB STATIC mylibB.c) +set_property(TARGET mylibB PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/lib") +get_property(mylibB TARGET mylibB PROPERTY LOCATION) + +# Create a custom target to drive the subproject build. +include(ExternalProject) +ExternalProject_Add(ExternalTarget + SOURCE_DIR "${LinkDirectory_BINARY_DIR}/External" + BINARY_DIR "${LinkDirectory_BINARY_DIR}/External-build" + CMAKE_ARGS "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${LinkDirectory_BINARY_DIR}/bin" + PREFIX "${LinkDirectory_BINARY_DIR}/External-build/root" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + ) + +# Add a step to wipe out the subproject executable after our libraries +# change. This is needed because the subproject cannot depend on them +# directly because it does not know the full paths to the libraries. +# (The purpose of this test is to check that link_directories works.) +ExternalProject_Add_Step(ExternalTarget cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin + DEPENDEES download + DEPENDERS configure + DEPENDS ${mylibA} ${mylibB} + "${LinkDirectory_BINARY_DIR}/External/CMakeLists.txt" + "${LinkDirectory_BINARY_DIR}/External/myexe.c" + ) + +# Make the subproject build after our targets. +add_dependencies(ExternalTarget mylibA mylibB) diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt new file mode 100644 index 0000000..f7c840f --- /dev/null +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectoryExternal C) + +# Test CMP0015 OLD behavior: -L../lib +cmake_policy(SET CMP0015 OLD) +link_directories(../lib) + +# Test CMP0015 NEW behavior: -L${CMAKE_CURRENT_SOURCE_DIR}/lib +cmake_policy(SET CMP0015 NEW) +link_directories(lib) + +add_executable(myexe myexe.c) +set_property(TARGET myexe PROPERTY OUTPUT_NAME LinkDirectory) +target_link_libraries(myexe mylibA mylibB) diff --git a/Tests/LinkDirectory/External/myexe.c b/Tests/LinkDirectory/External/myexe.c new file mode 100644 index 0000000..6ef1ebe --- /dev/null +++ b/Tests/LinkDirectory/External/myexe.c @@ -0,0 +1,3 @@ +extern int mylibA(void); +extern int mylibB(void); +int main(void) { return mylibA() + mylibB(); } diff --git a/Tests/LinkDirectory/mylibA.c b/Tests/LinkDirectory/mylibA.c new file mode 100644 index 0000000..890a089 --- /dev/null +++ b/Tests/LinkDirectory/mylibA.c @@ -0,0 +1 @@ +int mylibA(void) { return 0; } diff --git a/Tests/LinkDirectory/mylibB.c b/Tests/LinkDirectory/mylibB.c new file mode 100644 index 0000000..090cc6c --- /dev/null +++ b/Tests/LinkDirectory/mylibB.c @@ -0,0 +1 @@ +int mylibB(void) { return 0; } diff --git a/Tests/Module/CheckTypeSize/CMakeLists.txt b/Tests/Module/CheckTypeSize/CMakeLists.txt new file mode 100644 index 0000000..45e9f67 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.1 FATAL_ERROR) +project(CheckTypeSize C) + +include(CheckTypeSize) +check_type_size("void*" SIZEOF_DATA_PTR) +check_type_size(char SIZEOF_CHAR) +check_type_size(short SIZEOF_SHORT) +check_type_size(int SIZEOF_INT) +check_type_size(long SIZEOF_LONG) +check_type_size("long long" SIZEOF_LONG_LONG) +check_type_size(__int64 SIZEOF___INT64) +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t SIZEOF_SSIZE_T) + +configure_file(config.h.in config.h) +include_directories(${CheckTypeSize_BINARY_DIR}) + +add_executable(CheckTypeSize CheckTypeSize.c) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c new file mode 100644 index 0000000..602c834 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c @@ -0,0 +1,122 @@ +#include "config.h" + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_STDDEF_H +# include <stddef.h> +#endif + +#include <stdio.h> + +#define CHECK(t,m) do { \ + if(sizeof(t) != m) \ + { \ + printf(#m ": expected %d, got %d (line %d)\n", \ + (int)sizeof(t), (int)m, __LINE__); \ + result = 1; \ + } \ + } while(0) + +#define NODEF(m) do { \ + printf(#m": not defined (line %d)\n", __LINE__); \ + result = 1; \ + } while(0) + +int main() +{ + int result = 0; + + /* void* */ +#if !defined(HAVE_SIZEOF_DATA_PTR) + NODEF(HAVE_SIZEOF_DATA_PTR); +#endif +#if defined(SIZEOF_DATA_PTR) + CHECK(void*, SIZEOF_DATA_PTR); +#else + NODEF(SIZEOF_DATA_PTR); +#endif + + /* char */ +#if !defined(HAVE_SIZEOF_CHAR) + NODEF(HAVE_SIZEOF_CHAR); +#endif +#if defined(SIZEOF_CHAR) + CHECK(char, SIZEOF_CHAR); +#else + NODEF(SIZEOF_CHAR); +#endif + + /* short */ +#if !defined(HAVE_SIZEOF_SHORT) + NODEF(HAVE_SIZEOF_SHORT); +#endif +#if defined(SIZEOF_SHORT) + CHECK(short, SIZEOF_SHORT); +#else + NODEF(SIZEOF_SHORT); +#endif + + /* int */ +#if !defined(HAVE_SIZEOF_INT) + NODEF(HAVE_SIZEOF_INT); +#endif +#if defined(SIZEOF_INT) + CHECK(int, SIZEOF_INT); +#else + NODEF(SIZEOF_INT); +#endif + + /* long */ +#if !defined(HAVE_SIZEOF_LONG) + NODEF(HAVE_SIZEOF_LONG); +#endif +#if defined(SIZEOF_LONG) + CHECK(long, SIZEOF_LONG); +#else + NODEF(SIZEOF_LONG); +#endif + + /* long long */ +#if defined(SIZEOF_LONG_LONG) + CHECK(long long, SIZEOF_LONG_LONG); +# if !defined(HAVE_SIZEOF_LONG_LONG) + NODEF(HAVE_SIZEOF_LONG_LONG); +# endif +#endif + + /* __int64 */ +#if defined(SIZEOF___INT64) + CHECK(__int64, SIZEOF___INT64); +# if !defined(HAVE_SIZEOF___INT64) + NODEF(HAVE_SIZEOF___INT64); +# endif +#elif defined(HAVE_SIZEOF___INT64) + NODEF(SIZEOF___INT64); +#endif + + /* size_t */ +#if !defined(HAVE_SIZEOF_SIZE_T) + NODEF(HAVE_SIZEOF_SIZE_T); +#endif +#if defined(SIZEOF_SIZE_T) + CHECK(size_t, SIZEOF_SIZE_T); +#else + NODEF(SIZEOF_SIZE_T); +#endif + + /* ssize_t */ +#if defined(SIZEOF_SSIZE_T) + CHECK(ssize_t, SIZEOF_SSIZE_T); +# if !defined(HAVE_SIZEOF_SSIZE_T) + NODEF(HAVE_SIZEOF_SSIZE_T); +# endif +#elif defined(HAVE_SIZEOF_SSIZE_T) + NODEF(SIZEOF_SSIZE_T); +#endif + + return result; +} diff --git a/Tests/Module/CheckTypeSize/config.h.in b/Tests/Module/CheckTypeSize/config.h.in new file mode 100644 index 0000000..b5bfbf6 --- /dev/null +++ b/Tests/Module/CheckTypeSize/config.h.in @@ -0,0 +1,39 @@ +#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_STDDEF_H + +/* void* */ +#cmakedefine HAVE_SIZEOF_DATA_PTR +@SIZEOF_DATA_PTR_CODE@ + +/* char */ +#cmakedefine HAVE_SIZEOF_CHAR +@SIZEOF_CHAR_CODE@ + +/* short */ +#cmakedefine HAVE_SIZEOF_SHORT +@SIZEOF_SHORT_CODE@ + +/* int */ +#cmakedefine HAVE_SIZEOF_INT +@SIZEOF_INT_CODE@ + +/* long */ +#cmakedefine HAVE_SIZEOF_LONG +@SIZEOF_LONG_CODE@ + +/* long long */ +#cmakedefine HAVE_SIZEOF_LONG_LONG +@SIZEOF_LONG_LONG_CODE@ + +/* __int64 */ +#cmakedefine HAVE_SIZEOF___INT64 +@SIZEOF___INT64_CODE@ + +/* size_t */ +#cmakedefine HAVE_SIZEOF_SIZE_T +@SIZEOF_SIZE_T_CODE@ + +/* ssize_t */ +#cmakedefine HAVE_SIZEOF_SSIZE_T +@SIZEOF_SSIZE_T_CODE@ diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt new file mode 100644 index 0000000..88468c3 --- /dev/null +++ b/Tests/OutDir/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 2.8) +project(OutDir C) + +if(CMAKE_CONFIGURATION_TYPES) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" CONFIG) + list(APPEND configs "${CONFIG}") + endforeach() + set(CMAKE_BUILD_TYPE) +elseif(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +if(CMAKE_BUILD_TYPE) + string(TOUPPER "${CMAKE_BUILD_TYPE}" configs) +endif() + +set(top "${OutDir_BINARY_DIR}") +foreach(config ${configs}) + foreach(type archive runtime library) + string(TOUPPER "${type}" TYPE) + set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}") + file(REMOVE_RECURSE "${top}/${type}") + endforeach() +endforeach() + +add_subdirectory(../COnly COnly) + +add_custom_command( + OUTPUT OutDir.h + COMMAND ${CMAKE_COMMAND} -Dtop=${top} -P ${OutDir_SOURCE_DIR}/OutDir.cmake + DEPENDS COnly ${OutDir_SOURCE_DIR}/OutDir.cmake + ) +include_directories(${top}) +add_executable(OutDir OutDir.c OutDir.h) diff --git a/Tests/OutDir/OutDir.c b/Tests/OutDir/OutDir.c new file mode 100644 index 0000000..53f9259 --- /dev/null +++ b/Tests/OutDir/OutDir.c @@ -0,0 +1,24 @@ +#include <OutDir.h> +#include <stdio.h> + +int main(void) +{ + const char* files[] = {TESTC1_LIB, TESTC2_LIB, CONLY_EXE, 0}; + int result = 0; + const char** fname = files; + for(;*fname;++fname) + { + FILE* f = fopen(*fname, "rb"); + if(f) + { + printf("found: [%s]\n", *fname); + fclose(f); + } + else + { + printf("error: [%s]\n", *fname); + result = 1; + } + } + return result; +} diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake new file mode 100644 index 0000000..e1e6b7f --- /dev/null +++ b/Tests/OutDir/OutDir.cmake @@ -0,0 +1,28 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a" ".so" ".sl" ".dylib" ".dll.a") + +find_library(TESTC1_LIB + NAMES testc1 testc1_test_debug_postfix + PATHS ${top}/archive + NO_DEFAULT_PATH) + +find_library(TESTC2_LIB + NAMES testc2 testc2_test_debug_postfix + PATHS ${top}/archive ${top}/library + NO_DEFAULT_PATH) + +find_program(CONLY_EXE + NAMES COnly + PATHS ${top}/runtime + NO_DEFAULT_PATH) + +file(WRITE ${top}/OutDir.h "/* Generated by ${CMAKE_CURRENT_LIST_FILE} */ +#ifndef OutDir_h +#define OutDir_h + +#define TESTC1_LIB \"${TESTC1_LIB}\" +#define TESTC2_LIB \"${TESTC2_LIB}\" +#define CONLY_EXE \"${CONLY_EXE}\" + +#endif +") diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 7a249d8..5fc6550 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -364,14 +364,21 @@ SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) -INCLUDE(CPack) IF(CTEST_TEST_CPACK) SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) ELSE(CTEST_TEST_CPACK) SET(PACKAGE_TARGET) ENDIF(CTEST_TEST_CPACK) +INCLUDE(CPack) + ADD_CUSTOM_COMMAND( TARGET ${install_target} POST_BUILD diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 7a249d8..5fc6550 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -364,14 +364,21 @@ SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) -INCLUDE(CPack) IF(CTEST_TEST_CPACK) SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) ELSE(CTEST_TEST_CPACK) SET(PACKAGE_TARGET) ENDIF(CTEST_TEST_CPACK) +INCLUDE(CPack) + ADD_CUSTOM_COMMAND( TARGET ${install_target} POST_BUILD diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index d2e4de4..1055d07 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -30,8 +30,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMI // C shared module flags CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" CMAKE_SHARED_MODULE_CREATE_C_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS}" @@ -51,8 +49,6 @@ CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNA // CXX shared module flags CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" CMAKE_SHARED_MODULE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CXX_FLAGS}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG}" -CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP}" CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS}" CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS}" diff --git a/Tests/TarTest/CMakeLists.txt b/Tests/TarTest/CMakeLists.txt index 548712d..a3c5b31 100644 --- a/Tests/TarTest/CMakeLists.txt +++ b/Tests/TarTest/CMakeLists.txt @@ -28,9 +28,19 @@ IF(UNIX) SET(CHECK_FILES ${CHECK_FILES} "d1/f2.txt") ENDIF(UNIX) +# cleanup first in case there are files left from previous runs +# if the umask is odd on the machine it might create files that +# are not automatically over written. These tests are run +# each time the configure step is run. +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar") +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + # Run tests EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\" tar_dir") EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\" tar_dir") diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 62bed87..a57498f 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -211,12 +211,18 @@ TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed") TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed") TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed") +FOREACH(lang C CXX) + IF(NOT "${CMAKE_${lang}_COMPILER_ID}" MATCHES "^(PathScale)$") + SET(${lang}_DD --) + ENDIF() +ENDFOREACH() + UNSET(C_BOGUS_FLAG CACHE) INCLUDE(CheckCCompilerFlag) -CHECK_C_COMPILER_FLAG(---_this_is_not_a_flag_ C_BOGUS_FLAG) +CHECK_C_COMPILER_FLAG(${C_DD}-_this_is_not_a_flag_ C_BOGUS_FLAG) TEST_FAIL(C_BOGUS_FLAG "CHECK_C_COMPILER_FLAG() succeeded, but should have failed") UNSET(CXX_BOGUS_FLAG CACHE) INCLUDE(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG(---_this_is_not_a_flag_ CXX_BOGUS_FLAG) +CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG) TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed") |