summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-01-24 19:12:10 (GMT)
committerBrad King <brad.king@kitware.com>2013-01-30 15:05:07 (GMT)
commitee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1 (patch)
tree4a0235d75ef035f1129888043fda79db892f8f75
parentaa8b2288d320335d28f3777e1bc86ed3df231a09 (diff)
downloadCMake-ee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1.zip
CMake-ee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1.tar.gz
CMake-ee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1.tar.bz2
ExternalData: Add support for SHA 1 and 2 hash algorithms
Update the Module.ExternalData and RunCMake.ExternalData tests to cover some of them.
-rw-r--r--Modules/ExternalData.cmake9
-rw-r--r--Tests/Module/ExternalData/CMakeLists.txt1
-rw-r--r--Tests/Module/ExternalData/Data1Check.cmake6
-rw-r--r--Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da01
-rw-r--r--Tests/Module/ExternalData/SHA1/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f11
-rw-r--r--Tests/Module/ExternalData/SHA224/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a58691741
-rw-r--r--Tests/Module/ExternalData/SHA256/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f1331
-rw-r--r--Tests/Module/ExternalData/SeriesMixed.1.dat.md51
-rw-r--r--Tests/Module/ExternalData/SeriesMixed.2.dat.sha11
-rw-r--r--Tests/Module/ExternalData/SeriesMixed.3.dat.sha2241
-rw-r--r--Tests/Module/ExternalData/SeriesMixed.4.dat.sha2561
-rw-r--r--Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt3
-rw-r--r--Tests/RunCMake/ExternalData/LinkContentSHA1.cmake22
-rw-r--r--Tests/RunCMake/ExternalData/RunCMakeTest.cmake1
17 files changed, 51 insertions, 2 deletions
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index fef8367..26b0f99 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -49,6 +49,11 @@
# %(algo) <ext> Description
# ------- ----- -----------
# MD5 .md5 Message-Digest Algorithm 5, RFC 1321
+# SHA1 .sha1 US Secure Hash Algorithm 1, RFC 3174
+# SHA224 .sha224 US Secure Hash Algorithms, RFC 4634
+# SHA256 .sha256 US Secure Hash Algorithms, RFC 4634
+# SHA384 .sha384 US Secure Hash Algorithms, RFC 4634
+# SHA512 .sha512 US Secure Hash Algorithms, RFC 4634
# Note that the hashes are used only for unique data identification and
# download verification. This is not security software.
#
@@ -261,8 +266,8 @@ endfunction()
#-----------------------------------------------------------------------------
# Private helper interface
-set(_ExternalData_REGEX_ALGO "MD5")
-set(_ExternalData_REGEX_EXT "md5")
+set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
+set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512")
set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}")
get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH)
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
index c9a192b..e69713a 100644
--- a/Tests/Module/ExternalData/CMakeLists.txt
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -22,6 +22,7 @@ ExternalData_Add_Test(Data1
-D SeriesBn=DATA{SeriesBn_1.dat,:}
-D SeriesCn=DATA{SeriesCn.1.dat,:}
-D SeriesDn=DATA{SeriesDn-1.dat,:}
+ -D SeriesMixed=DATA{SeriesMixed.1.dat,:}
-D Paired=DATA{PairedA.dat,PairedB.dat}
-D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat}
-D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat}
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
index 972ec46..b99d7ae 100644
--- a/Tests/Module/ExternalData/Data1Check.cmake
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -26,6 +26,12 @@ foreach(s A B C D)
endif()
endforeach()
endforeach()
+foreach(n .1 .2 .3 .4)
+ string(REGEX REPLACE "\\.1\\.dat$" "${n}.dat" file "${SeriesMixed}")
+ if(NOT EXISTS "${file}")
+ message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
+ endif()
+endforeach()
foreach(n A B)
string(REGEX REPLACE "A\\.dat$" "${n}.dat" file "${Paired}")
if(NOT EXISTS "${file}")
diff --git a/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 b/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0
new file mode 100644
index 0000000..362d4b4
--- /dev/null
+++ b/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0
@@ -0,0 +1 @@
+SeriesMixed.1
diff --git a/Tests/Module/ExternalData/SHA1/.gitattributes b/Tests/Module/ExternalData/SHA1/.gitattributes
new file mode 100644
index 0000000..3e51d39
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA1/.gitattributes
@@ -0,0 +1 @@
+* -crlf
diff --git a/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1 b/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1
new file mode 100644
index 0000000..a388540
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1
@@ -0,0 +1 @@
+SeriesMixed.2
diff --git a/Tests/Module/ExternalData/SHA224/.gitattributes b/Tests/Module/ExternalData/SHA224/.gitattributes
new file mode 100644
index 0000000..3e51d39
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA224/.gitattributes
@@ -0,0 +1 @@
+* -crlf
diff --git a/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 b/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174
new file mode 100644
index 0000000..e806d98
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174
@@ -0,0 +1 @@
+SeriesMixed.3
diff --git a/Tests/Module/ExternalData/SHA256/.gitattributes b/Tests/Module/ExternalData/SHA256/.gitattributes
new file mode 100644
index 0000000..3e51d39
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA256/.gitattributes
@@ -0,0 +1 @@
+* -crlf
diff --git a/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 b/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133
new file mode 100644
index 0000000..e3d1e0c
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133
@@ -0,0 +1 @@
+SeriesMixed.4
diff --git a/Tests/Module/ExternalData/SeriesMixed.1.dat.md5 b/Tests/Module/ExternalData/SeriesMixed.1.dat.md5
new file mode 100644
index 0000000..f962d8f
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesMixed.1.dat.md5
@@ -0,0 +1 @@
+ce38ea6c3c1e00fa6405dd64b8bf6da0
diff --git a/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1 b/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1
new file mode 100644
index 0000000..43a3540
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1
@@ -0,0 +1 @@
+2af59a7022024974f3b8521b7ed8137c996a79f1
diff --git a/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224 b/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224
new file mode 100644
index 0000000..a18e40e
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224
@@ -0,0 +1 @@
+3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174
diff --git a/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256 b/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256
new file mode 100644
index 0000000..67fc3c2
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256
@@ -0,0 +1 @@
+969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133
diff --git a/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt b/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt
new file mode 100644
index 0000000..9a8eb2e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt
@@ -0,0 +1,3 @@
+-- Linked ToLink.txt.sha1 to ExternalData SHA1/114ee5dda251457fd2df63bec91d3b8db43aba58
+-- Raw data correctly transformed to content link!
+-- Staged content exists!
diff --git a/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake b/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake
new file mode 100644
index 0000000..f78501c
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake
@@ -0,0 +1,22 @@
+include(ExternalData)
+set(ExternalData_LINK_CONTENT SHA1)
+set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR})
+set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData)
+set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt)
+set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/ToLink.txt)
+set(staged "${CMAKE_CURRENT_BINARY_DIR}/.ExternalData_SHA1_114ee5dda251457fd2df63bec91d3b8db43aba58")
+file(REMOVE ${staged})
+file(REMOVE ${input}.sha1)
+file(WRITE ${input} "To be transformed into a content link.")
+ExternalData_Expand_Arguments(Data args DATA{${input}})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Raw data correctly transformed to content link!")
+else()
+ message(FATAL_ERROR "Data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
+if(EXISTS "${staged}")
+ message(STATUS "Staged content exists!")
+else()
+ message(FATAL_ERROR "Staged content missing!")
+endif()
diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
index fc85a21..5ee46c9 100644
--- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
@@ -12,6 +12,7 @@ run_cmake(Directory3)
run_cmake(Directory4)
run_cmake(Directory5)
run_cmake(LinkContentMD5)
+run_cmake(LinkContentSHA1)
run_cmake(MissingData)
run_cmake(NoLinkInSource)
run_cmake(NoURLTemplates)