Commit aeb08658 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

Add curl testing

parent 3587c439
......@@ -273,6 +273,11 @@ IF(BUILD_TESTING)
${CMake_BINARY_DIR}/Tests/LinkLineOrder
LinkLineOrder)
ADD_TEST(curl ${CMake_BINARY_DIR}/Source/cmaketest
${CMake_SOURCE_DIR}/Source/CTest/Curl
${CMake_BINARY_DIR}/Tests/Curl
curltest)
IF (APPLE)
ADD_TEST(objc++ ${CMake_BINARY_DIR}/Source/cmaketest
${CMake_SOURCE_DIR}/Tests/Objc++
......
......@@ -356,3 +356,5 @@ IF(CURL_TESTING)
SUBDIRS(Testing)
ENDIF(CURL_TESTING)
ADD_EXECUTABLE(curltest Testing/curltest.c)
TARGET_LINK_LIBRARIES(curltest Curl)
\ No newline at end of file
#include "curl/curl.h"
int GetFtpFile(void)
{
int retVal = 0;
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
/* Get curl 7.9.2 from sunet.se's FTP site: */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
curl_easy_setopt(curl, CURLOPT_URL,
"ftp://public.kitware.com/pub/cmake/cygwin/setup.hint");
res = curl_easy_perform(curl);
if ( res != 0 )
{
printf("Error fetching: http://www.cmake.org/\n");
retVal = 1;
}
/* always cleanup */
curl_easy_cleanup(curl);
}
else
{
printf("Cannot create curl object\n");
retVal = 1;
}
return retVal;
}
int GetWebFile(void)
{
int retVal = 0;
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
/* get the first document */
curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/");
res = curl_easy_perform(curl);
if ( res != 0 )
{
printf("Error fetching: http://www.cmake.org/\n");
retVal = 1;
}
/* get another document from the same server using the same
connection */
curl_easy_setopt(curl, CURLOPT_URL, "http://www.cmake.org/HTML/Index.html");
res = curl_easy_perform(curl);
if ( res != 0 )
{
printf("Error fetching: http://www.cmake.org/HTML/Index.html\n");
retVal = 1;
}
/* always cleanup */
curl_easy_cleanup(curl);
}
else
{
printf("Cannot create curl object\n");
retVal = 1;
}
return retVal;
}
int main(int argc, char **argv)
{
int retVal = 0;
curl_global_init(CURL_GLOBAL_DEFAULT);
retVal += GetWebFile();
retVal += GetFtpFile();
curl_global_cleanup();
return retVal;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment