1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

Tests/RunCMake/execute_process: Check STARTUPINFOW reserved members

Verify that `execute_process` launches processes on Windows such that
`GetStartupInfoW` in the child does not populate `STARTUPINFOW` members
reserved for the MSVC C run-time.

Issue: #25996
This commit is contained in:
Brad King
2024-05-22 14:51:02 -04:00
parent d98df689ab
commit fa8c04b421
4 changed files with 34 additions and 0 deletions

View File

@@ -513,6 +513,10 @@ set(execute_process_ARGS
if(NOT CMake_TEST_EXTERNAL_CMAKE)
list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>)
endif()
if(WIN32)
add_executable(testStartupInfo testStartupInfo.c)
list(APPEND execute_process_ARGS -DTEST_STARTUPINFO_EXE=$<TARGET_FILE:testStartupInfo>)
endif()
add_RunCMake_test(execute_process)
add_RunCMake_test(export)
if(CMake_TEST_MSYSTEM_PREFIX)

View File

@@ -53,3 +53,7 @@ if(WIN32 OR CYGWIN)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(WindowsNoExtension-build ${CMAKE_COMMAND} --build . --config Debug --target RunScript)
endif()
if(TEST_STARTUPINFO_EXE)
run_cmake_script(StartupInfo -DTEST_STARTUPINFO_EXE=${TEST_STARTUPINFO_EXE})
endif()

View File

@@ -0,0 +1 @@
execute_process(COMMAND "${TEST_STARTUPINFO_EXE}" COMMAND_ERROR_IS_FATAL ANY)

View File

@@ -0,0 +1,25 @@
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1928
# pragma warning(disable : 5105) /* macro expansion warning in windows.h */
#endif
#include <windows.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
STARTUPINFOW si;
memset(&si, 0, sizeof(si));
GetStartupInfoW(&si);
if (si.cbReserved2 != 0 || si.lpReserved2 != NULL) {
fprintf(stderr, "si.cbReserved2: %u\n", si.cbReserved2);
fprintf(stderr, "si.lpReserved2: %p\n", si.lpReserved2);
return 1;
}
return 0;
}