diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-04-01 12:57:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-04-13 12:59:08 (GMT) |
commit | 17ff86547e759fea54b74eecce5fa62f33bba7f6 (patch) | |
tree | cd74a3e5dc9dbcc154afd6e51daff4b89e3e7c4a /Tests | |
parent | 591426f5a0ff9d442753105031313e704b972d29 (diff) | |
download | CMake-17ff86547e759fea54b74eecce5fa62f33bba7f6.zip CMake-17ff86547e759fea54b74eecce5fa62f33bba7f6.tar.gz CMake-17ff86547e759fea54b74eecce5fa62f33bba7f6.tar.bz2 |
cmake_host_system_information: query windows registry
Fixes: #21240, #23367
Diffstat (limited to 'Tests')
27 files changed, 312 insertions, 0 deletions
diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt new file mode 100644 index 0000000..1832ada --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadKey1.cmake:[0-9]+ \(message\): + WRONG_ROOT: invalid root key. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake new file mode 100644 index 0000000..6299f85 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake @@ -0,0 +1,4 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY WRONG_ROOT/SUBKEY ERROR_VARIABLE error) +if (NOT error STREQUAL "") + message(FATAL_ERROR "${error}") +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt new file mode 100644 index 0000000..4be55bf --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadKey2.cmake:[0-9]+ \(message\): + HKLM-SUBKEY: invalid root key. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake new file mode 100644 index 0000000..1750078 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake @@ -0,0 +1,4 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM-SUBKEY ERROR_VARIABLE error) +if (NOT error STREQUAL "") + message(FATAL_ERROR "${error}") +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt new file mode 100644 index 0000000..9510327 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadQuery1.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid argument\(s\) "BAD_OPTION". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake new file mode 100644 index 0000000..a92f35c --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE BAD_OPTION) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt new file mode 100644 index 0000000..6a430f1 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at Registry_BadQuery2.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing expected value for argument\(s\) + "VALUE". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake new file mode 100644 index 0000000..7c751cc --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VALUE) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt new file mode 100644 index 0000000..5eda4ff --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at Registry_BadView1.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing expected value for argument\(s\) + "VIEW". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake new file mode 100644 index 0000000..6527784 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt new file mode 100644 index 0000000..201d93a --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadView2.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid value for "VIEW": BAD_VIEW. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake new file mode 100644 index 0000000..d116c76 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW BAD_VIEW) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt new file mode 100644 index 0000000..5b7f7c7 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadView3.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid argument\(s\) "64". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake new file mode 100644 index 0000000..7c5f272 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW 32 64) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt new file mode 100644 index 0000000..ff55fcb --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_NoArgs.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing <key> specification. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake new file mode 100644 index 0000000..87e253d --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake new file mode 100644 index 0000000..9f9fb14 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake @@ -0,0 +1,232 @@ + +# check Windows architecture +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) +if (status STREQUAL "") + set(HOST_64BIT TRUE) +else() + set(HOST_64BIT FALSE) +endif() + +# helper function for test validation +function(CHECK key result status expression) + if(status STREQUAL "") + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for key '${key}': '${result}'\") + endif()") + else() + message(SEND_ERROR "query failed for key '${key}': '${status}'") + endif() +endfunction() + + +# HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry: Query default value +set(KEY "HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"default 64bit\") + OR (NOT HOST_64BIT AND result STREQUAL \"default 32bit\")") +# query value using special name should be identical to default value +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE "(default)" ERROR_VARIABLE status) +check("${KEY}{(default)}" "${result2}" "${status}" "result2 STREQUAL result") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW HOST ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"default 64bit\") + OR (NOT HOST_64BIT AND result STREQUAL \"default 32bit\")") +# VIEW TARGET should have same value as VIEW HOST +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result2}" "${status}" "result2 STREQUAL result") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64 ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32 ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + +# reg 64bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64_32 ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + +# reg 32bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32_64 ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + + +# HKCU/Software/CMake-Tests/chsi-registry: Query named value +set(KEY "HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"64bit\") + OR (NOT HOST_64BIT AND result STREQUAL \"32bit\")") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW HOST ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"64bit\") + OR (NOT HOST_64BIT AND result STREQUAL \"32bit\")") +# VIEW TARGET should have same value as VIEW HOST +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result2}" "${status}" "result2 STREQUAL result") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64 ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"64bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32 ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + +# reg 64bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64_32 ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"64bit\"") + +# reg 32bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32_64 ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of various types +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_SZ}" "${result}" "${status}" "result STREQUAL \"data with space\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_EXPAND_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_EXPAND_SZ}" "${result}" "${status}" + "(NOT result STREQUAL \"PATH=%PATH%\") AND (result MATCHES \"^PATH=\")") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_MULTI_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_MULTI_SZ}" "${result}" "${status}" "result STREQUAL \"data1;data2\"") +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE2_MULTI_SZ + SEPARATOR "|" ERROR_VARIABLE status) +check("${KEY}{VALUE2_MULTI_SZ}" "${result}" "${status}" "result STREQUAL \"data1;data2\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_DWORD ERROR_VARIABLE status) +check("${KEY}{VALUE_DWORD}" "${result}" "${status}" "result EQUAL \"129\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_QWORD ERROR_VARIABLE status) +check("${KEY}{VALUE_QWORD}" "${result}" "${status}" "result EQUAL \"513\"") + + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of value names +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE2_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") +# VIEW BOTH should have same result as default view +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW BOTH ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE2_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW HOST ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\") + OR (NOT HOST_64BIT AND result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\")") +# VIEW TARGET should have same result as VIEW HOST +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" + "(HOST_64BIT AND result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\") + OR (NOT HOST_64BIT AND result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\")") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64 ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32 ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\"") + +# reg 64bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64_32 ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE2_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + +# reg 32bit is read first. Result is the same as with view 64_32 +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32_64 ERROR_VARIABLE status) +check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of sub keys +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2;subkey3\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW HOST ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"subkey1;subkey2\") + OR (NOT HOST_64BIT AND result STREQUAL \"subkey1;subkey3\")") +# VIEW TARGET should have same result as VIEW HOST +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result}" "${status}" + "(HOST_64BIT AND result STREQUAL \"subkey1;subkey2\") + OR (NOT HOST_64BIT AND result STREQUAL \"subkey1;subkey3\")") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64 ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result}" "${status}" + "result STREQUAL \"subkey1;subkey2\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32 ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result}" "${status}" + "result STREQUAL \"subkey1;subkey3\"") + +# reg 64bit is read first +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64_32 ERROR_VARIABLE status) +check("${KEY}[SUBLEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2;subkey3\"") + +# reg 32bit is read first. Result is the same as with view 64_32 +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32_64 ERROR_VARIABLE status) +check("${KEY}[SUBKEYS]" "${result2}" "${status}" "result2 STREQUAL result") + + +# Check influence of variable CMAKE_SIZEOF_VOID_P +set(CMAKE_SIZEOF_VOID_P 8) + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"64bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + +set(CMAKE_SIZEOF_VOID_P 4) + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"32bit\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" "result STREQUAL \"subkey1;subkey3\"") diff --git a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake index 87b6944..d857bee 100644 --- a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake @@ -21,3 +21,27 @@ if(RunCMake_GENERATOR MATCHES "^Visual Studio " AND NOT RunCMake_GENERATOR STREQ else() run_cmake(VsMSBuildMissing) endif() + +# WINDOWS_REGISTRY tests +run_cmake(Registry_NoArgs) +run_cmake(Registry_BadQuery1) +run_cmake(Registry_BadQuery2) +run_cmake(Registry_BadView1) +run_cmake(Registry_BadView2) +run_cmake(Registry_BadView3) +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + run_cmake(Registry_BadKey1) + run_cmake(Registry_BadKey2) + + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_data.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + run_cmake(Registry_Query) + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests" /f OUTPUT_QUIET ERROR_QUIET) + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests" /f OUTPUT_QUIET ERROR_QUIET) + endif() +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/registry_data.reg b/Tests/RunCMake/cmake_host_system_information/registry_data.reg Binary files differnew file mode 100644 index 0000000..8596648 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/registry_data.reg |