[4/6]kernel32/tests: test Fiber Local Storage functions

André Hentschel nerv at dawncrow.de
Sun Jan 24 09:30:49 CST 2010


---
 dlls/kernel32/tests/fiber.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/fiber.c b/dlls/kernel32/tests/fiber.c
index 9358963..95e9953 100644
--- a/dlls/kernel32/tests/fiber.c
+++ b/dlls/kernel32/tests/fiber.c
@@ -28,6 +28,10 @@ static void (WINAPI *pDeleteFiber)(LPVOID);
 static LPVOID (WINAPI *pConvertThreadToFiberEx)(LPVOID,DWORD);
 static LPVOID (WINAPI *pCreateFiberEx)(SIZE_T,SIZE_T,DWORD,LPFIBER_START_ROUTINE,LPVOID);
 static BOOL (WINAPI *pIsThreadAFiber)(void);
+static DWORD (WINAPI *pFlsAlloc)(PFLS_CALLBACK_FUNCTION);
+static BOOL (WINAPI *pFlsFree)(DWORD);
+static PVOID (WINAPI *pFlsGetValue)(DWORD);
+static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID);
 
 static LPVOID fibers[2];
 static BYTE testparam = 185;
@@ -45,9 +49,18 @@ static VOID init_funcs(void)
     X(ConvertThreadToFiberEx);
     X(CreateFiberEx);
     X(IsThreadAFiber);
+    X(FlsAlloc);
+    X(FlsFree);
+    X(FlsGetValue);
+    X(FlsSetValue);
 #undef X
 }
 
+static VOID WINAPI FiberLocalStorageProc(PVOID lpFlsData)
+{
+    ok(lpFlsData == (PVOID) 1587, "FlsData expected not to be changed\n");
+}
+
 static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
 {
     BYTE *tparam = (BYTE *)lpFiberParameter;
@@ -136,6 +149,29 @@ static void test_FiberHandling(void)
     ok(!pIsThreadAFiber(), "IsThreadAFiber reported TRUE\n");
 }
 
+static void test_FiberLocalStorage(PFLS_CALLBACK_FUNCTION cbfunc)
+{
+    DWORD fls;
+    BOOL ret;
+    PVOID val = (PVOID) 1587;
+
+    if (!pFlsAlloc)
+    {
+        win_skip( "Fiber Local Storage not supported\n" );
+        return;
+    }
+
+    fls = pFlsAlloc(cbfunc);
+    ok(fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %d\n", GetLastError());
+
+    ret = pFlsSetValue(fls, val);
+    ok(ret, "FlsSetValue failed\n");
+    ok(val == pFlsGetValue(fls), "FlsGetValue failed\n");
+
+    ret = pFlsFree(fls);
+    ok(ret, "FlsFree failed\n");
+}
+
 START_TEST(fiber)
 {
     init_funcs();
@@ -147,4 +183,6 @@ START_TEST(fiber)
     }
 
     test_FiberHandling();
+    test_FiberLocalStorage(NULL);
+    test_FiberLocalStorage(FiberLocalStorageProc);
 }
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list