Time to commit some Work-In-Progress stuff before my diff gets too large..
[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 <apitest.h>
9
10 #include <wingdi.h>
11 #include <winddi.h>
12
13 void Test_EngAcquireSemaphore()
14 {
15 HSEMAPHORE hsem;
16 PRTL_CRITICAL_SECTION lpcrit;
17
18 hsem = EngCreateSemaphore();
19 ok(hsem != NULL, "EngCreateSemaphore failed\n");
20 if (!hsem) return;
21 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
22
23 /* real data test */
24 EngAcquireSemaphore(hsem);
25 // ok(lpcrit->LockCount == -2); doesn't work on XP
26 ok(lpcrit->RecursionCount == 1, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount);
27 ok(lpcrit->OwningThread != 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread);
28 ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore);
29 ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount);
30
31 ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n");
32 if (lpcrit->DebugInfo)
33 {
34 ok(lpcrit->DebugInfo->Type == 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type);
35 ok(lpcrit->DebugInfo->CreatorBackTraceIndex == 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex);
36 ok(lpcrit->DebugInfo->EntryCount == 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount);
37 ok(lpcrit->DebugInfo->ContentionCount == 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount);
38 }
39
40 EngReleaseSemaphore(hsem);
41 EngDeleteSemaphore(hsem);
42
43 /* NULL pointer test */
44 // Note NULL pointer test crash in Vista */
45 // EngAcquireSemaphore(NULL);
46
47 /* negtive pointer test */
48 // Note negtive pointer test crash in Vista */
49 // EngAcquireSemaphore((HSEMAPHORE)-1);
50
51 /* try with deleted Semaphore */
52 // Note deleted Semaphore pointer test does freze the whole program in Vista */
53 // EngAcquireSemaphore(hsem);
54 }
55
56 START_TEST(EngAcquireSemaphore)
57 {
58 Test_EngAcquireSemaphore();
59 }
60