From a61c5ab6e59a458ad34383e64d0679a7fe898c61 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 8 Mar 2010 12:14:47 -0500 Subject: [PATCH] Add CMAKE_TESTS_CDASH_SERVER variable and CTestSubmitLargeOutput test. If defined and non-empty, the value of CMAKE_TESTS_CDASH_SERVER should point to a CDash server willing to accept submissions for a project named PublicDashboard. On machines that also run a CDash dashboard, set this variable to "http://localhost/CDash-trunk-Testing" so that the CMake tests that submit dashboards do not have to send those submissions over the wire. The CTestSubmitLargeOutput test runs a dashboard that has a test that produces very large amount of output on stdout/stderr. Since we do not even want to attempt to send such large output over the wire, this test is off by default unless the CMAKE_TESTS_CDASH_SERVER server is localhost. This test is expected to cause a submission failure when sent to CDash. It passes if the submit results contain error output. It fails if the submit succeeds. CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests. If not defined or "", this variable defaults to the server at http://www.cdash.org/CDash. If set explicitly to "NOTFOUND", curl tests and ctest tests that use the network are skipped. If set to something starting with "http://localhost/", the CDash is expected to be an instance of CDash used for CDash testing, pointing to a cdash4simpletest database. In these cases, the CDash dashboards should be run first. --- CMakeLists.txt | 20 ++++++++ Tests/CMakeLists.txt | 50 +++++++++++++++++-- Tests/CTestSubmitLargeOutput/CMakeLists.txt | 8 +++ .../CTestSubmitLargeOutput/CTestConfig.cmake | 6 +++ .../GenerateRandomOutput.cmake | 31 ++++++++++++ Tests/CTestSubmitLargeOutput/test.cmake.in | 26 ++++++++++ Tests/CTestTest2/test.cmake.in | 6 ++- Tests/CTestTest3/test.cmake.in | 5 ++ Utilities/cmcurl/CMakeLists.txt | 6 ++- Utilities/cmcurl/Testing/curltest.c | 29 ++++++++--- 10 files changed, 175 insertions(+), 12 deletions(-) create mode 100644 Tests/CTestSubmitLargeOutput/CMakeLists.txt create mode 100644 Tests/CTestSubmitLargeOutput/CTestConfig.cmake create mode 100644 Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake create mode 100644 Tests/CTestSubmitLargeOutput/test.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b4d6c5c6a..4cd11c458 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,9 @@ MACRO (CMAKE_BUILD_UTILITIES) ENDIF(NOT CMAKE_BUILD_CURL_SHARED) SET(CMAKE_CURL_INCLUDES) SET(CMAKE_CURL_LIBRARIES cmcurl) + IF(CMAKE_TESTS_CDASH_SERVER) + SET(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") + ENDIF(CMAKE_TESTS_CDASH_SERVER) ADD_SUBDIRECTORY(Utilities/cmcurl) ENDIF(CMAKE_USE_SYSTEM_CURL) @@ -389,6 +392,23 @@ INCLUDE(CheckSymbolExists) CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) +# CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests. +# +# If not defined or "", this variable defaults to the server at +# http://www.cdash.org/CDash. +# +# If set explicitly to "NOTFOUND", curl tests and ctest tests that use +# the network are skipped. +# +# If set to something starting with "http://localhost/", the CDash is +# expected to be an instance of CDash used for CDash testing, pointing +# to a cdash4simpletest database. In these cases, the CDash dashboards +# should be run first. +# +IF("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x") + SET(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash") +ENDIF("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x") + # build the utilities (a macro defined in this file) CMAKE_BUILD_UTILITIES() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7bc8b3366..6a08b3c2f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1393,26 +1393,45 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endforeach() - IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) + IF (CMAKE_TESTS_CDASH_SERVER) + SET(regex "^([^:]+)://([^/]+)(/.*)$") + + IF ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + SET(protocol "${CMAKE_MATCH_1}") + SET(server "${CMAKE_MATCH_2}") + SET(path "${CMAKE_MATCH_3}") + ELSE ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + SET(protocol "http") + SET(server "www.cdash.org") + SET(path "/CDash") + MESSAGE("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...") + MESSAGE(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]") + ENDIF ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + ENDIF (CMAKE_TESTS_CDASH_SERVER) + + + IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) ADD_TEST(CTestTest ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" ) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) ADD_TEST(CTestTest2 ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest3/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" @ONLY ESCAPE_QUOTES) ADD_TEST(CTestTest3 ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTest3/testOutput.log" ) - + # these tests take a long time, make sure they have it # if timeouts have not already been set GET_TEST_PROPERTY(CTestTest TIMEOUT PREVIOUS_TIMEOUT) @@ -1432,7 +1451,32 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ SET_TESTS_PROPERTIES ( CTestTest3 PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) + ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) + + IF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) + SET(CTEST_RUN_CTestSubmitLargeOutput OFF) + + IF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") + SET(CTEST_RUN_CTestSubmitLargeOutput ON) + ENDIF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") + ENDIF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) + + IF(CTEST_RUN_CTestSubmitLargeOutput) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestSubmitLargeOutput/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" + @ONLY ESCAPE_QUOTES + ) + ADD_TEST(CTestSubmitLargeOutput ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/testOutput.log" + ) + + # This test only passes if it fails to submit properly... + # + SET_TESTS_PROPERTIES(CTestSubmitLargeOutput PROPERTIES + PASS_REGULAR_EXPRESSION "Errors occurred during submission") + ENDIF(CTEST_RUN_CTestSubmitLargeOutput) IF (CMAKE_RUN_LONG_TESTS AND TEST_KDE4_STABLE_BRANCH) IF(UNIX) diff --git a/Tests/CTestSubmitLargeOutput/CMakeLists.txt b/Tests/CTestSubmitLargeOutput/CMakeLists.txt new file mode 100644 index 000000000..6c30e7a0d --- /dev/null +++ b/Tests/CTestSubmitLargeOutput/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8) +project(SubmitLargeOutput NONE) + +include(CTest) + +add_test(GenerateRandomOutput ${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/GenerateRandomOutput.cmake + ) diff --git a/Tests/CTestSubmitLargeOutput/CTestConfig.cmake b/Tests/CTestSubmitLargeOutput/CTestConfig.cmake new file mode 100644 index 000000000..ffd6efc2d --- /dev/null +++ b/Tests/CTestSubmitLargeOutput/CTestConfig.cmake @@ -0,0 +1,6 @@ +set(CTEST_PROJECT_NAME "SubmitLargeOutput") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +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/CTestSubmitLargeOutput/GenerateRandomOutput.cmake b/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake new file mode 100644 index 000000000..c7f4f299a --- /dev/null +++ b/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake @@ -0,0 +1,31 @@ +# +# This script generates random lines of output. +# +# By default, it generates 100M of output (a million lines of 100 bytes each), +# but you can override that by passing in -D line_count and/or -D line_size... +# + +# Default values: +# +if(NOT DEFINED line_count) + set(line_count 1000000) +endif() + +if(NOT DEFINED line_size) + set(line_size 100) +endif() + +if(NOT DEFINED random_seed) + set(random_seed 1987) +endif() + +# Use RANDOM_SEED once before the loop: +# +string(RANDOM LENGTH ${line_size} RANDOM_SEED ${random_seed} s) + +# Emit line_count lines of random output: +# +foreach(i RANGE 1 ${line_count}) + string(RANDOM LENGTH ${line_size} s) + message(${s}) +endforeach() diff --git a/Tests/CTestSubmitLargeOutput/test.cmake.in b/Tests/CTestSubmitLargeOutput/test.cmake.in new file mode 100644 index 000000000..bc094b035 --- /dev/null +++ b/Tests/CTestSubmitLargeOutput/test.cmake.in @@ -0,0 +1,26 @@ +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "LargeOutput-@BUILDNAME@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestSubmitLargeOutput") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestSubmitLargeOutput/build") +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_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + +SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 1000000000) +SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000000) + +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + +set(CTEST_DROP_METHOD "@protocol@") +set(CTEST_DROP_SITE "@server@") +set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + +CTEST_SUBMIT(RETURN_VALUE res) diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index 643e767e5..cccd8c123 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -18,7 +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_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ @@ -41,6 +40,11 @@ CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 2 END 4 STRI CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 6 STRIDE 2 SUBMIT_INDEX 3) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res STRIDE 1.5) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + +set(CTEST_DROP_METHOD "@protocol@") +set(CTEST_DROP_SITE "@server@") +set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + CTEST_SUBMIT(RETURN_VALUE res) # Test submission of a subset of parts. diff --git a/Tests/CTestTest3/test.cmake.in b/Tests/CTestTest3/test.cmake.in index d0a1f888d..1cf5a885b 100644 --- a/Tests/CTestTest3/test.cmake.in +++ b/Tests/CTestTest3/test.cmake.in @@ -53,6 +53,11 @@ CTEST_BUILD(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) + +set(CTEST_DROP_METHOD "@protocol@") +set(CTEST_DROP_SITE "@server@") +set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + CTEST_SUBMIT(RETURN_VALUE res) #SET(svncommand "@SVNCOMMAND@") diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index d7ff9aa96..510851a26 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -762,5 +762,9 @@ ENDIF(CURL_TESTING) ADD_EXECUTABLE(LIBCURL Testing/curltest.c) TARGET_LINK_LIBRARIES(LIBCURL cmcurl ${CMAKE_DL_LIBS}) -ADD_TEST(curl LIBCURL) + +IF(CMAKE_CURL_TEST_URL) + ADD_TEST(curl LIBCURL ${CMAKE_CURL_TEST_URL}) +ENDIF(CMAKE_CURL_TEST_URL) + INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmcurl) diff --git a/Utilities/cmcurl/Testing/curltest.c b/Utilities/cmcurl/Testing/curltest.c index 67c142f17..210868e36 100644 --- a/Utilities/cmcurl/Testing/curltest.c +++ b/Utilities/cmcurl/Testing/curltest.c @@ -36,7 +36,7 @@ int GetFtpFile(void) return retVal; } -int GetWebFile(void) +int GetWebFiles(char *url1, char *url2) { int retVal = 0; CURL *curl; @@ -98,22 +98,24 @@ int GetWebFile(void) } /* get the first document */ - curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/page1.html"); + curl_easy_setopt(curl, CURLOPT_URL, url1); res = curl_easy_perform(curl); if ( res != 0 ) { - printf("Error fetching: http://www.cmake.org/page1.html\n"); + printf("Error fetching: %s\n", url1); retVal = 1; } /* get another document from the same server using the same connection */ + /* avoid warnings about url2 since below block is commented out: */ + (void) url2; /* - curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/page2.html"); + curl_easy_setopt(curl, CURLOPT_URL, url2); res = curl_easy_perform(curl); if ( res != 0 ) { - printf("Error fetching: http://www.cmake.org/page2.html\n"); + printf("Error fetching: %s\n", url2); retVal = 1; } */ @@ -130,15 +132,28 @@ int GetWebFile(void) return retVal; } -int main(/*int argc, char **argv*/) + +int main(int argc, char **argv) { int retVal = 0; + curl_global_init(CURL_GLOBAL_DEFAULT); - retVal += GetWebFile(); + + if(argc>1) + { + retVal += GetWebFiles(argv[1], 0); + } + else + { + printf("error: first argument should be a url to download\n"); + retVal = 1; + } /* Do not check the output of FTP socks5 cannot handle FTP yet */ /* GetFtpFile(); */ /* do not test ftp right now because we don't enable that port */ + curl_global_cleanup(); + return retVal; }