msvcr90/tests: Don't check if msvcr90 functions exists.

This commit is contained in:
Piotr Caban 2011-05-24 17:23:34 +02:00 committed by Alexandre Julliard
parent 6e777041b2
commit 696ba80347
1 changed files with 57 additions and 145 deletions

View File

@ -185,6 +185,62 @@ static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
}
#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");
SET(p_controlfp_s, "_controlfp_s");
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");
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");
}
else
{
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");
}
hkernel32 = GetModuleHandleA("kernel32.dll");
pEncodePointer = (void *) GetProcAddress(hkernel32, "EncodePointer");
return TRUE;
}
static int __cdecl initterm_cb0(void)
{
cb_called[0]++;
@ -209,11 +265,6 @@ static void test__initterm_e(void)
_INITTERM_E_FN table[4];
int res;
if (!p_initterm_e) {
skip("_initterm_e not found\n");
return;
}
memset(table, 0, sizeof(table));
memset(cb_called, 0, sizeof(cb_called));
@ -290,11 +341,6 @@ static void test__encode_pointer(void)
{
void *ptr, *res;
if(!p_encode_pointer || !p_decode_pointer || !p_encoded_null) {
win_skip("_encode_pointer, _decode_pointer or _encoded_null not found\n");
return;
}
ptr = (void*)0xdeadbeef;
res = p_encode_pointer(ptr);
res = p_decode_pointer(res);
@ -320,11 +366,6 @@ static void test_error_messages(void)
{
int *size, size_copy;
if(!p_sys_nerr || !p__sys_nerr || !p_sys_errlist || !p__sys_errlist) {
win_skip("Skipping test_error_messages tests\n");
return;
}
size = p__sys_nerr();
size_copy = *size;
ok(*p_sys_nerr == *size, "_sys_nerr = %u, size = %u\n", *p_sys_nerr, *size);
@ -342,16 +383,6 @@ static void test__strtoi64(void)
__int64 res;
unsigned __int64 ures;
if(!p_strtoi64 || !p_strtoui64) {
win_skip("_strtoi64 or _strtoui64 not found\n");
return;
}
if(!p_set_invalid_parameter_handler) {
win_skip("_set_invalid_parameter_handler not found\n");
return;
}
errno = 0xdeadbeef;
SET_EXPECT(invalid_parameter_handler);
res = p_strtoi64(NULL, NULL, 10);
@ -390,17 +421,6 @@ static void test__itoa_s(void)
errno_t ret;
char buffer[33];
if (!p_itoa_s)
{
win_skip("Skipping _itoa_s tests\n");
return;
}
if(!p_set_invalid_parameter_handler) {
win_skip("_set_invalid_parameter_handler not found\n");
return;
}
/* _itoa_s (on msvcr90) doesn't set errno (in case of errors) while msvcrt does
* as we always set errno in our msvcrt implementation, don't test here that errno
* isn't changed
@ -493,17 +513,6 @@ static void test_wcsncat_s(void)
wchar_t dst[4];
wchar_t src[4];
if (!p_wcsncat_s)
{
win_skip("skipping wcsncat_s tests\n");
return;
}
if(!p_set_invalid_parameter_handler) {
win_skip("_set_invalid_parameter_handler not found\n");
return;
}
memcpy(src, abcW, sizeof(abcW));
dst[0] = 0;
SET_EXPECT(invalid_parameter_handler);
@ -590,11 +599,6 @@ static void test_qsort_s(void)
"."
};
if(!p_qsort_s) {
win_skip("qsort_s not found\n");
return;
}
SET_EXPECT(invalid_parameter_handler);
p_qsort_s(NULL, 0, 0, NULL, NULL);
CHECK_CALLED(invalid_parameter_handler);
@ -688,12 +692,6 @@ static void test_controlfp_s(void)
unsigned int cur;
int ret;
if (!p_controlfp_s)
{
win_skip("_controlfp_s not found\n");
return;
}
SET_EXPECT(invalid_parameter_handler);
ret = p_controlfp_s( NULL, ~0, ~0 );
ok( ret == EINVAL, "wrong result %d\n", ret );
@ -753,12 +751,6 @@ static void test__atoflt(void)
_CRT_FLOAT flt;
int ret, i = 0;
if (!p_atoflt)
{
win_skip("_atoflt not found\n");
return;
}
if (0)
{
/* crashes on native */
@ -785,12 +777,6 @@ static void test__set_abort_behavior(void)
{
unsigned int res;
if (!p_set_abort_behavior)
{
win_skip("_set_abort_behavior not found\n");
return;
}
/* default is _WRITE_ABORT_MSG | _CALL_REPORTFAULT */
res = p_set_abort_behavior(0, 0);
ok (res == (_WRITE_ABORT_MSG | _CALL_REPORTFAULT),
@ -809,12 +795,6 @@ static void test__sopen_s(void)
{
int ret, fd;
if(!p_sopen_s)
{
win_skip("_sopen_s not found\n");
return;
}
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);
@ -831,12 +811,6 @@ static void test__wsopen_s(void)
wchar_t testW[] = {'t','e','s','t',0};
int ret, fd;
if(!p_wsopen_s)
{
win_skip("_wsopen_s not found\n");
return;
}
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);
@ -852,12 +826,6 @@ static void test__realloc_crt(void)
{
void *mem;
if(!p_realloc_crt)
{
win_skip("_realloc_crt not found\n");
return;
}
if (0)
{
/* crashes on some systems starting Vista */
@ -884,13 +852,6 @@ static void test_typeinfo(void)
struct __type_info_node node;
char *name;
if (!p_type_info_name_internal_method)
{
win_skip("public: char const * __thiscall type_info::_name_internal_method(struct \
__type_info_node *)const not supported\n");
return;
}
/* name */
t1.name = NULL;
node.memPtr = NULL;
@ -905,57 +866,8 @@ static void test_typeinfo(void)
START_TEST(msvcr90)
{
HMODULE hcrt;
HMODULE hkernel32;
SetLastError(0xdeadbeef);
hcrt = LoadLibraryA("msvcr90.dll");
if (!hcrt) {
win_skip("msvcr90.dll not installed (got %d)\n", GetLastError());
if(!init())
return;
}
p_set_invalid_parameter_handler = (void *) GetProcAddress(hcrt, "_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");
p_initterm_e = (void *) GetProcAddress(hcrt, "_initterm_e");
p_encode_pointer = (void *) GetProcAddress(hcrt, "_encode_pointer");
p_decode_pointer = (void *) GetProcAddress(hcrt, "_decode_pointer");
p_encoded_null = (void *) GetProcAddress(hcrt, "_encoded_null");
p_sys_nerr = (void *) GetProcAddress(hcrt, "_sys_nerr");
p__sys_nerr = (void *) GetProcAddress(hcrt, "__sys_nerr");
p_sys_errlist = (void *) GetProcAddress(hcrt, "_sys_errlist");
p__sys_errlist = (void *) GetProcAddress(hcrt, "__sys_errlist");
p_strtoi64 = (void *) GetProcAddress(hcrt, "_strtoi64");
p_strtoui64 = (void *) GetProcAddress(hcrt, "_strtoui64");
p_itoa_s = (void *)GetProcAddress(hcrt, "_itoa_s");
p_wcsncat_s = (void *)GetProcAddress( hcrt,"wcsncat_s" );
p_qsort_s = (void *) GetProcAddress(hcrt, "qsort_s");
p_controlfp_s = (void *) GetProcAddress(hcrt, "_controlfp_s");
p_atoflt = (void* )GetProcAddress(hcrt, "_atoflt");
p_set_abort_behavior = (void *) GetProcAddress(hcrt, "_set_abort_behavior");
p_sopen_s = (void*) GetProcAddress(hcrt, "_sopen_s");
p_wsopen_s = (void*) GetProcAddress(hcrt, "_wsopen_s");
p_realloc_crt = (void*) GetProcAddress(hcrt, "_realloc_crt");
p_malloc = (void*) GetProcAddress(hcrt, "malloc");
p_free = (void*)GetProcAddress(hcrt, "free");
if (sizeof(void *) == 8)
{
p_type_info_name_internal_method = (void*)GetProcAddress(hcrt,
"?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z");
ptype_info_dtor = (void*)GetProcAddress(hcrt, "??1type_info@@UEAA@XZ");
}
else
{
p_type_info_name_internal_method = (void*)GetProcAddress(hcrt,
"?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z");
ptype_info_dtor = (void*)GetProcAddress(hcrt, "??1type_info@@UAE@XZ");
}
hkernel32 = GetModuleHandleA("kernel32.dll");
pEncodePointer = (void *) GetProcAddress(hkernel32, "EncodePointer");
test__initterm_e();
test__encode_pointer();