Robert Shearman : kernel: Add a test for mutexes.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jun 15 07:12:37 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 01739483008b4a03aabf33224ca162560ab99b0a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=01739483008b4a03aabf33224ca162560ab99b0a

Author: Robert Shearman <rob at codeweavers.com>
Date:   Wed Jun 14 13:20:31 2006 +0100

kernel: Add a test for mutexes.

---

 dlls/kernel/tests/sync.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel/tests/sync.c b/dlls/kernel/tests/sync.c
index e50f2f2..321f5cf 100644
--- a/dlls/kernel/tests/sync.c
+++ b/dlls/kernel/tests/sync.c
@@ -126,7 +126,34 @@ static void test_signalandwait(void)
     CloseHandle(file);
 }
 
+static void test_mutex(void)
+{
+    DWORD wait_ret;
+    BOOL ret;
+    HANDLE hCreated;
+    HANDLE hOpened;
+
+    hCreated = CreateMutex(NULL, FALSE, "WineTestMutex");
+    ok(hCreated != NULL, "CreateMutex failed with error %ld\n", GetLastError());
+    wait_ret = WaitForSingleObject(hCreated, INFINITE);
+    ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error 0x%08lx\n", wait_ret);
+
+    /* yes, opening with just READ_CONTROL access allows us to successfully
+     * call ReleaseMutex */
+    hOpened = OpenMutex(READ_CONTROL, FALSE, "WineTestMutex");
+    ok(hOpened != NULL, "OpenMutex failed with error %ld\n", GetLastError());
+    ret = ReleaseMutex(hOpened);
+    todo_wine ok(ret, "ReleaseMutex failed with error %ld\n", GetLastError());
+    ret = ReleaseMutex(hCreated);
+    todo_wine ok(!ret && (GetLastError() == ERROR_NOT_OWNER),
+        "ReleaseMutex should have failed with ERROR_NOT_OWNER instead of %ld\n", GetLastError());
+
+    CloseHandle(hOpened);
+    CloseHandle(hCreated);
+}
+
 START_TEST(sync)
 {
     test_signalandwait();
+    test_mutex();
 }




More information about the wine-cvs mailing list