From eb9584d7fc35978db8cd1ca335aae334ab3416d5 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 24 Aug 2016 13:58:16 +0200 Subject: [PATCH] msvcr90: Add _fpieee_flt tests. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcr90/tests/msvcr90.c | 167 +++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c index a4bcdc5dc23..5c5a6bf3622 100644 --- a/dlls/msvcr90/tests/msvcr90.c +++ b/dlls/msvcr90/tests/msvcr90.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -128,6 +130,7 @@ static int (__cdecl *p_fflush_nolock)(FILE*); 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*); +static int (__cdecl *p__fpieee_flt)(ULONG, EXCEPTION_POINTERS*, int (__cdecl *handler)(_FPIEEE_RECORD*)); /* make sure we use the correct errno */ #undef errno @@ -393,6 +396,7 @@ static BOOL init(void) SET(p_mbstowcs, "mbstowcs"); SET(p_wcstombs, "wcstombs"); SET(p_setlocale, "setlocale"); + SET(p__fpieee_flt, "_fpieee_flt"); if (sizeof(void *) == 8) { SET(p_type_info_name_internal_method, "?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z"); @@ -1633,6 +1637,166 @@ static void test__mbstok_s(void) ok(context == space+1, "Expected space+1, got %p.\n", context); } +#ifdef __i386__ +static _FPIEEE_RECORD fpieee_record; +static int handler_called; +static int __cdecl fpieee_handler(_FPIEEE_RECORD *rec) +{ + handler_called++; + fpieee_record = *rec; + return EXCEPTION_CONTINUE_EXECUTION; +} + +static void test__fpieee_flt(void) +{ + double argd = 1.5; + struct { + DWORD exception_code; + WORD opcode; + DWORD data_offset; + DWORD control_word; + DWORD status_word; + _FPIEEE_RECORD rec; + int ret; + } test_data[] = { + { STATUS_FLOAT_DIVIDE_BY_ZERO, 0x35dc, (DWORD)&argd, 0, 0, + {0, 2, _FpCodeDivide, + {0}, {1, 1, 1, 1, 1}, {0}, + {{0}, 1, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 0, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_INEXACT_RESULT, 0x35dc, (DWORD)&argd, 0, 0, + {0, 2, _FpCodeDivide, + {0}, {1, 1, 1, 1, 1}, {0}, + {{0}, 0, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 1, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_INVALID_OPERATION, 0x35dc, (DWORD)&argd, 0, 0, + {0, 2, _FpCodeDivide, + {0}, {1, 1, 1, 1, 1}, {0}, + {{0}, 1, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 0, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_OVERFLOW, 0x35dc, (DWORD)&argd, 0, 0, + {0, 2, _FpCodeDivide, + {0}, {1, 1, 1, 1, 1}, {0}, + {{0}, 0, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 1, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_UNDERFLOW, 0x35dc, (DWORD)&argd, 0, 0, + {0, 2, _FpCodeDivide, + {0}, {1, 1, 1, 1, 1}, {0}, + {{0}, 0, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 1, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_DIVIDE_BY_ZERO, 0x35dc, (DWORD)&argd, 0, 0xffffffff, + {0, 2, _FpCodeDivide, + {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, + {{0}, 1, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 0, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + { STATUS_FLOAT_DIVIDE_BY_ZERO, 0x35dc, (DWORD)&argd, 0xffffffff, 0xffffffff, + {3, 0, _FpCodeDivide, + {0}, {0}, {1, 1, 1, 1, 1}, + {{0}, 1, _FpFormatFp80}, + {{0}, 1, _FpFormatFp64}, + {{0}, 0, _FpFormatFp80}}, + EXCEPTION_CONTINUE_EXECUTION }, + }; + EXCEPTION_POINTERS ep; + EXCEPTION_RECORD rec; + CONTEXT ctx; + int i, ret; + + if(!p__fpieee_flt) { + win_skip("_fpieee_flt not available\n"); + return; + } + + ep.ExceptionRecord = &rec; + ep.ContextRecord = &ctx; + memset(&rec, 0, sizeof(rec)); + memset(&ctx, 0, sizeof(ctx)); + ret = p__fpieee_flt(1, &ep, fpieee_handler); + ok(ret == EXCEPTION_CONTINUE_SEARCH, "_fpieee_flt returned %d\n", ret); + ok(handler_called == 0, "handler_called = %d\n", handler_called); + + for(i=0; i