From ba14ded010d38624fa1b7f7594201016f4cbdec5 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sun, 1 Jun 2008 17:33:51 +0000 Subject: [PATCH] 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 --- rostests/apitests/gdi32api/testlist.c | 6 ++ .../gdi32api/tests/EngAcquireSemaphore.c | 45 +++++++++++++++ .../gdi32api/tests/EngCreateSemaphore.c | 15 ----- .../gdi32api/tests/EngDeleteSemaphore.c | 51 +++++++++++++++++ .../gdi32api/tests/EngReleaseSemaphore.c | 56 +++++++++++++++++++ 5 files changed, 158 insertions(+), 15 deletions(-) create mode 100644 rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c create mode 100644 rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c create mode 100644 rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c diff --git a/rostests/apitests/gdi32api/testlist.c b/rostests/apitests/gdi32api/testlist.c index f2563199340..6a9a78c6c34 100644 --- a/rostests/apitests/gdi32api/testlist.c +++ b/rostests/apitests/gdi32api/testlist.c @@ -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 }, diff --git a/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c b/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c new file mode 100644 index 00000000000..3c9fcf559e5 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c @@ -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; +} + diff --git a/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c b/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c index 272229c92f5..23a1d9a48c7 100644 --- a/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c +++ b/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c @@ -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; } diff --git a/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c b/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c new file mode 100644 index 00000000000..5d85ace8e67 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c @@ -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; +} + diff --git a/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c b/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c new file mode 100644 index 00000000000..fa25bc2d3d9 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c @@ -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; +} +