ENH: add test for registry-related functions (win32)
This commit is contained in:
parent
2b4e802a94
commit
81ebecaea1
|
@ -110,6 +110,29 @@ GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test registry (win32)
|
||||||
|
# Create a file, put its path in a registry key, try to find the file in that
|
||||||
|
# path using that registry key, then remove the file and the key
|
||||||
|
#
|
||||||
|
IF (WIN32)
|
||||||
|
IF (NOT UNIX)
|
||||||
|
SET(dir "${Complex_BINARY_DIR}/registry_dir")
|
||||||
|
SET(file "registry_test_dummy")
|
||||||
|
SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test")
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
${Complex_SOURCE_DIR}/Library/dummy
|
||||||
|
"${dir}/${file}"
|
||||||
|
COPYONLY IMMEDIATE)
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} write_regv \"${hkey}\" \"${dir}\"")
|
||||||
|
FIND_PATH(REGISTRY_TEST_PATH
|
||||||
|
${file}
|
||||||
|
"[${hkey}]")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} delete_regv \"${hkey}\"")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} remove \"${dir}/${file}\"")
|
||||||
|
ENDIF (NOT UNIX)
|
||||||
|
ENDIF (WIN32)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
# (plug vars to #define so that they can be tested)
|
# (plug vars to #define so that they can be tested)
|
||||||
|
|
|
@ -37,7 +37,7 @@ void ForceStringUse()
|
||||||
|
|
||||||
void cmFailed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "FAILED: " << Message << m2 << "\n";
|
std::cout << "FAILED: " << Message << m2 << "\n";
|
||||||
cm_failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,24 @@ int main()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test registry (win32)
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#ifndef REGISTRY_TEST_PATH
|
||||||
|
cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
|
||||||
|
REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,9 @@
|
||||||
#cmakedefine FILE_HAS_ABSTRACT
|
#cmakedefine FILE_HAS_ABSTRACT
|
||||||
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
||||||
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
||||||
|
|
||||||
|
// Test registry read
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#define REGISTRY_TEST_PATH "${REGISTRY_TEST_PATH}"
|
||||||
|
#endif
|
||||||
|
|
|
@ -110,6 +110,29 @@ GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test registry (win32)
|
||||||
|
# Create a file, put its path in a registry key, try to find the file in that
|
||||||
|
# path using that registry key, then remove the file and the key
|
||||||
|
#
|
||||||
|
IF (WIN32)
|
||||||
|
IF (NOT UNIX)
|
||||||
|
SET(dir "${Complex_BINARY_DIR}/registry_dir")
|
||||||
|
SET(file "registry_test_dummy")
|
||||||
|
SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test")
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
${Complex_SOURCE_DIR}/Library/dummy
|
||||||
|
"${dir}/${file}"
|
||||||
|
COPYONLY IMMEDIATE)
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} write_regv \"${hkey}\" \"${dir}\"")
|
||||||
|
FIND_PATH(REGISTRY_TEST_PATH
|
||||||
|
${file}
|
||||||
|
"[${hkey}]")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} delete_regv \"${hkey}\"")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} remove \"${dir}/${file}\"")
|
||||||
|
ENDIF (NOT UNIX)
|
||||||
|
ENDIF (WIN32)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
# (plug vars to #define so that they can be tested)
|
# (plug vars to #define so that they can be tested)
|
||||||
|
|
|
@ -37,7 +37,7 @@ void ForceStringUse()
|
||||||
|
|
||||||
void cmFailed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "FAILED: " << Message << m2 << "\n";
|
std::cout << "FAILED: " << Message << m2 << "\n";
|
||||||
cm_failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,24 @@ int main()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test registry (win32)
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#ifndef REGISTRY_TEST_PATH
|
||||||
|
cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
|
||||||
|
REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,9 @@
|
||||||
#cmakedefine FILE_HAS_ABSTRACT
|
#cmakedefine FILE_HAS_ABSTRACT
|
||||||
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
||||||
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
||||||
|
|
||||||
|
// Test registry read
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#define REGISTRY_TEST_PATH "${REGISTRY_TEST_PATH}"
|
||||||
|
#endif
|
||||||
|
|
|
@ -110,6 +110,29 @@ GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
|
||||||
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test registry (win32)
|
||||||
|
# Create a file, put its path in a registry key, try to find the file in that
|
||||||
|
# path using that registry key, then remove the file and the key
|
||||||
|
#
|
||||||
|
IF (WIN32)
|
||||||
|
IF (NOT UNIX)
|
||||||
|
SET(dir "${Complex_BINARY_DIR}/registry_dir")
|
||||||
|
SET(file "registry_test_dummy")
|
||||||
|
SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test")
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
${Complex_SOURCE_DIR}/Library/dummy
|
||||||
|
"${dir}/${file}"
|
||||||
|
COPYONLY IMMEDIATE)
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} write_regv \"${hkey}\" \"${dir}\"")
|
||||||
|
FIND_PATH(REGISTRY_TEST_PATH
|
||||||
|
${file}
|
||||||
|
"[${hkey}]")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} delete_regv \"${hkey}\"")
|
||||||
|
EXEC_PROGRAM("${CCOMMAND_COMMAND} remove \"${dir}/${file}\"")
|
||||||
|
ENDIF (NOT UNIX)
|
||||||
|
ENDIF (WIN32)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
# (plug vars to #define so that they can be tested)
|
# (plug vars to #define so that they can be tested)
|
||||||
|
|
|
@ -37,7 +37,7 @@ void ForceStringUse()
|
||||||
|
|
||||||
void cmFailed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "FAILED: " << Message << m2 << "\n";
|
std::cout << "FAILED: " << Message << m2 << "\n";
|
||||||
cm_failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,6 +612,24 @@ int main()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test registry (win32)
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#ifndef REGISTRY_TEST_PATH
|
||||||
|
cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
|
||||||
|
REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,9 @@
|
||||||
#cmakedefine FILE_HAS_ABSTRACT
|
#cmakedefine FILE_HAS_ABSTRACT
|
||||||
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
#cmakedefine FILE_HAS_WRAP_EXCLUDE
|
||||||
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}"
|
||||||
|
|
||||||
|
// Test registry read
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
#define REGISTRY_TEST_PATH "${REGISTRY_TEST_PATH}"
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue