From 73e669c6bcc45148abb43e906468acc3487f371d Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Sat, 20 Mar 2010 00:32:17 +0100 Subject: [PATCH] msvcr90/tests: Add tests for _initterm_e. --- configure | 1 + configure.ac | 1 + dlls/msvcr90/tests/Makefile.in | 17 ++++ dlls/msvcr90/tests/msvcr90.c | 150 ++++++++++++++++++++++++++++ dlls/msvcr90/tests/msvcr90.manifest | 22 ++++ dlls/msvcr90/tests/msvcr90.rc | 22 ++++ 6 files changed, 213 insertions(+) create mode 100644 dlls/msvcr90/tests/Makefile.in create mode 100644 dlls/msvcr90/tests/msvcr90.c create mode 100644 dlls/msvcr90/tests/msvcr90.manifest create mode 100644 dlls/msvcr90/tests/msvcr90.rc diff --git a/configure b/configure index bc905771e05..8cdd4210f55 100755 --- a/configure +++ b/configure @@ -14359,6 +14359,7 @@ wine_fn_config_dll msvcr70 enable_msvcr70 msvcr70 wine_fn_config_dll msvcr71 enable_msvcr71 msvcr71 wine_fn_config_dll msvcr80 enable_msvcr80 msvcr80 wine_fn_config_dll msvcr90 enable_msvcr90 msvcr90 +wine_fn_config_test dlls/msvcr90/tests msvcr90_test wine_fn_config_dll msvcrt enable_msvcrt msvcrt wine_fn_config_test dlls/msvcrt/tests msvcrt_test wine_fn_config_dll msvcrt20 enable_msvcrt20 msvcrt20 diff --git a/configure.ac b/configure.ac index 8a8bba4b17e..bf6693470eb 100644 --- a/configure.ac +++ b/configure.ac @@ -2401,6 +2401,7 @@ WINE_CONFIG_DLL(msvcr70,,[msvcr70]) WINE_CONFIG_DLL(msvcr71,,[msvcr71]) WINE_CONFIG_DLL(msvcr80,,[msvcr80]) WINE_CONFIG_DLL(msvcr90,,[msvcr90]) +WINE_CONFIG_TEST(dlls/msvcr90/tests) WINE_CONFIG_DLL(msvcrt,,[msvcrt]) WINE_CONFIG_TEST(dlls/msvcrt/tests) WINE_CONFIG_DLL(msvcrt20,,[msvcrt20]) diff --git a/dlls/msvcr90/tests/Makefile.in b/dlls/msvcr90/tests/Makefile.in new file mode 100644 index 00000000000..39fb4c3fd35 --- /dev/null +++ b/dlls/msvcr90/tests/Makefile.in @@ -0,0 +1,17 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = msvcr90.dll +APPMODE = -mno-cygwin +IMPORTS = kernel32 +MODCFLAGS = @BUILTINFLAG@ +EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt + +C_SRCS = \ + msvcr90.c + +RC_SRCS = \ + msvcr90.rc + +@MAKE_TEST_RULES@ diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c new file mode 100644 index 00000000000..ddfd7815c92 --- /dev/null +++ b/dlls/msvcr90/tests/msvcr90.c @@ -0,0 +1,150 @@ +/* + * 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 +#include +#include + +#include +#include +#include +#include "wine/test.h" + +typedef int (__cdecl *_INITTERM_E_FN)(void); +static int (__cdecl *p_initterm_e)(_INITTERM_E_FN *table, _INITTERM_E_FN *end); +int cb_called[4]; + +/* ########## */ + +static int initterm_cb0(void) +{ + cb_called[0]++; + return 0; +} + +static int initterm_cb1(void) +{ + cb_called[1]++; + return 1; +} + +static int initterm_cb2(void) +{ + cb_called[2]++; + return 2; +} + + +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)); + 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]); + +} + +/* ########## */ + +START_TEST(msvcr90) +{ + HMODULE hcrt; + + SetLastError(0xdeadbeef); + hcrt = LoadLibraryA("msvcr90.dll"); + if (!hcrt) { + win_skip("msvcr90.dll not installed (got %d)\n", GetLastError()); + return; + } + + p_initterm_e = (void *) GetProcAddress(hcrt, "_initterm_e"); + + test__initterm_e(); + +} diff --git a/dlls/msvcr90/tests/msvcr90.manifest b/dlls/msvcr90/tests/msvcr90.manifest new file mode 100644 index 00000000000..ff7566d8fed --- /dev/null +++ b/dlls/msvcr90/tests/msvcr90.manifest @@ -0,0 +1,22 @@ + + + +Wine msvcr90 test suite + + + + + + diff --git a/dlls/msvcr90/tests/msvcr90.rc b/dlls/msvcr90/tests/msvcr90.rc new file mode 100644 index 00000000000..056767d9e75 --- /dev/null +++ b/dlls/msvcr90/tests/msvcr90.rc @@ -0,0 +1,22 @@ +/* + * Copyright (c) 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 "winuser.h" + +/* @makedep: msvcr90.manifest */ +1 RT_MANIFEST msvcr90.manifest