d8c1218e3eef8d760d655774d3e62d306398d81a
[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 "precomp.h"
9
10 void Test_EngDeleteSemaphore()
11 {
12 HSEMAPHORE hsem;
13 PRTL_CRITICAL_SECTION lpcrit;
14
15 /* test Create then delete */
16 hsem = EngCreateSemaphore();
17 ok(hsem != NULL, "EngCreateSemaphore failed\n");
18 if (!hsem) return;
19 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
20 EngDeleteSemaphore(hsem);
21
22 // ok(lpcrit->LockCount > 0); doesn't work on XP
23 ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount);
24 ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread);
25 ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore);
26 ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount);
27
28 //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n");
29 if (lpcrit->DebugInfo)
30 {
31 ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type);
32 ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex);
33 //ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount);
34 //ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount);
35 }
36
37 /* test EngAcquireSemaphore and release it, then delete it */
38 hsem = EngCreateSemaphore();
39 ok(hsem != NULL, "EngCreateSemaphore failed\n");
40 if (!hsem) return;
41 lpcrit = (PRTL_CRITICAL_SECTION)hsem;
42
43 EngAcquireSemaphore(hsem);
44 EngReleaseSemaphore(hsem);
45 EngDeleteSemaphore(hsem);
46
47 //ok(lpcrit->LockCount > 0, "lpcrit->LockCount=%ld\n", lpcrit->LockCount);
48 ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount);
49 ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread);
50 ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore);
51 ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount);
52
53 //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n");
54 if (lpcrit->DebugInfo)
55 {
56 ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type);
57 ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex);
58 //ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount);
59 //ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount);
60 }
61 }
62
63 START_TEST(EngDeleteSemaphore)
64 {
65 Test_EngDeleteSemaphore();
66 }
67