[PATCH] msvcp120: Add tests for concurrent_vector_Internal_push_back and capacity.
Zhiyi Zhang
zzhang at codeweavers.com
Tue Jun 5 02:00:14 CDT 2018
On Tue 6 5 14:39, Hua Meng wrote:
> Signed-off-by: Hua meng <161220092 at smail.nju.edu.cn>
> ---
> dlls/msvcp120/tests/msvcp120.c | 120 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 117 insertions(+), 3 deletions(-)
> mode change 100644 => 100755 dlls/msvcp120/tests/msvcp120.c
Hi,
I don't think you need to change the file permission from 644 to 755.
And there are some style inconsistencies.
Thanks,
Zhiyi Zhang
>
> diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
> old mode 100644
> new mode 100755
> index dfd2d06..84e20bd
> --- a/dlls/msvcp120/tests/msvcp120.c
> +++ b/dlls/msvcp120/tests/msvcp120.c
> @@ -35,6 +35,7 @@ struct expect_struct {
> DEFINE_EXPECT(queue_char__Move_item);
> DEFINE_EXPECT(queue_char__Copy_item);
> DEFINE_EXPECT(queue_char__Assign_and_destroy_item);
> + DEFINE_EXPECT(concurrent_vector_int_alloc);
> };
>
> #define SET_EXPECT(func) \
> @@ -105,6 +106,8 @@ struct thiscall_thunk
>
> static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
> static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
> +static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a,
> + const void *b );
>
> static void init_thiscall_thunk(void)
> {
> @@ -117,17 +120,19 @@ static void init_thiscall_thunk(void)
> thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
> call_thiscall_func1 = (void *)thunk;
> call_thiscall_func2 = (void *)thunk;
> + call_thiscall_func3 = (void *)thunk;
> }
>
> #define call_func1(func,_this) call_thiscall_func1(func,_this)
> #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
> -
> +#define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),\
> + (const void*)(b))
> #else
>
> #define init_thiscall_thunk()
> #define call_func1(func,_this) func(_this)
> #define call_func2(func,_this,a) func(_this,a)
> -
> +#define call_func3(func,_this,a,b) func(_this,a,b)
> #endif /* __i386__ */
>
> static inline float __port_infinity(void)
> @@ -360,6 +365,19 @@ static void (__thiscall *p_queue_base_v4__Internal_move_push)(queue_base_v4*, vo
> static MSVCP_bool (__thiscall *p_queue_base_v4__Internal_pop_if_present)(queue_base_v4*, void*);
> static void (__thiscall *p_queue_base_v4__Internal_finish_clear)(queue_base_v4*);
>
> +typedef struct vector_base_v4
> +{
> + void* (__cdecl *allocator)(struct vector_base_v4 *, size_t);
> + void *storage[3];
> + size_t first_block;
> + size_t early_size;
> + void **segment;
> +} vector_base_v4;
> +
> +static void (__thiscall *p_vector_base_v4_dtor)(vector_base_v4*);
> +static size_t (__thiscall *p_vector_base_v4__Internal_capacity)(vector_base_v4*);
> +static void* (__thiscall *p_vector_base_v4__Internal_push_back)(vector_base_v4*, size_t, size_t*);
> +
> static HMODULE msvcp;
> #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
> #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
> @@ -493,7 +511,13 @@ static BOOL init(void)
> "?_Internal_pop_if_present at _Concurrent_queue_base_v4@details at Concurrency@@IEAA_NPEAX at Z");
> SET(p_queue_base_v4__Internal_finish_clear,
> "?_Internal_finish_clear at _Concurrent_queue_base_v4@details at Concurrency@@IEAAXXZ");
> - } else {
> + SET(p_vector_base_v4_dtor,
> + "??1_Concurrent_vector_base_v4 at details@Concurrency@@IEAA at XZ");
> + SET(p_vector_base_v4__Internal_capacity,
> + "?_Internal_capacity at _Concurrent_vector_base_v4@details at Concurrency@@IEBA_KXZ");
> + SET(p_vector_base_v4__Internal_push_back,
> + "?_Internal_push_back at _Concurrent_vector_base_v4@details at Concurrency@@IEAAPEAX_KAEA_K at Z");
> +} else {
> SET(p_tr2_sys__File_size,
> "?_File_size at sys@tr2 at std@@YA_KPBD at Z");
> SET(p_tr2_sys__File_size_wchar,
> @@ -596,6 +620,12 @@ static BOOL init(void)
> "?_Internal_pop_if_present at _Concurrent_queue_base_v4@details at Concurrency@@IAE_NPAX at Z");
> SET(p_queue_base_v4__Internal_finish_clear,
> "?_Internal_finish_clear at _Concurrent_queue_base_v4@details at Concurrency@@IAEXXZ");
> + SET(p_vector_base_v4_dtor,
> + "??1_Concurrent_vector_base_v4 at details@Concurrency@@IAE at XZ");
> + SET(p_vector_base_v4__Internal_capacity,
> + "?_Internal_capacity at _Concurrent_vector_base_v4@details at Concurrency@@IBEIXZ");
> + SET(p_vector_base_v4__Internal_push_back,
> + "?_Internal_push_back at _Concurrent_vector_base_v4@details at Concurrency@@IAEPAXIAAI at Z");
> #else
> SET(p__Thrd_current,
> "_Thrd_current");
> @@ -627,6 +657,12 @@ static BOOL init(void)
> "?_Internal_pop_if_present at _Concurrent_queue_base_v4@details at Concurrency@@IAA_NPAX at Z");
> SET(p_queue_base_v4__Internal_finish_clear,
> "?_Internal_finish_clear at _Concurrent_queue_base_v4@details at Concurrency@@IAAXXZ");
> + SET(p_vector_base_v4_dtor,
> + "??1_Concurrent_vector_base_v4 at details@Concurrency@@IAA at XZ");
> + SET(p_vector_base_v4__Internal_capacity,
> + "?_Internal_capacity at _Concurrent_vector_base_v4@details at Concurrency@@IBAIXZ");
> + SET(p_vector_base_v4__Internal_push_back,
> + "?_Internal_push_back at _Concurrent_vector_base_v4@details at Concurrency@@IAAPAXIAAI at Z");
> #endif
> }
> SET(p__Thrd_equal,
> @@ -2396,6 +2432,83 @@ static DWORD WINAPI queue_pop_thread(void*arg)
> return 0;
> }
>
> +static void* __cdecl concurrent_vector_int_alloc(vector_base_v4 *this, size_t n)
> +{
> + CHECK_EXPECT(concurrent_vector_int_alloc);
> + return malloc(n*sizeof(int));
> +}
> +
> +static void concurrent_vector_int_ctor(vector_base_v4 *this)
> +{
> + memset(this, 0, sizeof(*this));
> + this->allocator = concurrent_vector_int_alloc;
> + this->segment = &this->storage[0];
> +}
> +
> +static void test_vector_base_v4(void)
> +{
> + vector_base_v4 vector;
> + size_t idx;
> + size_t size;
> + int *data;
> +
> + /* test for concurrent_vector_base_v4__Internal_push_back and _Internal_capacity */
> + concurrent_vector_int_ctor(&vector);
> +
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 0, "size of vector got %ld expected %d\n", (long)size, 0);
> +
> + SET_EXPECT(concurrent_vector_int_alloc);
> + data = call_func3(p_vector_base_v4__Internal_push_back, &vector, sizeof(int), &idx);
> + CHECK_CALLED(concurrent_vector_int_alloc);
> + todo_wine ok(data != NULL, "_Internal_push_back returned NULL\n");
> + if(!data){
> + skip("_Internal_capacity not yet implemented\n");
> + return;
> + }
> + todo_wine ok(idx == 0, "idx got %ld expected %d\n", (long)idx, 0);
> + *data = 1;
> + todo_wine ok(data == vector.storage[0], "vector.storage[0] got %p expected %p\n", vector.storage[0], data);
> + todo_wine ok(vector.first_block == 1, "vector.first_block got %ld expected %d\n", (long)vector.first_block, 1);
> + todo_wine ok(vector.early_size == 1, "vector.early_size got %ld expected %d\n", (long)vector.early_size, 1);
> +
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 2, "size of vector got %ld expected %d\n", (long)size, 2);
> +
> + data = call_func3(p_vector_base_v4__Internal_push_back, &vector, sizeof(int), &idx);
> + todo_wine ok(data != NULL, "_Internal_push_back returned NULL\n");
> + todo_wine ok(idx == 1, "idx got %ld expected %d\n", (long)idx, 1);
> + *data = 2;
> + todo_wine ok(vector.first_block == 1, "vector.first_block got %ld expected %d\n", (long)vector.first_block, 1);
> + todo_wine ok(vector.early_size == 2, "vector.early_size got %ld expected %d\n", (long)vector.early_size, 2);
> +
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 2, "size of vector got %ld expected %d\n", (long)size, 2);
> +
> + SET_EXPECT(concurrent_vector_int_alloc);
> + data = call_func3(p_vector_base_v4__Internal_push_back, &vector, sizeof(int), &idx);
> + CHECK_CALLED(concurrent_vector_int_alloc);
> + todo_wine ok(data != NULL, "_Internal_push_back returned NULL\n");
> + todo_wine ok(idx == 2, "idx got %ld expected %d\n", (long)idx, 2);
> + *data = 3;
> + todo_wine ok(vector.first_block == 1, "vector.first_block got %ld expected %d\n", (long)vector.first_block, 1);
> + todo_wine ok(vector.early_size == 3, "vector.early_size got %ld expected %d\n", (long)vector.early_size, 3);
> +
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 4, "size of vector got %ld expected %d\n", (long)size, 4);
> +
> + data = call_func3(p_vector_base_v4__Internal_push_back, &vector, sizeof(int), &idx);
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 4, "size of vector got %ld expected %d\n", (long)size, 4);
> +
> + SET_EXPECT(concurrent_vector_int_alloc);
> + data = call_func3(p_vector_base_v4__Internal_push_back, &vector, sizeof(int), &idx);
> + CHECK_CALLED(concurrent_vector_int_alloc);
> + size = (size_t)call_func1(p_vector_base_v4__Internal_capacity, &vector);
> + todo_wine ok(size == 8, "size of vector got %ld expected %d\n", (long)size, 8);
> +
> + call_func1(p_vector_base_v4_dtor, &vector);
> +}
> static void test_queue_base_v4(void)
> {
> queue_base_v4 queue;
> @@ -2626,6 +2739,7 @@ START_TEST(msvcp120)
>
> test_vector_base_v4__Segment_index_of();
> test_queue_base_v4();
> + test_vector_base_v4();
>
> test_vbtable_size_exports();
>
>
More information about the wine-devel
mailing list