mirror of
https://github.com/reactos/reactos.git
synced 2025-07-24 15:23:39 +00:00
Adding complete test kit for EngCreateSemaphore, EngAcquireSemaphore, EngDeleteSemaphore, EngReleaseSemaphore
I think it testing all case it can now, and also split up some test to EngDeleteSemaphore and EngReleaseSemaphore and EngAcquireSemaphore, that was in EngCreateSemaphore svn path=/trunk/; revision=33816
This commit is contained in:
parent
c3f50e79c8
commit
ba14ded010
5 changed files with 158 additions and 15 deletions
|
@ -12,6 +12,9 @@
|
|||
#include "tests/CreatePen.c"
|
||||
#include "tests/CreateRectRgn.c"
|
||||
#include "tests/EngCreateSemaphore.c"
|
||||
#include "tests/EngAcquireSemaphore.c"
|
||||
#include "tests/EngDeleteSemaphore.c"
|
||||
#include "tests/EngReleaseSemaphore.c"
|
||||
#include "tests/ExtCreatePen.c"
|
||||
#include "tests/GdiConvertBitmap.c"
|
||||
#include "tests/GdiConvertBrush.c"
|
||||
|
@ -53,6 +56,9 @@ TESTENTRY TestList[] =
|
|||
{ L"CreateFont", Test_CreateFont },
|
||||
{ L"CreatePen", Test_CreatePen },
|
||||
{ L"EngCreateSemaphore", Test_EngCreateSemaphore },
|
||||
{ L"EngAcquireSemaphore", Test_EngAcquireSemaphore },
|
||||
{ L"EngDeleteSemaphore", Test_EngDeleteSemaphore },
|
||||
{ L"EngReleaseSemaphore", Test_EngReleaseSemaphore },
|
||||
{ L"CreateRectRgn", Test_CreateRectRgn },
|
||||
{ L"ExtCreatePen", Test_ExtCreatePen },
|
||||
{ L"GdiConvertBitmap", Test_GdiConvertBitmap },
|
||||
|
|
45
rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c
Normal file
45
rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* Simple test of EngAcquireSemaphore only check if we got a lock or not */
|
||||
INT
|
||||
Test_EngAcquireSemaphore(PTESTINFO pti)
|
||||
{
|
||||
|
||||
HSEMAPHORE hsem;
|
||||
PRTL_CRITICAL_SECTION lpcrit;
|
||||
|
||||
hsem = EngCreateSemaphore();
|
||||
RTEST ( hsem != NULL );
|
||||
ASSERT(hsem != NULL);
|
||||
lpcrit = (PRTL_CRITICAL_SECTION) hsem;
|
||||
|
||||
/* real data test */
|
||||
EngAcquireSemaphore(hsem);
|
||||
RTEST (lpcrit->LockCount == -2);
|
||||
RTEST (lpcrit->RecursionCount == 1);
|
||||
RTEST (lpcrit->OwningThread != 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->DebugInfo->Type == 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex == 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount == 0);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount == 0);
|
||||
|
||||
EngReleaseSemaphore(hsem);
|
||||
EngDeleteSemaphore(hsem);
|
||||
|
||||
/* NULL pointer test */
|
||||
// Note NULL pointer test crash in Vista */
|
||||
// EngAcquireSemaphore(NULL);
|
||||
|
||||
/* negtive pointer test */
|
||||
// Note negtive pointer test crash in Vista */
|
||||
// EngAcquireSemaphore((HSEMAPHORE)-1);
|
||||
|
||||
/* try with deleted Semaphore */
|
||||
// Note deleted Semaphore pointer test does freze the whole program in Vista */
|
||||
// EngAcquireSemaphore(hsem);
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
}
|
||||
|
|
@ -26,21 +26,6 @@ Test_EngCreateSemaphore(PTESTINFO pti)
|
|||
|
||||
EngDeleteSemaphore(hsem);
|
||||
|
||||
RTEST (lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->LockCount > 0);
|
||||
RTEST (lpcrit->RecursionCount == 0);
|
||||
RTEST (lpcrit->OwningThread == 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
// my (magnus olsen) value I getting back in vista RTEST (lpcrit->DebugInfo->Type == 0xA478);
|
||||
RTEST (lpcrit->DebugInfo->Type != 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount != 0);
|
||||
// my (magnus olsen) value I getting back RTEST in vista (lpcrit->DebugInfo->ContentionCount == 0x20000);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount != 0);
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
}
|
||||
|
||||
|
|
51
rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c
Normal file
51
rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
INT
|
||||
Test_EngDeleteSemaphore(PTESTINFO pti)
|
||||
{
|
||||
|
||||
HSEMAPHORE hsem;
|
||||
PRTL_CRITICAL_SECTION lpcrit;
|
||||
|
||||
/* test Create then delete */
|
||||
hsem = EngCreateSemaphore();
|
||||
ASSERT(hsem != NULL);
|
||||
lpcrit = (PRTL_CRITICAL_SECTION) hsem;
|
||||
EngDeleteSemaphore(hsem);
|
||||
|
||||
RTEST (lpcrit->LockCount > 0);
|
||||
RTEST (lpcrit->RecursionCount == 0);
|
||||
RTEST (lpcrit->OwningThread == 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->DebugInfo->Type != 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount != 0);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount != 0);
|
||||
|
||||
|
||||
/* test EngAcquireSemaphore and release it, then delete it */
|
||||
hsem = EngCreateSemaphore();
|
||||
ASSERT(hsem != NULL);
|
||||
lpcrit = (PRTL_CRITICAL_SECTION) hsem;
|
||||
|
||||
EngAcquireSemaphore(hsem);
|
||||
EngReleaseSemaphore(hsem);
|
||||
EngDeleteSemaphore(hsem);
|
||||
|
||||
RTEST (lpcrit->LockCount > 0);
|
||||
RTEST (lpcrit->RecursionCount == 0);
|
||||
RTEST (lpcrit->OwningThread == 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->DebugInfo->Type != 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount != 0);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount != 0);
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
}
|
||||
|
56
rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c
Normal file
56
rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* Simple test of EngAcquireSemaphore only check if we got a lock or not */
|
||||
INT
|
||||
Test_EngReleaseSemaphore(PTESTINFO pti)
|
||||
{
|
||||
|
||||
HSEMAPHORE hsem;
|
||||
PRTL_CRITICAL_SECTION lpcrit;
|
||||
|
||||
hsem = EngCreateSemaphore();
|
||||
ASSERT(hsem != NULL);
|
||||
|
||||
lpcrit = (PRTL_CRITICAL_SECTION) hsem;
|
||||
|
||||
EngAcquireSemaphore(hsem);
|
||||
EngReleaseSemaphore(hsem);
|
||||
|
||||
RTEST (lpcrit->LockCount != 0);
|
||||
RTEST (lpcrit->RecursionCount == 0);
|
||||
RTEST (lpcrit->OwningThread == 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->DebugInfo->Type == 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex == 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount == 0);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount == 0);
|
||||
|
||||
EngDeleteSemaphore(hsem);
|
||||
|
||||
/* try with deleted Semaphore */
|
||||
EngReleaseSemaphore(hsem);
|
||||
RTEST (lpcrit->LockCount > 0);
|
||||
RTEST (lpcrit->RecursionCount != 0);
|
||||
RTEST (lpcrit->OwningThread == 0);
|
||||
RTEST (lpcrit->LockSemaphore == 0);
|
||||
RTEST (lpcrit->SpinCount == 0);
|
||||
|
||||
ASSERT(lpcrit->DebugInfo != NULL);
|
||||
RTEST (lpcrit->DebugInfo->Type != 0);
|
||||
RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0);
|
||||
RTEST (lpcrit->DebugInfo->EntryCount != 0);
|
||||
RTEST (lpcrit->DebugInfo->ContentionCount != 0);
|
||||
|
||||
/* NULL pointer test */
|
||||
// Note NULL pointer test crash in Vista */
|
||||
// EngReleaseSemaphore(NULL);
|
||||
|
||||
/* negtive pointer test */
|
||||
// Note negtive pointer test crash in Vista */
|
||||
// EngReleaseSemaphore((HSEMAPHORE)-1);
|
||||
|
||||
|
||||
return APISTATUS_NORMAL;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue