kernel32/tests: Add tests for critical section debug info presence.

This commit is contained in:
Paul Gofman 2023-12-18 17:02:28 -06:00 committed by Alexandre Julliard
parent e8f4909ac3
commit 0b441c4c8f
2 changed files with 38 additions and 6 deletions

View file

@ -2741,7 +2741,8 @@ static void test_crit_section(void)
to override that. */
memset(&cs, 0, sizeof(cs));
InitializeCriticalSection(&cs);
ok(cs.DebugInfo != NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */,
"Unexpected debug info pointer %p.\n", cs.DebugInfo);
DeleteCriticalSection(&cs);
ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
@ -2751,10 +2752,39 @@ static void test_crit_section(void)
return;
}
memset(&cs, 0, sizeof(cs));
ret = pInitializeCriticalSectionEx(&cs, 0, 0);
ok(ret, "Failed to initialize critical section.\n");
todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */,
"Unexpected debug info pointer %p.\n", cs.DebugInfo);
DeleteCriticalSection(&cs);
ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
memset(&cs, 0, sizeof(cs));
ret = pInitializeCriticalSectionEx(&cs, 0, CRITICAL_SECTION_NO_DEBUG_INFO);
ok(ret, "Failed to initialize critical section.\n");
ok(cs.DebugInfo == (void *)(ULONG_PTR)-1, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
DeleteCriticalSection(&cs);
todo_wine ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
memset(&cs, 0, sizeof(cs));
ret = pInitializeCriticalSectionEx(&cs, 0, 0);
ok(ret, "Failed to initialize critical section.\n");
todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */,
"Unexpected debug info pointer %p.\n", cs.DebugInfo);
DeleteCriticalSection(&cs);
ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
memset(&cs, 0, sizeof(cs));
ret = pInitializeCriticalSectionEx(&cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO);
ok(ret || broken(GetLastError() == ERROR_INVALID_PARAMETER) /* before Win8 */,
"Failed to initialize critical section, error %lu.\n", GetLastError());
if (!ret)
{
ret = pInitializeCriticalSectionEx(&cs, 0, 0);
ok(ret, "Failed to initialize critical section.\n");
}
ok(cs.DebugInfo && cs.DebugInfo != (void *)(ULONG_PTR)-1, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
ret = TryEnterCriticalSection(&cs);
ok(ret, "Failed to enter critical section.\n");

View file

@ -6113,11 +6113,13 @@ typedef struct _RTL_CRITICAL_SECTION {
ULONG_PTR SpinCount;
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
#define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
#define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
#define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
#define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
#define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
#define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x01000000
#define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x02000000
#define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x04000000
#define RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE 0x08000000
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO 0x10000000
#define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xff000000
#define RTL_CRITICAL_SECTION_FLAG_RESERVED 0xe0000000
typedef struct _RTL_SRWLOCK {
PVOID Ptr;