diff options
Diffstat (limited to 'Utilities/cmcurl')
-rw-r--r-- | Utilities/cmcurl/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Utilities/cmcurl/Testing/curltest.c | 29 |
2 files changed, 27 insertions, 8 deletions
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index d7ff9aa..510851a 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 67c142f..210868e 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; } |