summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeTests/FileUploadTest.cmake.in
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-02-23 18:53:53 (GMT)
committerDavid Cole <david.cole@kitware.com>2011-02-25 22:26:34 (GMT)
commit963bebcc174411e1087af31cc5054422b0080e76 (patch)
treeea03e151378a797ccb757674ac6625782a83234c /Tests/CMakeTests/FileUploadTest.cmake.in
parent62f816adde5312eb97724796efa8e4dff9534f54 (diff)
downloadCMake-963bebcc174411e1087af31cc5054422b0080e76.zip
CMake-963bebcc174411e1087af31cc5054422b0080e76.tar.gz
CMake-963bebcc174411e1087af31cc5054422b0080e76.tar.bz2
Implement file(UPLOAD (#11286)
Including documentation and testing, of course.
Diffstat (limited to 'Tests/CMakeTests/FileUploadTest.cmake.in')
-rw-r--r--Tests/CMakeTests/FileUploadTest.cmake.in49
1 files changed, 49 insertions, 0 deletions
diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in
new file mode 100644
index 0000000..8577aef
--- /dev/null
+++ b/Tests/CMakeTests/FileUploadTest.cmake.in
@@ -0,0 +1,49 @@
+file(REMOVE_RECURSE "@CMAKE_CURRENT_BINARY_DIR@/uploads")
+
+if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png")
+ message(FATAL_ERROR "error: file1.png exists - should have been deleted")
+endif()
+if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png")
+ message(FATAL_ERROR "error: file2.png exists - should have been deleted")
+endif()
+
+file(MAKE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/uploads")
+
+set(filename "@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png")
+set(urlbase "file://@CMAKE_CURRENT_BINARY_DIR@/uploads")
+
+message(STATUS "FileUpload:1")
+file(UPLOAD
+ ${filename}
+ ${urlbase}/file1.png
+ TIMEOUT 2
+ )
+
+message(STATUS "FileUpload:2")
+file(UPLOAD
+ ${filename}
+ ${urlbase}/file2.png
+ STATUS status
+ LOG log
+ SHOW_PROGRESS
+ )
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum
+ "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png"
+ OUTPUT_VARIABLE sum1
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$")
+ message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum
+ "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png"
+ OUTPUT_VARIABLE sum2
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$")
+ message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')")
+endif()
+
+message(STATUS "log='${log}'")
+message(STATUS "status='${status}'")
+message(STATUS "DONE")