f129fb94c737ba71eb0bd9a2823a4b1b77a3fdd9
[reactos.git] / modules / rostests / apitests / gdi32 / EngDeleteSemaphore.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for EngDeleteSemaphore
5 * PROGRAMMERS: Magnus Olsen
6 */
7
8 #include <apitest.h>
9
10 #include <wingdi.h>
11 #include <winddi.h>
12
13 void Test_EngDeleteSemaphore()
14 {
15 HSEMAPHORE hsem;
16 PRTL_CRITICAL_SECTION lpcrit;
17
18 /* test Create then delete */
19 hsem = EngCreateSemaphore();
20 ok(hsem != NULL, "EngCreateSemaphore failed\n");
21 if (!hsem) return;
22 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
23 EngDeleteSemaphore(hsem);
24
25 // ok(lpcrit->LockCount > 0); doesn't work on XP
26 ok(lpcrit->RecursionCount == 0, "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 /* test EngAcquireSemaphore and release it, then delete it */
41 hsem = EngCreateSemaphore();
42 ok(hsem != NULL, "EngCreateSemaphore failed\n");
43 if (!hsem) return;
44 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
45
46 EngAcquireSemaphore(hsem);
47 EngReleaseSemaphore(hsem);
48 EngDeleteSemaphore(hsem);
49
50 //ok(lpcrit->LockCount > 0, "lpcrit->LockCount=%ld\n", lpcrit->LockCount);
51 ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount);
52 ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread);
53 ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore);
54 ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount);
55
56 //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n");
57 if (lpcrit->DebugInfo)
58 {
59 ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type);
60 ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex);
61 //ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount);
62 //ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount);
63 }
64 }
65
66 START_TEST(EngDeleteSemaphore)
67 {
68 Test_EngDeleteSemaphore();
69 }
70