fadb8f937e7930d76ae5a8395ab555ae6fffcb23
[reactos.git] / rostests / apitests / gdi32 / EngAcquireSemaphore.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for EngAcquireSemaphore
5 * PROGRAMMERS: Magnus Olsen
6 */
7
8 #include <wine/test.h>
9 #include <wingdi.h>
10 #include <winddi.h>
11
12 void Test_EngAcquireSemaphore()
13 {
14 HSEMAPHORE hsem;
15 PRTL_CRITICAL_SECTION lpcrit;
16
17 hsem = EngCreateSemaphore();
18 ok(hsem != NULL, "EngCreateSemaphore failed\n");
19 if (!hsem) return;
20 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
21
22 /* real data test */
23 EngAcquireSemaphore(hsem);
24 // ok(lpcrit->LockCount == -2); doesn't work on XP
25 ok(lpcrit->RecursionCount == 1, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount);
26 ok(lpcrit->OwningThread != 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread);
27 ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore);
28 ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount);
29
30 ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n");
31 if (lpcrit->DebugInfo)
32 {
33 ok(lpcrit->DebugInfo->Type == 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type);
34 ok(lpcrit->DebugInfo->CreatorBackTraceIndex == 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex);
35 ok(lpcrit->DebugInfo->EntryCount == 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount);
36 ok(lpcrit->DebugInfo->ContentionCount == 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount);
37 }
38
39 EngReleaseSemaphore(hsem);
40 EngDeleteSemaphore(hsem);
41
42 /* NULL pointer test */
43 // Note NULL pointer test crash in Vista */
44 // EngAcquireSemaphore(NULL);
45
46 /* negtive pointer test */
47 // Note negtive pointer test crash in Vista */
48 // EngAcquireSemaphore((HSEMAPHORE)-1);
49
50 /* try with deleted Semaphore */
51 // Note deleted Semaphore pointer test does freze the whole program in Vista */
52 // EngAcquireSemaphore(hsem);
53 }
54
55 START_TEST(EngAcquireSemaphore)
56 {
57 Test_EngAcquireSemaphore();
58 }
59