2010-03-20 00:32:17 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Detlef Riekenberg
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2011-01-18 17:06:07 +01:00
|
|
|
#include <math.h>
|
2011-01-26 01:59:13 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <share.h>
|
|
|
|
#include <sys/stat.h>
|
2011-05-24 17:23:57 +02:00
|
|
|
#include <time.h>
|
|
|
|
#include <locale.h>
|
2010-03-20 00:32:17 +01:00
|
|
|
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2010-10-24 23:41:23 +02:00
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
2012-07-26 11:06:37 +02:00
|
|
|
do { \
|
|
|
|
expect_ ## func = TRUE; \
|
|
|
|
errno = 0xdeadbeef; \
|
|
|
|
}while(0)
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
#define CHECK_EXPECT2(func) \
|
|
|
|
do { \
|
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
2012-07-26 11:06:37 +02:00
|
|
|
#define CHECK_CALLED(func,error) \
|
2010-10-24 23:41:23 +02:00
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
2012-07-26 11:06:37 +02:00
|
|
|
ok( errno == (error), "got errno %u instead of %u\n", errno, (error) ); \
|
2010-10-24 23:41:23 +02:00
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
DEFINE_EXPECT(invalid_parameter_handler);
|
|
|
|
|
2010-03-24 22:39:44 +01:00
|
|
|
static _invalid_parameter_handler (__cdecl *p_set_invalid_parameter_handler)(_invalid_parameter_handler);
|
2010-03-20 00:32:17 +01:00
|
|
|
typedef int (__cdecl *_INITTERM_E_FN)(void);
|
|
|
|
static int (__cdecl *p_initterm_e)(_INITTERM_E_FN *table, _INITTERM_E_FN *end);
|
2010-03-25 11:06:29 +01:00
|
|
|
static void* (__cdecl *p_encode_pointer)(void *);
|
|
|
|
static void* (__cdecl *p_decode_pointer)(void *);
|
2010-03-25 11:09:13 +01:00
|
|
|
static void* (__cdecl *p_encoded_null)(void);
|
2010-03-24 22:40:40 +01:00
|
|
|
static int *p_sys_nerr;
|
|
|
|
static int* (__cdecl *p__sys_nerr)(void);
|
|
|
|
static char **p_sys_errlist;
|
|
|
|
static char** (__cdecl *p__sys_errlist)(void);
|
2010-04-01 12:39:50 +02:00
|
|
|
static __int64 (__cdecl *p_strtoi64)(const char *, char **, int);
|
|
|
|
static unsigned __int64 (__cdecl *p_strtoui64)(const char *, char **, int);
|
2010-11-11 22:30:25 +01:00
|
|
|
static errno_t (__cdecl *p_itoa_s)(int,char*,size_t,int);
|
2010-11-15 22:00:10 +01:00
|
|
|
static int (__cdecl *p_wcsncat_s)(wchar_t *dst, size_t elem, const wchar_t *src, size_t count);
|
2010-11-17 17:07:58 +01:00
|
|
|
static void (__cdecl *p_qsort_s)(void *, size_t, size_t, int (__cdecl *)(void *, const void *, const void *), void *);
|
2012-07-16 20:36:10 +02:00
|
|
|
static void* (__cdecl *p_bsearch_s)(const void *, const void *, size_t, size_t,
|
|
|
|
int (__cdecl *compare)(void *, const void *, const void *), void *);
|
2010-11-27 20:40:14 +01:00
|
|
|
static int (__cdecl *p_controlfp_s)(unsigned int *, unsigned int, unsigned int);
|
2012-07-17 21:49:09 +02:00
|
|
|
static int (__cdecl *p_tmpfile_s)(FILE**);
|
2011-01-18 17:06:07 +01:00
|
|
|
static int (__cdecl *p_atoflt)(_CRT_FLOAT *, char *);
|
2011-01-19 23:21:11 +01:00
|
|
|
static unsigned int (__cdecl *p_set_abort_behavior)(unsigned int, unsigned int);
|
2011-01-26 01:59:13 +01:00
|
|
|
static int (__cdecl *p_sopen_s)(int*, const char*, int, int, int);
|
2011-01-26 23:56:30 +01:00
|
|
|
static int (__cdecl *p_wsopen_s)(int*, const wchar_t*, int, int, int);
|
2011-01-28 01:21:06 +01:00
|
|
|
static void* (__cdecl *p_realloc_crt)(void*, size_t);
|
|
|
|
static void* (__cdecl *p_malloc)(size_t);
|
|
|
|
static void (__cdecl *p_free)(void*);
|
2011-05-24 17:23:57 +02:00
|
|
|
static void* (__cdecl *p_getptd)(void);
|
|
|
|
static int* (__cdecl *p_errno)(void);
|
|
|
|
static __msvcrt_ulong* (__cdecl *p_doserrno)(void);
|
|
|
|
static void (__cdecl *p_srand)(unsigned int);
|
|
|
|
static char* (__cdecl *p_strtok)(char*, const char*);
|
|
|
|
static wchar_t* (__cdecl *p_wcstok)(wchar_t*, const wchar_t*);
|
2013-06-21 12:17:43 +02:00
|
|
|
static unsigned char* (__cdecl *p__mbstok)(unsigned char*, const unsigned char*);
|
2011-05-24 17:23:57 +02:00
|
|
|
static char* (__cdecl *p_strerror)(int);
|
|
|
|
static wchar_t* (__cdecl *p_wcserror)(int);
|
|
|
|
static char* (__cdecl *p_tmpnam)(char*);
|
|
|
|
static wchar_t* (__cdecl *p_wtmpnam)(wchar_t*);
|
|
|
|
static char* (__cdecl *p_asctime)(struct tm*);
|
|
|
|
static wchar_t* (__cdecl *p_wasctime)(struct tm*);
|
|
|
|
static struct tm* (__cdecl *p_localtime64)(__time64_t*);
|
|
|
|
static char* (__cdecl *p_ecvt)(double, int, int*, int*);
|
|
|
|
static int* (__cdecl *p_fpecode)(void);
|
|
|
|
static int (__cdecl *p_configthreadlocale)(int);
|
|
|
|
static void* (__cdecl *p_get_terminate)(void);
|
|
|
|
static void* (__cdecl *p_get_unexpected)(void);
|
2011-11-15 14:20:49 +01:00
|
|
|
static int (__cdecl *p__vswprintf_l)(wchar_t*, const wchar_t*, _locale_t, __ms_va_list);
|
|
|
|
static int (__cdecl *p_vswprintf_l)(wchar_t*, const wchar_t*, _locale_t, __ms_va_list);
|
2011-11-16 12:51:06 +01:00
|
|
|
static FILE* (__cdecl *p_fopen)(const char*, const char*);
|
|
|
|
static int (__cdecl *p_fclose)(FILE*);
|
|
|
|
static int (__cdecl *p_unlink)(const char*);
|
2013-08-21 22:13:36 +02:00
|
|
|
static int (__cdecl *p_access_s)(const char*, int);
|
2011-11-16 12:51:06 +01:00
|
|
|
static void (__cdecl *p_lock_file)(FILE*);
|
|
|
|
static void (__cdecl *p_unlock_file)(FILE*);
|
|
|
|
static int (__cdecl *p_fileno)(FILE*);
|
|
|
|
static int (__cdecl *p_feof)(FILE*);
|
|
|
|
static int (__cdecl *p_ferror)(FILE*);
|
|
|
|
static int (__cdecl *p_flsbuf)(int, FILE*);
|
2014-10-28 14:43:35 +01:00
|
|
|
static int (__cdecl *p_filbuf)(FILE*);
|
2012-04-16 18:11:37 +02:00
|
|
|
static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long);
|
2013-03-05 11:06:08 +01:00
|
|
|
static void** (__cdecl *p__pxcptinfoptrs)(void);
|
2014-05-07 12:08:06 +02:00
|
|
|
static void* (__cdecl *p__AdjustPointer)(void*, const void*);
|
2014-10-20 21:03:16 +02:00
|
|
|
static int (__cdecl *p_fflush_nolock)(FILE*);
|
2016-06-14 11:57:59 +02:00
|
|
|
static size_t (__cdecl *p_mbstowcs)(wchar_t*, const char*, size_t);
|
|
|
|
static size_t (__cdecl *p_wcstombs)(char*, const wchar_t*, size_t);
|
|
|
|
static char* (__cdecl *p_setlocale)(int, const char*);
|
2011-05-24 17:23:57 +02:00
|
|
|
|
2012-07-26 11:06:37 +02:00
|
|
|
/* make sure we use the correct errno */
|
|
|
|
#undef errno
|
|
|
|
#define errno (*p_errno())
|
2010-03-25 11:09:13 +01:00
|
|
|
|
2011-02-03 13:56:33 +01:00
|
|
|
/* type info */
|
|
|
|
typedef struct __type_info
|
|
|
|
{
|
|
|
|
void *vtable;
|
|
|
|
char *name;
|
|
|
|
char mangled[16];
|
|
|
|
} type_info;
|
|
|
|
|
2011-02-16 13:59:18 +01:00
|
|
|
struct __type_info_node
|
|
|
|
{
|
|
|
|
void *memPtr;
|
|
|
|
struct __type_info_node* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
static char* (WINAPI *p_type_info_name_internal_method)(type_info*, struct __type_info_node *);
|
2011-02-03 13:56:33 +01:00
|
|
|
static void (WINAPI *ptype_info_dtor)(type_info*);
|
|
|
|
|
2014-01-06 17:54:26 +01:00
|
|
|
#define CXX_FRAME_MAGIC_VC6 0x19930520
|
|
|
|
#define CXX_EXCEPTION 0xe06d7363
|
|
|
|
|
|
|
|
/* offsets for computing the this pointer */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int this_offset; /* offset of base class this pointer from start of object */
|
|
|
|
int vbase_descr; /* offset of virtual base class descriptor */
|
|
|
|
int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
|
|
|
|
} this_ptr_offsets;
|
|
|
|
|
|
|
|
typedef void (*cxx_copy_ctor)(void);
|
|
|
|
|
|
|
|
/* complete information about a C++ type */
|
|
|
|
#ifndef __x86_64__
|
|
|
|
typedef struct __cxx_type_info
|
|
|
|
{
|
|
|
|
UINT flags; /* flags (see CLASS_* flags below) */
|
|
|
|
const type_info *type_info; /* C++ type info */
|
|
|
|
this_ptr_offsets offsets; /* offsets for computing the this pointer */
|
|
|
|
unsigned int size; /* object size */
|
|
|
|
cxx_copy_ctor copy_ctor; /* copy constructor */
|
|
|
|
} cxx_type_info;
|
|
|
|
#else
|
|
|
|
typedef struct __cxx_type_info
|
|
|
|
{
|
|
|
|
UINT flags;
|
|
|
|
unsigned int type_info;
|
|
|
|
this_ptr_offsets offsets;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int copy_ctor;
|
|
|
|
} cxx_type_info;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* table of C++ types that apply for a given object */
|
|
|
|
#ifndef __x86_64__
|
|
|
|
typedef struct __cxx_type_info_table
|
|
|
|
{
|
|
|
|
UINT count; /* number of types */
|
|
|
|
const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
|
|
|
|
} cxx_type_info_table;
|
|
|
|
#else
|
|
|
|
typedef struct __cxx_type_info_table
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
unsigned int info[3];
|
|
|
|
} cxx_type_info_table;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* type information for an exception object */
|
|
|
|
#ifndef __x86_64__
|
|
|
|
typedef struct __cxx_exception_type
|
|
|
|
{
|
|
|
|
UINT flags; /* TYPE_FLAG flags */
|
|
|
|
void (*destructor)(void);/* exception object destructor */
|
|
|
|
void *custom_handler; /* custom handler for this exception */
|
|
|
|
const cxx_type_info_table *type_info_table; /* list of types for this exception object */
|
|
|
|
} cxx_exception_type;
|
|
|
|
#else
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
UINT flags;
|
|
|
|
unsigned int destructor;
|
|
|
|
unsigned int custom_handler;
|
|
|
|
unsigned int type_info_table;
|
|
|
|
} cxx_exception_type;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int (__cdecl *p_is_exception_typeof)(const type_info*, EXCEPTION_POINTERS*);
|
|
|
|
|
2010-04-02 23:46:08 +02:00
|
|
|
static void* (WINAPI *pEncodePointer)(void *);
|
|
|
|
|
2010-10-01 13:41:42 +02:00
|
|
|
static int cb_called[4];
|
2010-11-17 17:07:58 +01:00
|
|
|
static int g_qsort_s_context_counter;
|
2012-07-16 20:36:10 +02:00
|
|
|
static int g_bsearch_s_context_counter;
|
2010-03-20 00:32:17 +01:00
|
|
|
|
2011-01-18 17:06:07 +01:00
|
|
|
static inline int almost_equal_f(float f1, float f2)
|
|
|
|
{
|
|
|
|
return f1-f2 > -1e-30 && f1-f2 < 1e-30;
|
|
|
|
}
|
|
|
|
|
2010-03-20 00:32:17 +01:00
|
|
|
/* ########## */
|
|
|
|
|
2011-02-03 13:56:33 +01:00
|
|
|
/* thiscall emulation */
|
|
|
|
/* Emulate a __thiscall */
|
2011-02-16 13:59:18 +01:00
|
|
|
#ifdef __i386__
|
2011-02-03 13:56:33 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
static inline void* do_call_func1(void *func, void *_this)
|
|
|
|
{
|
|
|
|
volatile void* retval = 0;
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
push ecx
|
|
|
|
mov ecx, _this
|
|
|
|
call func
|
|
|
|
mov retval, eax
|
|
|
|
pop ecx
|
|
|
|
}
|
|
|
|
return (void*)retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void* do_call_func2(void *func, void *_this, const void* arg)
|
|
|
|
{
|
|
|
|
volatile void* retval = 0;
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
push ecx
|
|
|
|
push arg
|
|
|
|
mov ecx, _this
|
|
|
|
call func
|
|
|
|
mov retval, eax
|
|
|
|
pop ecx
|
|
|
|
}
|
|
|
|
return (void*)retval;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void* do_call_func1(void *func, void *_this)
|
|
|
|
{
|
|
|
|
void *ret, *dummy;
|
|
|
|
__asm__ __volatile__ ("call *%2"
|
|
|
|
: "=a" (ret), "=c" (dummy)
|
|
|
|
: "g" (func), "1" (_this)
|
|
|
|
: "edx", "memory" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* do_call_func2(void *func, void *_this, const void* arg)
|
|
|
|
{
|
|
|
|
void *ret, *dummy;
|
|
|
|
__asm__ __volatile__ ("pushl %3\n\tcall *%2"
|
|
|
|
: "=a" (ret), "=c" (dummy)
|
|
|
|
: "r" (func), "r" (arg), "1" (_this)
|
|
|
|
: "edx", "memory" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-16 13:59:18 +01:00
|
|
|
#define call_func1(func,_this) do_call_func1(func,_this)
|
2016-02-11 02:18:03 +01:00
|
|
|
#define call_func2(func,_this,a) do_call_func2(func,_this,(const void*)(a))
|
2011-02-16 13:59:18 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define call_func1(func,_this) func(_this)
|
|
|
|
#define call_func2(func,_this,a) func(_this,a)
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
2011-02-03 13:56:33 +01:00
|
|
|
|
2010-06-22 17:52:23 +02:00
|
|
|
static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
|
2010-03-24 22:39:44 +01:00
|
|
|
const wchar_t *function, const wchar_t *file,
|
2010-04-14 14:34:27 +02:00
|
|
|
unsigned line, uintptr_t arg)
|
2010-03-24 22:39:44 +01:00
|
|
|
{
|
2010-10-24 23:41:23 +02:00
|
|
|
CHECK_EXPECT(invalid_parameter_handler);
|
2010-03-24 22:39:44 +01:00
|
|
|
ok(expression == NULL, "expression is not NULL\n");
|
|
|
|
ok(function == NULL, "function is not NULL\n");
|
|
|
|
ok(file == NULL, "file is not NULL\n");
|
|
|
|
ok(line == 0, "line = %u\n", line);
|
2010-04-14 14:34:27 +02:00
|
|
|
ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
|
2012-07-26 11:06:37 +02:00
|
|
|
ok(errno != 0xdeadbeef, "errno not set\n");
|
2010-03-24 22:39:44 +01:00
|
|
|
}
|
|
|
|
|
2011-05-24 17:23:34 +02:00
|
|
|
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hcrt,y)
|
|
|
|
#define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
|
|
|
|
static BOOL init(void)
|
|
|
|
{
|
|
|
|
HMODULE hcrt;
|
|
|
|
HMODULE hkernel32;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hcrt = LoadLibraryA("msvcr90.dll");
|
|
|
|
if (!hcrt) {
|
|
|
|
win_skip("msvcr90.dll not installed (got %d)\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET(p_set_invalid_parameter_handler, "_set_invalid_parameter_handler");
|
|
|
|
if(p_set_invalid_parameter_handler)
|
|
|
|
ok(p_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
|
|
|
|
"Invalid parameter handler was already set\n");
|
|
|
|
|
|
|
|
SET(p_initterm_e, "_initterm_e");
|
|
|
|
SET(p_encode_pointer, "_encode_pointer");
|
|
|
|
SET(p_decode_pointer, "_decode_pointer");
|
|
|
|
SET(p_encoded_null, "_encoded_null");
|
|
|
|
SET(p_sys_nerr, "_sys_nerr");
|
|
|
|
SET(p__sys_nerr, "__sys_nerr");
|
|
|
|
SET(p_sys_errlist, "_sys_errlist");
|
|
|
|
SET(p__sys_errlist, "__sys_errlist");
|
|
|
|
SET(p_strtoi64, "_strtoi64");
|
|
|
|
SET(p_strtoui64, "_strtoui64");
|
|
|
|
SET(p_itoa_s, "_itoa_s");
|
|
|
|
SET(p_wcsncat_s,"wcsncat_s" );
|
|
|
|
SET(p_qsort_s, "qsort_s");
|
2012-07-16 20:36:10 +02:00
|
|
|
SET(p_bsearch_s, "bsearch_s");
|
2011-05-24 17:23:34 +02:00
|
|
|
SET(p_controlfp_s, "_controlfp_s");
|
2012-07-17 21:49:09 +02:00
|
|
|
SET(p_tmpfile_s, "tmpfile_s");
|
2011-05-24 17:23:34 +02:00
|
|
|
SET(p_atoflt, "_atoflt");
|
|
|
|
SET(p_set_abort_behavior, "_set_abort_behavior");
|
|
|
|
SET(p_sopen_s, "_sopen_s");
|
|
|
|
SET(p_wsopen_s, "_wsopen_s");
|
|
|
|
SET(p_realloc_crt, "_realloc_crt");
|
|
|
|
SET(p_malloc, "malloc");
|
|
|
|
SET(p_free, "free");
|
2011-05-24 17:23:57 +02:00
|
|
|
SET(p_getptd, "_getptd");
|
|
|
|
SET(p_errno, "_errno");
|
|
|
|
SET(p_doserrno, "__doserrno");
|
|
|
|
SET(p_srand, "srand");
|
|
|
|
SET(p_strtok, "strtok");
|
|
|
|
SET(p_wcstok, "wcstok");
|
2013-06-21 12:17:43 +02:00
|
|
|
SET(p__mbstok, "_mbstok");
|
2011-05-24 17:23:57 +02:00
|
|
|
SET(p_strerror, "strerror");
|
|
|
|
SET(p_wcserror, "_wcserror");
|
|
|
|
SET(p_tmpnam, "tmpnam");
|
|
|
|
SET(p_wtmpnam, "_wtmpnam");
|
|
|
|
SET(p_asctime, "asctime");
|
|
|
|
SET(p_wasctime, "_wasctime");
|
|
|
|
SET(p_localtime64, "_localtime64");
|
|
|
|
SET(p_ecvt, "_ecvt");
|
|
|
|
SET(p_fpecode, "__fpecode");
|
|
|
|
SET(p_configthreadlocale, "_configthreadlocale");
|
|
|
|
SET(p_get_terminate, "_get_terminate");
|
|
|
|
SET(p_get_unexpected, "_get_unexpected");
|
2011-11-15 14:20:49 +01:00
|
|
|
SET(p__vswprintf_l, "__vswprintf_l");
|
|
|
|
SET(p_vswprintf_l, "_vswprintf_l");
|
2011-11-16 12:51:06 +01:00
|
|
|
SET(p_fopen, "fopen");
|
|
|
|
SET(p_fclose, "fclose");
|
|
|
|
SET(p_unlink, "_unlink");
|
2013-08-21 22:13:36 +02:00
|
|
|
SET(p_access_s, "_access_s");
|
2011-11-16 12:51:06 +01:00
|
|
|
SET(p_lock_file, "_lock_file");
|
|
|
|
SET(p_unlock_file, "_unlock_file");
|
|
|
|
SET(p_fileno, "_fileno");
|
|
|
|
SET(p_feof, "feof");
|
|
|
|
SET(p_ferror, "ferror");
|
|
|
|
SET(p_flsbuf, "_flsbuf");
|
2014-10-28 14:43:35 +01:00
|
|
|
SET(p_filbuf, "_filbuf");
|
2012-04-16 18:11:37 +02:00
|
|
|
SET(p_byteswap_ulong, "_byteswap_ulong");
|
2013-03-05 11:06:08 +01:00
|
|
|
SET(p__pxcptinfoptrs, "__pxcptinfoptrs");
|
2014-05-07 12:08:06 +02:00
|
|
|
SET(p__AdjustPointer, "__AdjustPointer");
|
2014-10-20 21:03:16 +02:00
|
|
|
SET(p_fflush_nolock, "_fflush_nolock");
|
2016-06-14 11:57:59 +02:00
|
|
|
SET(p_mbstowcs, "mbstowcs");
|
|
|
|
SET(p_wcstombs, "wcstombs");
|
|
|
|
SET(p_setlocale, "setlocale");
|
2011-05-24 17:23:34 +02:00
|
|
|
if (sizeof(void *) == 8)
|
|
|
|
{
|
|
|
|
SET(p_type_info_name_internal_method, "?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z");
|
|
|
|
SET(ptype_info_dtor, "??1type_info@@UEAA@XZ");
|
2014-01-06 17:54:26 +01:00
|
|
|
SET(p_is_exception_typeof, "?_is_exception_typeof@@YAHAEBVtype_info@@PEAU_EXCEPTION_POINTERS@@@Z");
|
2011-05-24 17:23:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-27 23:52:38 +02:00
|
|
|
#ifdef __arm__
|
|
|
|
SET(p_type_info_name_internal_method, "?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z");
|
|
|
|
SET(ptype_info_dtor, "??1type_info@@UAA@XZ");
|
|
|
|
#else
|
2011-05-24 17:23:34 +02:00
|
|
|
SET(p_type_info_name_internal_method, "?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z");
|
|
|
|
SET(ptype_info_dtor, "??1type_info@@UAE@XZ");
|
2013-08-27 23:52:38 +02:00
|
|
|
#endif
|
2014-01-06 17:54:26 +01:00
|
|
|
SET(p_is_exception_typeof, "?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z");
|
2011-05-24 17:23:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hkernel32 = GetModuleHandleA("kernel32.dll");
|
|
|
|
pEncodePointer = (void *) GetProcAddress(hkernel32, "EncodePointer");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-07 14:25:32 +02:00
|
|
|
static int __cdecl initterm_cb0(void)
|
2010-03-20 00:32:17 +01:00
|
|
|
{
|
|
|
|
cb_called[0]++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-07 14:25:32 +02:00
|
|
|
static int __cdecl initterm_cb1(void)
|
2010-03-20 00:32:17 +01:00
|
|
|
{
|
|
|
|
cb_called[1]++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-07 14:25:32 +02:00
|
|
|
static int __cdecl initterm_cb2(void)
|
2010-03-20 00:32:17 +01:00
|
|
|
{
|
|
|
|
cb_called[2]++;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test__initterm_e(void)
|
|
|
|
{
|
|
|
|
_INITTERM_E_FN table[4];
|
|
|
|
int res;
|
|
|
|
|
|
|
|
memset(table, 0, sizeof(table));
|
|
|
|
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, table);
|
|
|
|
ok( !res && !cb_called[0] && !cb_called[1] && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, NULL);
|
|
|
|
ok( !res && !cb_called[0] && !cb_called[1] && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
if (0) {
|
|
|
|
/* this crash on Windows */
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(NULL, table);
|
|
|
|
trace("got %d with 0x%x\n", res, errno);
|
|
|
|
}
|
|
|
|
|
|
|
|
table[0] = initterm_cb0;
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, &table[1]);
|
|
|
|
ok( !res && (cb_called[0] == 1) && !cb_called[1] && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
|
|
|
|
/* init-function returning failure */
|
|
|
|
table[1] = initterm_cb1;
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, &table[3]);
|
|
|
|
ok( (res == 1) && (cb_called[0] == 1) && (cb_called[1] == 1) && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
/* init-function not called, when end < start */
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(&table[3], table);
|
|
|
|
ok( !res && !cb_called[0] && !cb_called[1] && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
/* initialization stop after first non-zero result */
|
|
|
|
table[2] = initterm_cb0;
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, &table[3]);
|
|
|
|
ok( (res == 1) && (cb_called[0] == 1) && (cb_called[1] == 1) && !cb_called[2],
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
/* NULL pointer in the array are skipped */
|
|
|
|
table[1] = NULL;
|
|
|
|
table[2] = initterm_cb2;
|
|
|
|
memset(cb_called, 0, sizeof(cb_called));
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_initterm_e(table, &table[3]);
|
|
|
|
ok( (res == 2) && (cb_called[0] == 1) && !cb_called[1] && (cb_called[2] == 1),
|
|
|
|
"got %d with 0x%x {%d, %d, %d}\n",
|
|
|
|
res, errno, cb_called[0], cb_called[1], cb_called[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-04-02 23:46:08 +02:00
|
|
|
/* Beware that _encode_pointer is a NOP before XP
|
|
|
|
(the parameter is returned unchanged) */
|
2010-03-25 11:06:29 +01:00
|
|
|
static void test__encode_pointer(void)
|
|
|
|
{
|
|
|
|
void *ptr, *res;
|
|
|
|
|
|
|
|
ptr = (void*)0xdeadbeef;
|
|
|
|
res = p_encode_pointer(ptr);
|
|
|
|
res = p_decode_pointer(res);
|
|
|
|
ok(res == ptr, "Pointers are different after encoding and decoding\n");
|
|
|
|
|
2010-04-02 23:46:08 +02:00
|
|
|
ok(p_encoded_null() == p_encode_pointer(NULL), "Error encoding null\n");
|
|
|
|
|
2010-03-25 11:06:29 +01:00
|
|
|
ptr = p_encode_pointer(p_encode_pointer);
|
|
|
|
ok(p_decode_pointer(ptr) == p_encode_pointer, "Error decoding pointer\n");
|
2010-03-25 11:09:13 +01:00
|
|
|
|
2010-04-02 23:46:08 +02:00
|
|
|
/* Not present before XP */
|
|
|
|
if (!pEncodePointer) {
|
|
|
|
win_skip("EncodePointer not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = pEncodePointer(p_encode_pointer);
|
|
|
|
ok(ptr == res, "_encode_pointer produced different result than EncodePointer\n");
|
|
|
|
|
2010-03-25 11:06:29 +01:00
|
|
|
}
|
|
|
|
|
2010-03-24 22:40:40 +01:00
|
|
|
static void test_error_messages(void)
|
|
|
|
{
|
|
|
|
int *size, size_copy;
|
|
|
|
|
|
|
|
size = p__sys_nerr();
|
|
|
|
size_copy = *size;
|
|
|
|
ok(*p_sys_nerr == *size, "_sys_nerr = %u, size = %u\n", *p_sys_nerr, *size);
|
|
|
|
|
|
|
|
*size = 20;
|
|
|
|
ok(*p_sys_nerr == *size, "_sys_nerr = %u, size = %u\n", *p_sys_nerr, *size);
|
|
|
|
|
|
|
|
*size = size_copy;
|
|
|
|
|
|
|
|
ok(*p_sys_errlist == *(p__sys_errlist()), "p_sys_errlist != p__sys_errlist()\n");
|
|
|
|
}
|
|
|
|
|
2010-04-01 12:39:50 +02:00
|
|
|
static void test__strtoi64(void)
|
|
|
|
{
|
|
|
|
__int64 res;
|
|
|
|
unsigned __int64 ures;
|
|
|
|
|
2010-10-24 23:41:23 +02:00
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
res = p_strtoi64(NULL, NULL, 10);
|
|
|
|
ok(res == 0, "res != 0\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
res = p_strtoi64("123", NULL, 1);
|
|
|
|
ok(res == 0, "res != 0\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
res = p_strtoi64("123", NULL, 37);
|
|
|
|
ok(res == 0, "res != 0\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
ures = p_strtoui64(NULL, NULL, 10);
|
|
|
|
ok(ures == 0, "res = %d\n", (int)ures);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
ures = p_strtoui64("123", NULL, 1);
|
|
|
|
ok(ures == 0, "res = %d\n", (int)ures);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-10-24 23:41:23 +02:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
2010-04-01 12:39:50 +02:00
|
|
|
ures = p_strtoui64("123", NULL, 37);
|
|
|
|
ok(ures == 0, "res = %d\n", (int)ures);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-04-01 12:39:50 +02:00
|
|
|
}
|
|
|
|
|
2010-11-11 22:30:25 +01:00
|
|
|
static void test__itoa_s(void)
|
|
|
|
{
|
|
|
|
errno_t ret;
|
|
|
|
char buffer[33];
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(0, NULL, 0, 0);
|
|
|
|
ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(0, buffer, 0, 0);
|
|
|
|
ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
|
|
|
|
ok(buffer[0] == 'X', "Expected the output buffer to be untouched\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(0, buffer, sizeof(buffer), 0);
|
|
|
|
ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
|
|
|
|
ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(0, buffer, sizeof(buffer), 64);
|
|
|
|
ok(ret == EINVAL, "Expected _itoa_s to return EINVAL, got %d\n", ret);
|
|
|
|
ok(buffer[0] == '\0', "Expected the output buffer to be null terminated\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(12345678, buffer, 4, 10);
|
|
|
|
ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
|
|
|
|
ok(!memcmp(buffer, "\000765", 4),
|
|
|
|
"Expected the output buffer to be null terminated with truncated output\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, ERANGE);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(12345678, buffer, 8, 10);
|
|
|
|
ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
|
|
|
|
ok(!memcmp(buffer, "\0007654321", 8),
|
|
|
|
"Expected the output buffer to be null terminated with truncated output\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, ERANGE);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
memset(buffer, 'X', sizeof(buffer));
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_itoa_s(-12345678, buffer, 9, 10);
|
|
|
|
ok(ret == ERANGE, "Expected _itoa_s to return ERANGE, got %d\n", ret);
|
|
|
|
ok(!memcmp(buffer, "\00087654321", 9),
|
|
|
|
"Expected the output buffer to be null terminated with truncated output\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, ERANGE);
|
2010-11-11 22:30:25 +01:00
|
|
|
|
|
|
|
ret = p_itoa_s(12345678, buffer, 9, 10);
|
|
|
|
ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
|
|
|
|
ok(!strcmp(buffer, "12345678"),
|
|
|
|
"Expected output buffer string to be \"12345678\", got \"%s\"\n",
|
|
|
|
buffer);
|
|
|
|
|
|
|
|
ret = p_itoa_s(43690, buffer, sizeof(buffer), 2);
|
|
|
|
ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
|
|
|
|
ok(!strcmp(buffer, "1010101010101010"),
|
|
|
|
"Expected output buffer string to be \"1010101010101010\", got \"%s\"\n",
|
|
|
|
buffer);
|
|
|
|
|
|
|
|
ret = p_itoa_s(1092009, buffer, sizeof(buffer), 36);
|
|
|
|
ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
|
|
|
|
ok(!strcmp(buffer, "nell"),
|
|
|
|
"Expected output buffer string to be \"nell\", got \"%s\"\n",
|
|
|
|
buffer);
|
|
|
|
|
|
|
|
ret = p_itoa_s(5704, buffer, sizeof(buffer), 18);
|
|
|
|
ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
|
|
|
|
ok(!strcmp(buffer, "hag"),
|
|
|
|
"Expected output buffer string to be \"hag\", got \"%s\"\n",
|
|
|
|
buffer);
|
|
|
|
|
|
|
|
ret = p_itoa_s(-12345678, buffer, sizeof(buffer), 10);
|
|
|
|
ok(ret == 0, "Expected _itoa_s to return 0, got %d\n", ret);
|
|
|
|
ok(!strcmp(buffer, "-12345678"),
|
|
|
|
"Expected output buffer string to be \"-12345678\", got \"%s\"\n",
|
|
|
|
buffer);
|
|
|
|
}
|
|
|
|
|
2010-11-15 22:00:10 +01:00
|
|
|
static void test_wcsncat_s(void)
|
|
|
|
{
|
|
|
|
static wchar_t abcW[] = {'a','b','c',0};
|
|
|
|
int ret;
|
|
|
|
wchar_t dst[4];
|
|
|
|
wchar_t src[4];
|
|
|
|
|
|
|
|
memcpy(src, abcW, sizeof(abcW));
|
|
|
|
dst[0] = 0;
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wcsncat_s(NULL, 4, src, 4);
|
|
|
|
ok(ret == EINVAL, "err = %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-15 22:00:10 +01:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wcsncat_s(dst, 0, src, 4);
|
|
|
|
ok(ret == EINVAL, "err = %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-15 22:00:10 +01:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wcsncat_s(dst, 0, src, _TRUNCATE);
|
|
|
|
ok(ret == EINVAL, "err = %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-15 22:00:10 +01:00
|
|
|
|
|
|
|
ret = p_wcsncat_s(dst, 4, NULL, 0);
|
|
|
|
ok(ret == 0, "err = %d\n", ret);
|
|
|
|
|
|
|
|
dst[0] = 0;
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wcsncat_s(dst, 2, src, 4);
|
|
|
|
ok(ret == ERANGE, "err = %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, ERANGE);
|
2010-11-15 22:00:10 +01:00
|
|
|
|
|
|
|
dst[0] = 0;
|
|
|
|
ret = p_wcsncat_s(dst, 2, src, _TRUNCATE);
|
|
|
|
ok(ret == STRUNCATE, "err = %d\n", ret);
|
|
|
|
ok(dst[0] == 'a' && dst[1] == 0, "dst is %s\n", wine_dbgstr_w(dst));
|
|
|
|
|
|
|
|
memcpy(dst, abcW, sizeof(abcW));
|
|
|
|
dst[3] = 'd';
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wcsncat_s(dst, 4, src, 4);
|
|
|
|
ok(ret == EINVAL, "err = %d\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-15 22:00:10 +01:00
|
|
|
}
|
2010-11-11 22:30:25 +01:00
|
|
|
|
2010-11-17 17:07:58 +01:00
|
|
|
/* Based on dlls/ntdll/tests/string.c */
|
2011-02-01 11:40:14 +01:00
|
|
|
static __cdecl int intcomparefunc(void *context, const void *a, const void *b)
|
2010-11-17 17:07:58 +01:00
|
|
|
{
|
2011-02-01 11:40:14 +01:00
|
|
|
const int *p = a, *q = b;
|
|
|
|
|
2010-11-17 17:07:58 +01:00
|
|
|
ok (a != b, "must never get the same pointer\n");
|
|
|
|
++*(int *) context;
|
2011-02-01 11:40:14 +01:00
|
|
|
|
|
|
|
return *p - *q;
|
2010-11-17 17:07:58 +01:00
|
|
|
}
|
|
|
|
|
2011-02-01 11:40:14 +01:00
|
|
|
static __cdecl int charcomparefunc(void *context, const void *a, const void *b)
|
2010-11-17 17:07:58 +01:00
|
|
|
{
|
2011-02-01 11:40:14 +01:00
|
|
|
const char *p = a, *q = b;
|
|
|
|
|
2010-11-17 17:07:58 +01:00
|
|
|
ok (a != b, "must never get the same pointer\n");
|
|
|
|
++*(int *) context;
|
2011-02-01 11:40:14 +01:00
|
|
|
|
|
|
|
return *p - *q;
|
2010-11-17 17:07:58 +01:00
|
|
|
}
|
|
|
|
|
2011-02-01 11:40:14 +01:00
|
|
|
static __cdecl int strcomparefunc(void *context, const void *a, const void *b)
|
2010-11-17 17:07:58 +01:00
|
|
|
{
|
2011-02-01 11:40:14 +01:00
|
|
|
const char * const *p = a;
|
|
|
|
const char * const *q = b;
|
|
|
|
|
2010-11-17 17:07:58 +01:00
|
|
|
ok (a != b, "must never get the same pointer\n");
|
|
|
|
++*(int *) context;
|
2011-02-01 11:40:14 +01:00
|
|
|
|
|
|
|
return lstrcmpA(*p, *q);
|
2010-11-17 17:07:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_qsort_s(void)
|
|
|
|
{
|
|
|
|
int arr[5] = { 23, 42, 8, 4, 16 };
|
|
|
|
int arr2[5] = { 23, 42, 8, 4, 16 };
|
|
|
|
char carr[5] = { 42, 23, 4, 8, 16 };
|
|
|
|
const char *strarr[7] = {
|
|
|
|
"Hello",
|
|
|
|
"Wine",
|
|
|
|
"World",
|
|
|
|
"!",
|
|
|
|
"Hopefully",
|
|
|
|
"Sorted",
|
|
|
|
"."
|
|
|
|
};
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
p_qsort_s(NULL, 0, 0, NULL, NULL);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-17 17:07:58 +01:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
p_qsort_s(NULL, 0, 0, intcomparefunc, NULL);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-17 17:07:58 +01:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
p_qsort_s(NULL, 0, sizeof(int), NULL, NULL);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-17 17:07:58 +01:00
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
p_qsort_s(NULL, 1, sizeof(int), intcomparefunc, NULL);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-17 17:07:58 +01:00
|
|
|
|
2012-07-26 11:06:37 +02:00
|
|
|
errno = 0xdeadbeef;
|
2010-11-17 17:07:58 +01:00
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s(NULL, 0, sizeof(int), intcomparefunc, NULL);
|
|
|
|
ok(g_qsort_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
ok( errno == 0xdeadbeef, "wrong errno %u\n", errno );
|
2010-11-17 17:07:58 +01:00
|
|
|
|
|
|
|
/* overflow without side effects, other overflow values crash */
|
2012-07-26 11:06:37 +02:00
|
|
|
errno = 0xdeadbeef;
|
2010-11-17 17:07:58 +01:00
|
|
|
g_qsort_s_context_counter = 0;
|
2010-12-26 18:00:20 +01:00
|
|
|
p_qsort_s((void*)arr2, (((size_t)1) << (8*sizeof(size_t) - 1)) + 1, sizeof(int), intcomparefunc, &g_qsort_s_context_counter);
|
2010-11-17 17:07:58 +01:00
|
|
|
ok(g_qsort_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
ok( errno == 0xdeadbeef, "wrong errno %u\n", errno );
|
2010-11-17 17:07:58 +01:00
|
|
|
ok(arr2[0] == 23, "should remain unsorted, arr2[0] is %d\n", arr2[0]);
|
|
|
|
ok(arr2[1] == 42, "should remain unsorted, arr2[1] is %d\n", arr2[1]);
|
|
|
|
ok(arr2[2] == 8, "should remain unsorted, arr2[2] is %d\n", arr2[2]);
|
|
|
|
ok(arr2[3] == 4, "should remain unsorted, arr2[3] is %d\n", arr2[3]);
|
|
|
|
|
2012-07-26 11:06:37 +02:00
|
|
|
errno = 0xdeadbeef;
|
2010-11-17 17:07:58 +01:00
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)arr, 0, sizeof(int), intcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
ok( errno == 0xdeadbeef, "wrong errno %u\n", errno );
|
2010-11-17 17:07:58 +01:00
|
|
|
ok(arr[0] == 23, "badly sorted, nmemb=0, arr[0] is %d\n", arr[0]);
|
|
|
|
ok(arr[1] == 42, "badly sorted, nmemb=0, arr[1] is %d\n", arr[1]);
|
|
|
|
ok(arr[2] == 8, "badly sorted, nmemb=0, arr[2] is %d\n", arr[2]);
|
|
|
|
ok(arr[3] == 4, "badly sorted, nmemb=0, arr[3] is %d\n", arr[3]);
|
|
|
|
ok(arr[4] == 16, "badly sorted, nmemb=0, arr[4] is %d\n", arr[4]);
|
|
|
|
|
2012-07-26 11:06:37 +02:00
|
|
|
errno = 0xdeadbeef;
|
2010-11-17 17:07:58 +01:00
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)arr, 1, sizeof(int), intcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
ok( errno == 0xdeadbeef, "wrong errno %u\n", errno );
|
2010-11-17 17:07:58 +01:00
|
|
|
ok(arr[0] == 23, "badly sorted, nmemb=1, arr[0] is %d\n", arr[0]);
|
|
|
|
ok(arr[1] == 42, "badly sorted, nmemb=1, arr[1] is %d\n", arr[1]);
|
|
|
|
ok(arr[2] == 8, "badly sorted, nmemb=1, arr[2] is %d\n", arr[2]);
|
|
|
|
ok(arr[3] == 4, "badly sorted, nmemb=1, arr[3] is %d\n", arr[3]);
|
|
|
|
ok(arr[4] == 16, "badly sorted, nmemb=1, arr[4] is %d\n", arr[4]);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)arr, 5, 0, intcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter == 0, "callback shouldn't have been called\n");
|
|
|
|
ok(arr[0] == 23, "badly sorted, size=0, arr[0] is %d\n", arr[0]);
|
|
|
|
ok(arr[1] == 42, "badly sorted, size=0, arr[1] is %d\n", arr[1]);
|
|
|
|
ok(arr[2] == 8, "badly sorted, size=0, arr[2] is %d\n", arr[2]);
|
|
|
|
ok(arr[3] == 4, "badly sorted, size=0, arr[3] is %d\n", arr[3]);
|
|
|
|
ok(arr[4] == 16, "badly sorted, size=0, arr[4] is %d\n", arr[4]);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-17 17:07:58 +01:00
|
|
|
|
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)arr, 5, sizeof(int), intcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter > 0, "callback wasn't called\n");
|
|
|
|
ok(arr[0] == 4, "badly sorted, arr[0] is %d\n", arr[0]);
|
|
|
|
ok(arr[1] == 8, "badly sorted, arr[1] is %d\n", arr[1]);
|
|
|
|
ok(arr[2] == 16, "badly sorted, arr[2] is %d\n", arr[2]);
|
|
|
|
ok(arr[3] == 23, "badly sorted, arr[3] is %d\n", arr[3]);
|
|
|
|
ok(arr[4] == 42, "badly sorted, arr[4] is %d\n", arr[4]);
|
|
|
|
|
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)carr, 5, sizeof(char), charcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter > 0, "callback wasn't called\n");
|
|
|
|
ok(carr[0] == 4, "badly sorted, carr[0] is %d\n", carr[0]);
|
|
|
|
ok(carr[1] == 8, "badly sorted, carr[1] is %d\n", carr[1]);
|
|
|
|
ok(carr[2] == 16, "badly sorted, carr[2] is %d\n", carr[2]);
|
|
|
|
ok(carr[3] == 23, "badly sorted, carr[3] is %d\n", carr[3]);
|
|
|
|
ok(carr[4] == 42, "badly sorted, carr[4] is %d\n", carr[4]);
|
|
|
|
|
|
|
|
g_qsort_s_context_counter = 0;
|
|
|
|
p_qsort_s((void*)strarr, 7, sizeof(char*), strcomparefunc, &g_qsort_s_context_counter);
|
|
|
|
ok(g_qsort_s_context_counter > 0, "callback wasn't called\n");
|
|
|
|
ok(!strcmp(strarr[0],"!"), "badly sorted, strarr[0] is %s\n", strarr[0]);
|
|
|
|
ok(!strcmp(strarr[1],"."), "badly sorted, strarr[1] is %s\n", strarr[1]);
|
|
|
|
ok(!strcmp(strarr[2],"Hello"), "badly sorted, strarr[2] is %s\n", strarr[2]);
|
|
|
|
ok(!strcmp(strarr[3],"Hopefully"), "badly sorted, strarr[3] is %s\n", strarr[3]);
|
|
|
|
ok(!strcmp(strarr[4],"Sorted"), "badly sorted, strarr[4] is %s\n", strarr[4]);
|
|
|
|
ok(!strcmp(strarr[5],"Wine"), "badly sorted, strarr[5] is %s\n", strarr[5]);
|
|
|
|
ok(!strcmp(strarr[6],"World"), "badly sorted, strarr[6] is %s\n", strarr[6]);
|
|
|
|
}
|
|
|
|
|
2012-07-16 20:36:10 +02:00
|
|
|
static void test_bsearch_s(void)
|
|
|
|
{
|
|
|
|
int arr[7] = { 1, 3, 4, 8, 16, 23, 42 };
|
|
|
|
int *x, l, i, j = 1;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
x = p_bsearch_s(NULL, NULL, 0, 0, NULL, NULL);
|
|
|
|
ok(x == NULL, "Expected bsearch_s to return NULL, got %p\n", x);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2012-07-16 20:36:10 +02:00
|
|
|
|
|
|
|
g_bsearch_s_context_counter = 0;
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
x = p_bsearch_s(&l, arr, j, 0, intcomparefunc, &g_bsearch_s_context_counter);
|
|
|
|
ok(x == NULL, "Expected bsearch_s to return NULL, got %p\n", x);
|
|
|
|
ok(g_bsearch_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2012-07-16 20:36:10 +02:00
|
|
|
|
|
|
|
g_bsearch_s_context_counter = 0;
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
x = p_bsearch_s(&l, arr, j, sizeof(arr[0]), NULL, &g_bsearch_s_context_counter);
|
|
|
|
ok(x == NULL, "Expected bsearch_s to return NULL, got %p\n", x);
|
|
|
|
ok(g_bsearch_s_context_counter == 0, "callback shouldn't have been called\n");
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2012-07-16 20:36:10 +02:00
|
|
|
|
|
|
|
/* just try all array sizes */
|
|
|
|
for (j=1;j<sizeof(arr)/sizeof(arr[0]);j++) {
|
|
|
|
for (i=0;i<j;i++) {
|
|
|
|
l = arr[i];
|
|
|
|
g_bsearch_s_context_counter = 0;
|
|
|
|
x = p_bsearch_s(&l, arr, j, sizeof(arr[0]), intcomparefunc, &g_bsearch_s_context_counter);
|
|
|
|
ok (x == &arr[i], "bsearch_s did not find %d entry in loopsize %d.\n", i, j);
|
|
|
|
ok(g_bsearch_s_context_counter > 0, "callback wasn't called\n");
|
|
|
|
}
|
|
|
|
l = 4242;
|
|
|
|
g_bsearch_s_context_counter = 0;
|
|
|
|
x = p_bsearch_s(&l, arr, j, sizeof(arr[0]), intcomparefunc, &g_bsearch_s_context_counter);
|
|
|
|
ok (x == NULL, "bsearch_s did find 4242 entry in loopsize %d.\n", j);
|
|
|
|
ok(g_bsearch_s_context_counter > 0, "callback wasn't called\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-27 20:40:14 +01:00
|
|
|
static void test_controlfp_s(void)
|
|
|
|
{
|
|
|
|
unsigned int cur;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_controlfp_s( NULL, ~0, ~0 );
|
|
|
|
ok( ret == EINVAL, "wrong result %d\n", ret );
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-27 20:40:14 +01:00
|
|
|
|
|
|
|
cur = 0xdeadbeef;
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_controlfp_s( &cur, ~0, ~0 );
|
|
|
|
ok( ret == EINVAL, "wrong result %d\n", ret );
|
|
|
|
ok( cur != 0xdeadbeef, "value not set\n" );
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-27 20:40:14 +01:00
|
|
|
|
|
|
|
cur = 0xdeadbeef;
|
|
|
|
ret = p_controlfp_s( &cur, 0, 0 );
|
|
|
|
ok( !ret, "wrong result %d\n", ret );
|
|
|
|
ok( cur != 0xdeadbeef, "value not set\n" );
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
cur = 0xdeadbeef;
|
|
|
|
ret = p_controlfp_s( &cur, 0x80000000, 0x80000000 );
|
|
|
|
ok( ret == EINVAL, "wrong result %d\n", ret );
|
|
|
|
ok( cur != 0xdeadbeef, "value not set\n" );
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2010-11-27 20:40:14 +01:00
|
|
|
|
|
|
|
cur = 0xdeadbeef;
|
|
|
|
/* mask is only checked when setting invalid bits */
|
|
|
|
ret = p_controlfp_s( &cur, 0, 0x80000000 );
|
|
|
|
ok( !ret, "wrong result %d\n", ret );
|
|
|
|
ok( cur != 0xdeadbeef, "value not set\n" );
|
|
|
|
}
|
2010-03-20 00:32:17 +01:00
|
|
|
|
2012-07-17 21:49:09 +02:00
|
|
|
static void test_tmpfile_s( void )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_tmpfile_s(NULL);
|
|
|
|
ok(ret == EINVAL, "Expected tmpfile_s to return EINVAL, got %i\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2012-07-17 21:49:09 +02:00
|
|
|
}
|
|
|
|
|
2011-01-18 17:06:07 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
float flt;
|
|
|
|
int ret;
|
|
|
|
} _atoflt_test;
|
|
|
|
|
|
|
|
static const _atoflt_test _atoflt_testdata[] = {
|
|
|
|
{ "12.1", 12.1, 0 },
|
|
|
|
{ "-13.721", -13.721, 0 },
|
|
|
|
{ "INF", 0.0, 0 },
|
|
|
|
{ ".21e12", 0.21e12, 0 },
|
|
|
|
{ "214353e-3", 214.353, 0 },
|
|
|
|
{ "1d9999999999999999999", 0.0, _OVERFLOW },
|
|
|
|
{ " d10", 0.0, 0 },
|
|
|
|
/* more significant digits */
|
|
|
|
{ "1.23456789", 1.23456789, 0 },
|
|
|
|
{ "1.23456789e1", 12.3456789, 0 },
|
|
|
|
{ "1e39", 0.0, _OVERFLOW },
|
|
|
|
{ "1e-39", 0.0, _UNDERFLOW },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test__atoflt(void)
|
|
|
|
{
|
|
|
|
_CRT_FLOAT flt;
|
|
|
|
int ret, i = 0;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-09 22:43:38 +01:00
|
|
|
p_atoflt(NULL, NULL);
|
|
|
|
p_atoflt(NULL, (char*)_atoflt_testdata[0].str);
|
|
|
|
p_atoflt(&flt, NULL);
|
2011-01-18 17:06:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while (_atoflt_testdata[i].str)
|
|
|
|
{
|
|
|
|
ret = p_atoflt(&flt, (char*)_atoflt_testdata[i].str);
|
|
|
|
ok(ret == _atoflt_testdata[i].ret, "got ret %d, expected ret %d, for %s\n", ret,
|
|
|
|
_atoflt_testdata[i].ret, _atoflt_testdata[i].str);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
ok(almost_equal_f(flt.f, _atoflt_testdata[i].flt), "got %f, expected %f, for %s\n", flt.f,
|
|
|
|
_atoflt_testdata[i].flt, _atoflt_testdata[i].str);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 23:21:11 +01:00
|
|
|
static void test__set_abort_behavior(void)
|
|
|
|
{
|
|
|
|
unsigned int res;
|
|
|
|
|
|
|
|
/* default is _WRITE_ABORT_MSG | _CALL_REPORTFAULT */
|
|
|
|
res = p_set_abort_behavior(0, 0);
|
|
|
|
ok (res == (_WRITE_ABORT_MSG | _CALL_REPORTFAULT),
|
|
|
|
"got 0x%x (expected 0x%x)\n", res, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
|
|
|
|
|
|
|
/* no internal mask */
|
|
|
|
p_set_abort_behavior(0xffffffff, 0xffffffff);
|
|
|
|
res = p_set_abort_behavior(0, 0);
|
|
|
|
ok (res == 0xffffffff, "got 0x%x (expected 0x%x)\n", res, 0xffffffff);
|
|
|
|
|
|
|
|
/* set to default value */
|
|
|
|
p_set_abort_behavior(_WRITE_ABORT_MSG | _CALL_REPORTFAULT, 0xffffffff);
|
|
|
|
}
|
|
|
|
|
2011-01-26 23:56:30 +01:00
|
|
|
static void test__sopen_s(void)
|
2011-01-26 01:59:13 +01:00
|
|
|
{
|
|
|
|
int ret, fd;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_sopen_s(NULL, "test", _O_RDONLY, _SH_DENYNO, _S_IREAD);
|
|
|
|
ok(ret == EINVAL, "got %d, expected EINVAL\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2011-01-26 01:59:13 +01:00
|
|
|
|
|
|
|
fd = 0xdead;
|
|
|
|
ret = p_sopen_s(&fd, "test", _O_RDONLY, _SH_DENYNO, _S_IREAD);
|
|
|
|
ok(ret == ENOENT, "got %d, expected ENOENT\n", ret);
|
|
|
|
ok(fd == -1, "got %d\n", fd);
|
|
|
|
}
|
|
|
|
|
2011-01-26 23:56:30 +01:00
|
|
|
static void test__wsopen_s(void)
|
|
|
|
{
|
|
|
|
wchar_t testW[] = {'t','e','s','t',0};
|
|
|
|
int ret, fd;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
ret = p_wsopen_s(NULL, testW, _O_RDONLY, _SH_DENYNO, _S_IREAD);
|
|
|
|
ok(ret == EINVAL, "got %d, expected EINVAL\n", ret);
|
2012-07-26 11:06:37 +02:00
|
|
|
CHECK_CALLED(invalid_parameter_handler, EINVAL);
|
2011-01-26 23:56:30 +01:00
|
|
|
|
|
|
|
fd = 0xdead;
|
|
|
|
ret = p_wsopen_s(&fd, testW, _O_RDONLY, _SH_DENYNO, _S_IREAD);
|
|
|
|
ok(ret == ENOENT, "got %d, expected ENOENT\n", ret);
|
|
|
|
ok(fd == -1, "got %d\n", fd);
|
|
|
|
}
|
|
|
|
|
2011-01-28 01:21:06 +01:00
|
|
|
static void test__realloc_crt(void)
|
|
|
|
{
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on some systems starting Vista */
|
2011-02-09 22:43:38 +01:00
|
|
|
p_realloc_crt(NULL, 10);
|
2011-01-28 01:21:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mem = p_malloc(10);
|
|
|
|
ok(mem != NULL, "memory not allocated\n");
|
|
|
|
|
|
|
|
mem = p_realloc_crt(mem, 20);
|
|
|
|
ok(mem != NULL, "memory not reallocated\n");
|
|
|
|
|
|
|
|
mem = p_realloc_crt(mem, 0);
|
|
|
|
ok(mem == NULL, "memory not freed\n");
|
|
|
|
|
|
|
|
mem = p_realloc_crt(NULL, 0);
|
|
|
|
ok(mem != NULL, "memory not (re)allocated for size 0\n");
|
|
|
|
p_free(mem);
|
|
|
|
}
|
|
|
|
|
2011-02-03 13:56:33 +01:00
|
|
|
static void test_typeinfo(void)
|
|
|
|
{
|
|
|
|
static type_info t1 = { NULL, NULL,{'.','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
|
|
|
|
struct __type_info_node node;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
/* name */
|
|
|
|
t1.name = NULL;
|
|
|
|
node.memPtr = NULL;
|
|
|
|
node.next = NULL;
|
|
|
|
name = call_func2(p_type_info_name_internal_method, &t1, &node);
|
|
|
|
ok(name != NULL, "got %p\n", name);
|
|
|
|
ok(name && t1.name && !strcmp(name, t1.name), "bad name '%s' for t1\n", name);
|
|
|
|
|
|
|
|
ok(t1.name && !strcmp(t1.name, "class test1"), "demangled to '%s' for t1\n", t1.name);
|
|
|
|
call_func1(ptype_info_dtor, &t1);
|
|
|
|
}
|
|
|
|
|
2011-05-24 17:23:57 +02:00
|
|
|
/* Keep in sync with msvcrt/msvcrt.h */
|
|
|
|
struct __thread_data {
|
|
|
|
DWORD tid;
|
|
|
|
HANDLE handle;
|
|
|
|
int thread_errno;
|
|
|
|
__msvcrt_ulong thread_doserrno;
|
|
|
|
int unk1;
|
|
|
|
unsigned int random_seed;
|
|
|
|
char *strtok_next;
|
|
|
|
wchar_t *wcstok_next;
|
|
|
|
unsigned char *mbstok_next;
|
|
|
|
char *strerror_buffer;
|
|
|
|
wchar_t *wcserror_buffer;
|
|
|
|
char *tmpnam_buffer;
|
|
|
|
wchar_t *wtmpnam_buffer;
|
|
|
|
void *unk2[2];
|
|
|
|
char *asctime_buffer;
|
|
|
|
wchar_t *wasctime_buffer;
|
|
|
|
struct tm *time_buffer;
|
|
|
|
char *efcvt_buffer;
|
|
|
|
int unk3[2];
|
2013-03-05 11:06:08 +01:00
|
|
|
void *unk4[3];
|
|
|
|
EXCEPTION_POINTERS *xcptinfo;
|
2011-05-24 17:23:57 +02:00
|
|
|
int fpecode;
|
|
|
|
pthreadmbcinfo mbcinfo;
|
|
|
|
pthreadlocinfo locinfo;
|
|
|
|
BOOL have_locale;
|
|
|
|
int unk5[1];
|
|
|
|
void* terminate_handler;
|
|
|
|
void* unexpected_handler;
|
|
|
|
void* se_translator;
|
|
|
|
void *unk6[3];
|
|
|
|
int unk7;
|
|
|
|
EXCEPTION_RECORD *exc_record;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_getptd(void)
|
|
|
|
{
|
|
|
|
struct __thread_data *ptd = p_getptd();
|
|
|
|
DWORD tid = GetCurrentThreadId();
|
|
|
|
wchar_t testW[] = {'t','e','s','t',0}, tW[] = {'t',0}, *wp;
|
|
|
|
char test[] = "test", *p;
|
2013-06-21 12:17:43 +02:00
|
|
|
unsigned char mbstok_test[] = "test", *up;
|
2011-05-24 17:23:57 +02:00
|
|
|
struct tm time;
|
|
|
|
__time64_t secs = 0;
|
|
|
|
int dec, sign;
|
|
|
|
void *mbcinfo, *locinfo;
|
|
|
|
|
|
|
|
ok(ptd->tid == tid, "ptd->tid = %x, expected %x\n", ptd->tid, tid);
|
|
|
|
ok(ptd->handle == INVALID_HANDLE_VALUE, "ptd->handle = %p\n", ptd->handle);
|
|
|
|
ok(p_errno() == &ptd->thread_errno, "ptd->thread_errno is different then _errno()\n");
|
|
|
|
ok(p_doserrno() == &ptd->thread_doserrno, "ptd->thread_doserrno is different then __doserrno()\n");
|
|
|
|
p_srand(1234);
|
|
|
|
ok(ptd->random_seed == 1234, "ptd->random_seed = %d\n", ptd->random_seed);
|
|
|
|
p = p_strtok(test, "t");
|
|
|
|
ok(ptd->strtok_next == p+3, "ptd->strtok_next is incorrect\n");
|
|
|
|
wp = p_wcstok(testW, tW);
|
|
|
|
ok(ptd->wcstok_next == wp+3, "ptd->wcstok_next is incorrect\n");
|
2013-06-21 12:17:43 +02:00
|
|
|
up = p__mbstok(mbstok_test, (unsigned char*)"t");
|
|
|
|
ok(ptd->mbstok_next == up+3, "ptd->mbstok_next is incorrect\n");
|
2011-05-24 17:23:57 +02:00
|
|
|
ok(p_strerror(0) == ptd->strerror_buffer, "ptd->strerror_buffer is incorrect\n");
|
|
|
|
ok(p_wcserror(0) == ptd->wcserror_buffer, "ptd->wcserror_buffer is incorrect\n");
|
|
|
|
ok(p_tmpnam(NULL) == ptd->tmpnam_buffer, "ptd->tmpnam_buffer is incorrect\n");
|
|
|
|
ok(p_wtmpnam(NULL) == ptd->wtmpnam_buffer, "ptd->wtmpnam_buffer is incorrect\n");
|
|
|
|
memset(&time, 0, sizeof(time));
|
|
|
|
time.tm_mday = 1;
|
|
|
|
ok(p_asctime(&time) == ptd->asctime_buffer, "ptd->asctime_buffer is incorrect\n");
|
|
|
|
ok(p_wasctime(&time) == ptd->wasctime_buffer, "ptd->wasctime_buffer is incorrect\n");
|
|
|
|
ok(p_localtime64(&secs) == ptd->time_buffer, "ptd->time_buffer is incorrect\n");
|
|
|
|
ok(p_ecvt(3.12, 1, &dec, &sign) == ptd->efcvt_buffer, "ptd->efcvt_buffer is incorrect\n");
|
2013-03-05 11:06:08 +01:00
|
|
|
ok(p__pxcptinfoptrs() == (void**)&ptd->xcptinfo, "ptd->xcptinfo is incorrect\n");
|
2011-05-24 17:23:57 +02:00
|
|
|
ok(p_fpecode() == &ptd->fpecode, "ptd->fpecode is incorrect\n");
|
|
|
|
mbcinfo = ptd->mbcinfo;
|
|
|
|
locinfo = ptd->locinfo;
|
|
|
|
todo_wine ok(ptd->have_locale == 1, "ptd->have_locale = %x\n", ptd->have_locale);
|
|
|
|
p_configthreadlocale(1);
|
|
|
|
todo_wine ok(mbcinfo == ptd->mbcinfo, "ptd->mbcinfo != mbcinfo\n");
|
|
|
|
todo_wine ok(locinfo == ptd->locinfo, "ptd->locinfo != locinfo\n");
|
|
|
|
todo_wine ok(ptd->have_locale == 3, "ptd->have_locale = %x\n", ptd->have_locale);
|
|
|
|
ok(p_get_terminate() == ptd->terminate_handler, "ptd->terminate_handler != _get_terminate()\n");
|
|
|
|
ok(p_get_unexpected() == ptd->unexpected_handler, "ptd->unexpected_handler != _get_unexpected()\n");
|
|
|
|
}
|
|
|
|
|
2011-11-15 14:20:49 +01:00
|
|
|
static int __cdecl __vswprintf_l_wrapper(wchar_t *buf,
|
|
|
|
const wchar_t *format, _locale_t locale, ...)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
|
|
|
ret = p__vswprintf_l(buf, format, locale, valist);
|
|
|
|
__ms_va_end(valist);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __cdecl _vswprintf_l_wrapper(wchar_t *buf,
|
|
|
|
const wchar_t *format, _locale_t locale, ...)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
|
|
|
ret = p_vswprintf_l(buf, format, locale, valist);
|
|
|
|
__ms_va_end(valist);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test__vswprintf_l(void)
|
|
|
|
{
|
|
|
|
static const wchar_t format[] = {'t','e','s','t',0};
|
|
|
|
|
|
|
|
wchar_t buf[32];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = __vswprintf_l_wrapper(buf, format, NULL);
|
|
|
|
ok(ret == 4, "ret = %d\n", ret);
|
|
|
|
ok(!memcmp(buf, format, sizeof(format)), "buf = %s, expected %s\n",
|
|
|
|
wine_dbgstr_w(buf), wine_dbgstr_w(format));
|
|
|
|
|
|
|
|
ret = _vswprintf_l_wrapper(buf, format, NULL);
|
|
|
|
ok(ret == 4, "ret = %d\n", ret);
|
|
|
|
ok(!memcmp(buf, format, sizeof(format)), "buf = %s, expected %s\n",
|
|
|
|
wine_dbgstr_w(buf), wine_dbgstr_w(format));
|
|
|
|
}
|
|
|
|
|
2011-11-16 12:51:06 +01:00
|
|
|
struct block_file_arg
|
|
|
|
{
|
|
|
|
FILE *read;
|
|
|
|
FILE *write;
|
2012-12-06 10:59:01 +01:00
|
|
|
HANDLE init;
|
|
|
|
HANDLE finish;
|
2014-10-20 21:03:16 +02:00
|
|
|
int deadlock_test;
|
2011-11-16 12:51:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD WINAPI block_file(void *arg)
|
|
|
|
{
|
|
|
|
struct block_file_arg *files = arg;
|
2014-10-20 21:03:16 +02:00
|
|
|
int deadlock_test;
|
2011-11-16 12:51:06 +01:00
|
|
|
|
|
|
|
p_lock_file(files->read);
|
|
|
|
p_lock_file(files->write);
|
2012-12-06 10:59:01 +01:00
|
|
|
SetEvent(files->init);
|
2014-10-20 21:03:16 +02:00
|
|
|
|
2012-12-06 10:59:01 +01:00
|
|
|
WaitForSingleObject(files->finish, INFINITE);
|
2014-10-20 21:03:16 +02:00
|
|
|
Sleep(200);
|
|
|
|
deadlock_test = InterlockedIncrement(&files->deadlock_test);
|
|
|
|
ok(deadlock_test == 1, "deadlock_test = %d\n", deadlock_test);
|
2011-11-16 12:51:06 +01:00
|
|
|
p_unlock_file(files->read);
|
|
|
|
p_unlock_file(files->write);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_nonblocking_file_access(void)
|
|
|
|
{
|
|
|
|
HANDLE thread;
|
|
|
|
struct block_file_arg arg;
|
|
|
|
FILE *filer, *filew;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if(!p_lock_file || !p_unlock_file) {
|
|
|
|
win_skip("_lock_file not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
filew = p_fopen("test_file", "w");
|
|
|
|
ok(filew != NULL, "unable to create test file\n");
|
|
|
|
if(!filew)
|
|
|
|
return;
|
|
|
|
filer = p_fopen("test_file", "r");
|
|
|
|
ok(filer != NULL, "unable to open test file\n");
|
|
|
|
if(!filer) {
|
|
|
|
p_fclose(filew);
|
|
|
|
p_unlink("test_file");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg.read = filer;
|
|
|
|
arg.write = filew;
|
2013-10-01 23:20:56 +02:00
|
|
|
arg.init = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
arg.finish = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2014-10-20 21:03:16 +02:00
|
|
|
arg.deadlock_test = 0;
|
2013-10-01 23:20:56 +02:00
|
|
|
ok(arg.init != NULL, "CreateEventW failed\n");
|
|
|
|
ok(arg.finish != NULL, "CreateEventW failed\n");
|
2011-11-16 12:51:06 +01:00
|
|
|
thread = CreateThread(NULL, 0, block_file, (void*)&arg, 0, NULL);
|
|
|
|
ok(thread != NULL, "CreateThread failed\n");
|
2012-12-06 10:59:01 +01:00
|
|
|
WaitForSingleObject(arg.init, INFINITE);
|
2011-11-16 12:51:06 +01:00
|
|
|
|
|
|
|
ret = p_fileno(filer);
|
|
|
|
ok(ret, "_fileno(filer) returned %d\n", ret);
|
|
|
|
ret = p_fileno(filew);
|
|
|
|
ok(ret, "_fileno(filew) returned %d\n", ret);
|
|
|
|
|
|
|
|
ret = p_feof(filer);
|
|
|
|
ok(ret==0, "feof(filer) returned %d\n", ret);
|
|
|
|
ret = p_feof(filew);
|
|
|
|
ok(ret==0, "feof(filew) returned %d\n", ret);
|
|
|
|
|
|
|
|
ret = p_ferror(filer);
|
|
|
|
ok(ret==0, "ferror(filer) returned %d\n", ret);
|
|
|
|
ret = p_ferror(filew);
|
|
|
|
ok(ret==0, "ferror(filew) returned %d\n", ret);
|
|
|
|
|
|
|
|
ret = p_flsbuf('a', filer);
|
|
|
|
ok(ret==-1, "_flsbuf(filer) returned %d\n", ret);
|
|
|
|
ret = p_flsbuf('a', filew);
|
|
|
|
ok(ret=='a', "_flsbuf(filew) returned %d\n", ret);
|
|
|
|
|
2014-10-28 14:43:35 +01:00
|
|
|
ret = p_filbuf(filer);
|
|
|
|
ok(ret==-1, "_filbuf(filer) returned %d\n", ret);
|
|
|
|
ret = p_filbuf(filew);
|
|
|
|
ok(ret==-1, "_filbuf(filew) returned %d\n", ret);
|
|
|
|
|
2014-10-20 21:03:16 +02:00
|
|
|
ret = p_fflush_nolock(filer);
|
|
|
|
ok(ret==0, "_fflush_nolock(filer) returned %d\n", ret);
|
|
|
|
ret = p_fflush_nolock(filew);
|
|
|
|
ok(ret==0, "_fflush_nolock(filew) returned %d\n", ret);
|
|
|
|
|
2012-12-06 10:59:01 +01:00
|
|
|
SetEvent(arg.finish);
|
2014-10-20 21:03:16 +02:00
|
|
|
|
|
|
|
ret = p_fflush_nolock(NULL);
|
|
|
|
ok(ret==0, "_fflush_nolock(NULL) returned %d\n", ret);
|
|
|
|
ret = InterlockedIncrement(&arg.deadlock_test);
|
|
|
|
ok(ret==2, "InterlockedIncrement returned %d\n", ret);
|
|
|
|
|
2011-11-16 12:51:06 +01:00
|
|
|
WaitForSingleObject(thread, INFINITE);
|
2012-12-06 10:59:01 +01:00
|
|
|
CloseHandle(arg.init);
|
|
|
|
CloseHandle(arg.finish);
|
2011-11-16 12:51:06 +01:00
|
|
|
CloseHandle(thread);
|
|
|
|
p_fclose(filer);
|
|
|
|
p_fclose(filew);
|
|
|
|
p_unlink("test_file");
|
|
|
|
}
|
|
|
|
|
2012-04-16 18:11:37 +02:00
|
|
|
static void test_byteswap(void)
|
|
|
|
{
|
|
|
|
unsigned long ret;
|
|
|
|
|
|
|
|
ret = p_byteswap_ulong(0x12345678);
|
|
|
|
ok(ret == 0x78563412, "ret = %lx\n", ret);
|
|
|
|
|
|
|
|
ret = p_byteswap_ulong(0);
|
|
|
|
ok(ret == 0, "ret = %lx\n", ret);
|
|
|
|
}
|
|
|
|
|
2013-08-21 22:13:36 +02:00
|
|
|
static void test_access_s(void)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
f = p_fopen("test_file", "w");
|
|
|
|
ok(f != NULL, "unable to create test file\n");
|
|
|
|
if(!f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p_fclose(f);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 0);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 2);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 4);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 6);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
SetFileAttributesA("test_file", FILE_ATTRIBUTE_READONLY);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 0);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 2);
|
|
|
|
ok(res == EACCES, "got %x\n", res);
|
|
|
|
ok(errno == EACCES, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 4);
|
|
|
|
ok(res == 0, "got %x\n", res);
|
|
|
|
ok(errno == 0xdeadbeef, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 6);
|
|
|
|
ok(res == EACCES, "got %x\n", res);
|
|
|
|
ok(errno == EACCES, "got %x\n", res);
|
|
|
|
|
|
|
|
SetFileAttributesA("test_file", FILE_ATTRIBUTE_NORMAL);
|
|
|
|
|
|
|
|
p_unlink("test_file");
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 0);
|
|
|
|
ok(res == ENOENT, "got %x\n", res);
|
|
|
|
ok(errno == ENOENT, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 2);
|
|
|
|
ok(res == ENOENT, "got %x\n", res);
|
|
|
|
ok(errno == ENOENT, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 4);
|
|
|
|
ok(res == ENOENT, "got %x\n", res);
|
|
|
|
ok(errno == ENOENT, "got %x\n", res);
|
|
|
|
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
res = p_access_s("test_file", 6);
|
|
|
|
ok(res == ENOENT, "got %x\n", res);
|
|
|
|
ok(errno == ENOENT, "got %x\n", res);
|
|
|
|
}
|
|
|
|
|
2014-01-06 17:54:26 +01:00
|
|
|
#ifndef __x86_64__
|
|
|
|
#define EXCEPTION_REF(instance, name) &instance.name
|
|
|
|
#else
|
|
|
|
#define EXCEPTION_REF(instance, name) FIELD_OFFSET(struct _exception_data, name)
|
|
|
|
#endif
|
|
|
|
static void test_is_exception_typeof(void)
|
|
|
|
{
|
|
|
|
const type_info ti1 = {NULL, NULL, {'.','?','A','V','t','e','s','t','1','@','@',0}};
|
|
|
|
const type_info ti2 = {NULL, NULL, {'.','?','A','V','t','e','s','t','2','@','@',0}};
|
|
|
|
const type_info ti3 = {NULL, NULL, {'.','?','A','V','t','e','s','t','3','@','@',0}};
|
|
|
|
|
|
|
|
const struct _exception_data {
|
|
|
|
type_info ti1;
|
|
|
|
type_info ti2;
|
|
|
|
cxx_type_info cti1;
|
|
|
|
cxx_type_info cti2;
|
|
|
|
cxx_type_info_table tit;
|
|
|
|
cxx_exception_type et;
|
|
|
|
} exception_data = {
|
|
|
|
{NULL, NULL, {'.','?','A','V','t','e','s','t','1','@','@',0}},
|
|
|
|
{NULL, NULL, {'.','?','A','V','t','e','s','t','2','@','@',0}},
|
|
|
|
{0, EXCEPTION_REF(exception_data, ti1)},
|
|
|
|
{0, EXCEPTION_REF(exception_data, ti2)},
|
|
|
|
{2, {EXCEPTION_REF(exception_data, cti1), EXCEPTION_REF(exception_data, cti2)}},
|
|
|
|
{0, 0, 0, EXCEPTION_REF(exception_data, tit)}
|
|
|
|
};
|
|
|
|
|
|
|
|
EXCEPTION_RECORD rec = {CXX_EXCEPTION, 0, NULL, NULL, 3, {CXX_FRAME_MAGIC_VC6, 0, (ULONG_PTR)&exception_data.et}};
|
|
|
|
EXCEPTION_POINTERS except_ptrs = {&rec, NULL};
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
rec.NumberParameters = 4;
|
|
|
|
rec.ExceptionInformation[3] = (ULONG_PTR)&exception_data;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ret = p_is_exception_typeof(&ti1, &except_ptrs);
|
|
|
|
ok(ret == 1, "_is_exception_typeof returned %d\n", ret);
|
|
|
|
ret = p_is_exception_typeof(&ti2, &except_ptrs);
|
|
|
|
ok(ret == 1, "_is_exception_typeof returned %d\n", ret);
|
|
|
|
ret = p_is_exception_typeof(&ti3, &except_ptrs);
|
|
|
|
ok(ret == 0, "_is_exception_typeof returned %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2014-05-07 12:08:06 +02:00
|
|
|
static void test__AdjustPointer(void)
|
|
|
|
{
|
|
|
|
int off = 0xf0;
|
|
|
|
void *obj1 = &off;
|
|
|
|
void *obj2 = (char*)&off - 2;
|
|
|
|
struct test_data {
|
|
|
|
void *ptr;
|
|
|
|
void *ret;
|
|
|
|
struct {
|
|
|
|
int this_offset;
|
|
|
|
int vbase_descr;
|
|
|
|
int vbase_offset;
|
|
|
|
} this_ptr_offsets;
|
|
|
|
} data[] = {
|
|
|
|
{NULL, NULL, {0, -1, 0}},
|
|
|
|
{(void*)0xbeef, (void*)0xbef0, {1, -1, 1}},
|
|
|
|
{(void*)0xbeef, (void*)0xbeee, {-1, -1, 0}},
|
|
|
|
{&obj1, (char*)&obj1 + off, {0, 0, 0}},
|
|
|
|
{(char*)&obj1 - 5, (char*)&obj1 + off, {0, 5, 0}},
|
|
|
|
{(char*)&obj1 - 3, (char*)&obj1 + off + 24, {24, 3, 0}},
|
|
|
|
{(char*)&obj2 - 17, (char*)&obj2 + off + 4, {4, 17, 2}}
|
|
|
|
};
|
|
|
|
void *ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i<sizeof(data)/sizeof(data[0]); i++) {
|
|
|
|
ret = p__AdjustPointer(data[i].ptr, &data[i].this_ptr_offsets);
|
|
|
|
ok(ret == data[i].ret, "%d) __AdjustPointer returned %p, expected %p\n", i, ret, data[i].ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 11:57:59 +02:00
|
|
|
static void test_mbstowcs(void)
|
|
|
|
{
|
|
|
|
wchar_t bufw[16];
|
|
|
|
char buf[16];
|
|
|
|
size_t ret;
|
|
|
|
|
|
|
|
buf[0] = 'a';
|
|
|
|
buf[1] = 0;
|
|
|
|
memset(bufw, 'x', sizeof(bufw));
|
|
|
|
ret = p_mbstowcs(bufw, buf, -1);
|
|
|
|
ok(ret == 1, "ret = %d\n", (int)ret);
|
|
|
|
ok(bufw[0] == 'a', "bufw[0] = '%c'\n", bufw[0]);
|
|
|
|
ok(bufw[1] == 0, "bufw[1] = '%c'\n", bufw[1]);
|
|
|
|
|
|
|
|
memset(bufw, 'x', sizeof(bufw));
|
|
|
|
ret = p_mbstowcs(bufw, buf, -1000);
|
|
|
|
ok(ret == 1, "ret = %d\n", (int)ret);
|
|
|
|
ok(bufw[0] == 'a', "bufw[0] = '%c'\n", bufw[0]);
|
|
|
|
ok(bufw[1] == 0, "bufw[1] = '%c'\n", bufw[1]);
|
|
|
|
|
|
|
|
memset(buf, 'x', sizeof(buf));
|
|
|
|
ret = p_wcstombs(buf, bufw, -1);
|
|
|
|
ok(ret == 1, "ret = %d\n", (int)ret);
|
|
|
|
ok(buf[0] == 'a', "buf[0] = '%c'\n", buf[0]);
|
|
|
|
ok(buf[1] == 0, "buf[1] = '%c'\n", buf[1]);
|
|
|
|
|
|
|
|
memset(buf, 'x', sizeof(buf));
|
|
|
|
ret = p_wcstombs(buf, bufw, -1000);
|
|
|
|
ok(ret == 1, "ret = %d\n", (int)ret);
|
|
|
|
ok(buf[0] == 'a', "buf[0] = '%c'\n", buf[0]);
|
|
|
|
ok(buf[1] == 0, "buf[1] = '%c'\n", buf[1]);
|
|
|
|
|
|
|
|
if(!p_setlocale(LC_ALL, "English")) {
|
|
|
|
win_skip("English locale not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[0] = 'a';
|
|
|
|
buf[1] = 0;
|
|
|
|
memset(bufw, 'x', sizeof(bufw));
|
|
|
|
ret = p_mbstowcs(bufw, buf, -1);
|
|
|
|
ok(ret == -1, "ret = %d\n", (int)ret);
|
|
|
|
ok(bufw[0] == 0, "bufw[0] = '%c'\n", bufw[0]);
|
|
|
|
|
|
|
|
memset(bufw, 'x', sizeof(bufw));
|
|
|
|
ret = p_mbstowcs(bufw, buf, -1000);
|
|
|
|
ok(ret == -1, "ret = %d\n", (int)ret);
|
|
|
|
ok(bufw[0] == 0, "bufw[0] = '%c'\n", bufw[0]);
|
|
|
|
|
|
|
|
memset(buf, 'x', sizeof(buf));
|
|
|
|
ret = p_wcstombs(buf, bufw, -1);
|
|
|
|
ok(ret == 0, "ret = %d\n", (int)ret);
|
|
|
|
ok(buf[0] == 0, "buf[0] = '%c'\n", buf[0]);
|
|
|
|
|
|
|
|
memset(buf, 'x', sizeof(buf));
|
|
|
|
ret = p_wcstombs(buf, bufw, -1000);
|
|
|
|
ok(ret == 0, "ret = %d\n", (int)ret);
|
|
|
|
ok(buf[0] == 0, "buf[0] = '%c'\n", buf[0]);
|
|
|
|
|
|
|
|
p_setlocale(LC_ALL, "C");
|
|
|
|
}
|
|
|
|
|
2010-03-20 00:32:17 +01:00
|
|
|
START_TEST(msvcr90)
|
|
|
|
{
|
2011-05-24 17:23:34 +02:00
|
|
|
if(!init())
|
2010-03-20 00:32:17 +01:00
|
|
|
return;
|
2010-04-02 23:46:08 +02:00
|
|
|
|
2010-03-20 00:32:17 +01:00
|
|
|
test__initterm_e();
|
2010-03-25 11:06:29 +01:00
|
|
|
test__encode_pointer();
|
2010-03-24 22:40:40 +01:00
|
|
|
test_error_messages();
|
2010-04-01 12:39:50 +02:00
|
|
|
test__strtoi64();
|
2010-11-11 22:30:25 +01:00
|
|
|
test__itoa_s();
|
2010-11-15 22:00:10 +01:00
|
|
|
test_wcsncat_s();
|
2010-11-17 17:07:58 +01:00
|
|
|
test_qsort_s();
|
2012-07-16 20:36:10 +02:00
|
|
|
test_bsearch_s();
|
2010-11-27 20:40:14 +01:00
|
|
|
test_controlfp_s();
|
2012-07-17 21:49:09 +02:00
|
|
|
test_tmpfile_s();
|
2011-01-18 17:06:07 +01:00
|
|
|
test__atoflt();
|
2011-01-19 23:21:11 +01:00
|
|
|
test__set_abort_behavior();
|
2011-01-26 23:56:30 +01:00
|
|
|
test__sopen_s();
|
|
|
|
test__wsopen_s();
|
2011-01-28 01:21:06 +01:00
|
|
|
test__realloc_crt();
|
2011-02-03 13:56:33 +01:00
|
|
|
test_typeinfo();
|
2011-05-24 17:23:57 +02:00
|
|
|
test_getptd();
|
2011-11-15 14:20:49 +01:00
|
|
|
test__vswprintf_l();
|
2011-11-16 12:51:06 +01:00
|
|
|
test_nonblocking_file_access();
|
2012-04-16 18:11:37 +02:00
|
|
|
test_byteswap();
|
2013-08-21 22:13:36 +02:00
|
|
|
test_access_s();
|
2014-01-06 17:54:26 +01:00
|
|
|
test_is_exception_typeof();
|
2014-05-07 12:08:06 +02:00
|
|
|
test__AdjustPointer();
|
2016-06-14 11:57:59 +02:00
|
|
|
test_mbstowcs();
|
2010-03-20 00:32:17 +01:00
|
|
|
}
|