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:
Magnus Olsen 2008-06-01 17:33:51 +00:00
parent c3f50e79c8
commit ba14ded010
5 changed files with 158 additions and 15 deletions

View file

@ -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 },

View 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;
}

View file

@ -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;
}

View 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;
}

View 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;
}