ExternalData: Add support for SHA 1 and 2 hash algorithms

Update the Module.ExternalData and RunCMake.ExternalData tests to cover
some of them.
This commit is contained in:
Brad King 2013-01-24 14:12:10 -05:00
parent aa8b2288d3
commit ee2abfdc89
17 changed files with 51 additions and 2 deletions

View File

@ -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)

View File

@ -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}

View File

@ -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}")

View File

@ -0,0 +1 @@
SeriesMixed.1

View File

@ -0,0 +1 @@
* -crlf

View File

@ -0,0 +1 @@
SeriesMixed.2

View File

@ -0,0 +1 @@
* -crlf

View File

@ -0,0 +1 @@
* -crlf

View File

@ -0,0 +1 @@
ce38ea6c3c1e00fa6405dd64b8bf6da0

View File

@ -0,0 +1 @@
2af59a7022024974f3b8521b7ed8137c996a79f1

View File

@ -0,0 +1 @@
3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174

View File

@ -0,0 +1 @@
969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133

View File

@ -0,0 +1,3 @@
-- Linked ToLink.txt.sha1 to ExternalData SHA1/114ee5dda251457fd2df63bec91d3b8db43aba58
-- Raw data correctly transformed to content link!
-- Staged content exists!

View File

@ -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()

View File

@ -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)