2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for EngAcquireSemaphore
5 * PROGRAMMERS: Magnus Olsen
10 void Test_EngAcquireSemaphore()
13 PRTL_CRITICAL_SECTION lpcrit
;
15 hsem
= EngCreateSemaphore();
16 ok(hsem
!= NULL
, "EngCreateSemaphore failed\n");
18 lpcrit
= (PRTL_CRITICAL_SECTION
)hsem
;
21 EngAcquireSemaphore(hsem
);
22 // ok(lpcrit->LockCount == -2); doesn't work on XP
23 ok(lpcrit
->RecursionCount
== 1, "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
);
28 ok(lpcrit
->DebugInfo
!= NULL
, "no DebugInfo\n");
29 if (lpcrit
->DebugInfo
)
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
);
37 EngReleaseSemaphore(hsem
);
38 EngDeleteSemaphore(hsem
);
40 /* NULL pointer test */
41 // Note NULL pointer test crash in Vista */
42 // EngAcquireSemaphore(NULL);
44 /* negtive pointer test */
45 // Note negtive pointer test crash in Vista */
46 // EngAcquireSemaphore((HSEMAPHORE)-1);
48 /* try with deleted Semaphore */
49 // Note deleted Semaphore pointer test does freze the whole program in Vista */
50 // EngAcquireSemaphore(hsem);
53 START_TEST(EngAcquireSemaphore
)
55 Test_EngAcquireSemaphore();