Hua Meng : msvcp120: Add test for Concurrent_vector_Internal_compact.

Alexandre Julliard julliard at winehq.org
Fri Jun 22 18:32:37 CDT 2018


Module: wine
Branch: master
Commit: 43d9e3f616b81ddf1d3b01330afe3e4363284198
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=43d9e3f616b81ddf1d3b01330afe3e4363284198

Author: Hua Meng <161220092 at smail.nju.edu.cn>
Date:   Fri Jun 22 18:15:16 2018 +0800

msvcp120: Add test for Concurrent_vector_Internal_compact.

Signed-off-by: Hua meng <161220092 at smail.nju.edu.cn>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp120/tests/msvcp120.c | 102 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 1 deletion(-)

diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index aec66fb..0ec9fbd 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -27,6 +27,11 @@
 DWORD expect_idx;
 static int vector_alloc_count;
 static int vector_elem_count;
+typedef struct blocks_to_free{
+    size_t first_block;
+    void *blocks[sizeof(void*)*8];
+    int size_check;
+}compact_block;
 
 #define DEFINE_EXPECT(func) \
     BOOL expect_ ## func, called_ ## func
@@ -115,6 +120,8 @@ static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void
         const void *b );
 static void * (WINAPI *call_thiscall_func4)( void *func, void *this, const void *a,
         const void *b, const void *c );
+static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a,
+        const void *b, const void *c, const void *d );
 static void * (WINAPI *call_thiscall_func6)( void *func, void *this, const void *a,
         const void *b, const void *c, const void *d, const void *e );
 
@@ -131,6 +138,7 @@ static void init_thiscall_thunk(void)
     call_thiscall_func2 = (void *)thunk;
     call_thiscall_func3 = (void *)thunk;
     call_thiscall_func4 = (void *)thunk;
+    call_thiscall_func5 = (void *)thunk;
     call_thiscall_func6 = (void *)thunk;
 }
 
@@ -140,6 +148,8 @@ static void init_thiscall_thunk(void)
         (const void*)(b))
 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),\
         (const void*)(b),(const void*)(c))
+#define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),\
+        (const void*)(b),(const void*)(c),(const void*)(d))
 #define call_func6(func,_this,a,b,c,d,e) call_thiscall_func6(func,_this,(const void*)(a),\
         (const void*)(b),(const void*)(c),(const void*)(d),(const void*)(e))
 #else
@@ -149,6 +159,7 @@ static void init_thiscall_thunk(void)
 #define call_func2(func,_this,a) func(_this,a)
 #define call_func3(func,_this,a,b) func(_this,a,b)
 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
+#define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
 #define call_func6(func,_this,a,b,c,d,e) func(_this,a,b,c,d,e)
 #endif /* __i386__ */
 
@@ -404,6 +415,9 @@ static void (__thiscall *p_vector_base_v4__Internal_assign)(
         void (__cdecl*)(void*, const void*, size_t), void (__cdecl*)(void*, const void*, size_t));
 static void (__thiscall *p_vector_base_v4__Internal_swap)(
         vector_base_v4*, const vector_base_v4*);
+static void* (__thiscall *p_vector_base_v4__Internal_compact)(
+        vector_base_v4*, size_t, void*, void (__cdecl*)(void*, size_t),
+        void (__cdecl*)(void*, const void*, size_t));
 
 static HMODULE msvcp;
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -552,6 +566,8 @@ static BOOL init(void)
                 "?_Internal_assign at _Concurrent_vector_base_v4@details at Concurrency@@IEAAXAEBV123 at _KP6AXPEAX1@ZP6AX2PEBX1 at Z5@Z");
         SET(p_vector_base_v4__Internal_swap,
                 "?_Internal_swap at _Concurrent_vector_base_v4@details at Concurrency@@IEAAXAEAV123@@Z");
+        SET(p_vector_base_v4__Internal_compact,
+                "?_Internal_compact at _Concurrent_vector_base_v4@details at Concurrency@@IEAAPEAX_KPEAXP6AX10 at ZP6AX1PEBX0@Z at Z");
     } else {
         SET(p_tr2_sys__File_size,
                 "?_File_size at sys@tr2 at std@@YA_KPBD at Z");
@@ -669,6 +685,8 @@ static BOOL init(void)
                 "?_Internal_assign at _Concurrent_vector_base_v4@details at Concurrency@@IAEXABV123 at IP6AXPAXI@ZP6AX1PBXI at Z4@Z");
         SET(p_vector_base_v4__Internal_swap,
                 "?_Internal_swap at _Concurrent_vector_base_v4@details at Concurrency@@IAEXAAV123@@Z");
+        SET(p_vector_base_v4__Internal_compact,
+                "?_Internal_compact at _Concurrent_vector_base_v4@details at Concurrency@@IAEPAXIPAXP6AX0I at ZP6AX0PBXI@Z at Z");
 #else
         SET(p__Thrd_current,
                 "_Thrd_current");
@@ -714,6 +732,9 @@ static BOOL init(void)
                 "?_Internal_assign at _Concurrent_vector_base_v4@details at Concurrency@@IAAXABV123 at IP6AXPAXI@ZP6AX1PBXI at Z4@Z");
         SET(p_vector_base_v4__Internal_swap,
                 "?_Internal_swap at _Concurrent_vector_base_v4@details at Concurrency@@IAAXAAV123@@Z");
+        SET(p_vector_base_v4__Internal_compact,
+                "?_Internal_compact at _Concurrent_vector_base_v4@details at Concurrency@@IAAPAXIPAXP6AX0I at ZP6AX0PBXI@Z at Z");
+
 #endif
     }
     SET(p__Thrd_equal,
@@ -2734,7 +2755,8 @@ static void test_vector_base_v4(void)
 {
     vector_base_v4 vector, v2;
     size_t idx, size;
-    int *data;
+    compact_block b;
+    int i, *data;
 
     concurrent_vector_int_ctor(&vector);
 
@@ -2892,6 +2914,84 @@ static void test_vector_base_v4(void)
     CHECK_CALLED(concurrent_vector_int_destroy);
     concurrent_vector_int_dtor(&v2);
 
+    /* test for _Internal_compact */
+    concurrent_vector_int_ctor(&v2);
+    for(i=0; i<2; i++) {
+        SET_EXPECT(concurrent_vector_int_alloc);
+        data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+        CHECK_CALLED(concurrent_vector_int_alloc);
+        ok(data != NULL, "_Internal_push_back returned NULL\n");
+        data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+        ok(data != NULL, "_Internal_push_back returned NULL\n");
+        vector_elem_count += 2;
+    }
+    ok(v2.first_block == 1, "v2.first_block got %ld expected 1\n", (long)v2.first_block);
+    ok(v2.early_size == 4, "v2.early_size got %ld expected 4\n", (long)v2.early_size);
+    memset(&b, 0xff, sizeof(b));
+    SET_EXPECT(concurrent_vector_int_alloc);
+    SET_EXPECT(concurrent_vector_int_copy);
+    SET_EXPECT(concurrent_vector_int_destroy);
+    data = call_func5(p_vector_base_v4__Internal_compact,
+            &v2, sizeof(int), &b, concurrent_vector_int_destroy,
+            concurrent_vector_int_copy);
+    CHECK_CALLED(concurrent_vector_int_alloc);
+    CHECK_CALLED(concurrent_vector_int_copy);
+    CHECK_CALLED(concurrent_vector_int_destroy);
+    ok(v2.first_block == 2, "v2.first_block got %ld expected 2\n", (long)v2.first_block);
+    ok(v2.early_size == 4,"v2.early_size got %ld expected 4\n", (long)v2.early_size);
+    ok(b.first_block == 1, "b.first_block got %ld expected 1\n", (long)b.first_block);
+    for(i=0; i<2; i++){
+        ok(b.blocks[i] != NULL, "b.blocks[%d] got NULL\n", i);
+        free(b.blocks[i]);
+        vector_alloc_count--;
+    }
+    for(; i<ARRAY_SIZE(b.blocks); i++)
+        ok(!b.blocks[i], "b.blocks[%d] != NULL\n", i);
+    ok(b.size_check == -1, "b.size_check = %x\n", b.size_check);
+
+    SET_EXPECT(concurrent_vector_int_alloc);
+    data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+    CHECK_CALLED(concurrent_vector_int_alloc);
+    ok(data != NULL, "_Internal_push_back returned NULL\n");
+    for(i=0; i<3; i++){
+        data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+        ok(data != NULL, "_Internal_push_back returned NULL\n");
+    }
+    SET_EXPECT(concurrent_vector_int_alloc);
+    data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+    CHECK_CALLED(concurrent_vector_int_alloc);
+    ok(data != NULL, "_Internal_push_back returned NULL\n");
+    vector_elem_count += 5;
+    ok(v2.first_block == 2, "v2.first_block got %ld expected 2\n", (long)v2.first_block);
+    ok(v2.early_size == 9, "v2.early_size got %ld expected 9\n", (long)v2.early_size);
+    memset(&b, 0xff, sizeof(b));
+    SET_EXPECT(concurrent_vector_int_alloc);
+    SET_EXPECT(concurrent_vector_int_copy);
+    SET_EXPECT(concurrent_vector_int_destroy);
+    data = call_func5(p_vector_base_v4__Internal_compact,
+            &v2, sizeof(int), &b, concurrent_vector_int_destroy,
+            concurrent_vector_int_copy);
+    CHECK_CALLED(concurrent_vector_int_alloc);
+    CHECK_CALLED(concurrent_vector_int_copy);
+    CHECK_CALLED(concurrent_vector_int_destroy);
+    ok(v2.first_block == 4, "v2.first_block got %ld expected 4\n", (long)v2.first_block);
+    ok(v2.early_size == 9, "v2.early_size got %ld expected 9\n", (long)v2.early_size);
+    ok(b.first_block == 2, "b.first_block got %ld expected 2\n", (long)b.first_block);
+    for(i=0; i<4; i++){
+        ok(b.blocks[i] != NULL, "b.blocks[%d] got NULL\n", i);
+        /* only b.blocks[0] and b.blocks[>=b.first_block] are used */
+        if(i == b.first_block-1) continue;
+        free(b.blocks[i]);
+        vector_alloc_count--;
+    }
+    for(; i<ARRAY_SIZE(b.blocks); i++)
+        ok(!b.blocks[i], "b.blocks[%d] != NULL\n", i);
+    SET_EXPECT(concurrent_vector_int_destroy);
+    size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
+            &v2, concurrent_vector_int_destroy);
+    CHECK_CALLED(concurrent_vector_int_destroy);
+    concurrent_vector_int_dtor(&v2);
+
     SET_EXPECT(concurrent_vector_int_destroy);
     size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
             &vector, concurrent_vector_int_destroy);




More information about the wine-cvs mailing list