[PATCH] msvcr90/tests: Add tests for _initterm_e [try 2]
Detlef Riekenberg
wine.dev at web.de
Fri Mar 19 18:32:17 CDT 2010
Now with the correct imports in Makefile.in
--
By by ... Detlef
---
dlls/msvcr90/tests/Makefile.in | 14 +++
dlls/msvcr90/tests/msvcr90.c | 151 +++++++++++++++++++++++++++++++++++
dlls/msvcr90/tests/msvcr90.manifest | 22 +++++
dlls/msvcr90/tests/msvcr90.rc | 31 +++++++
4 files changed, 218 insertions(+), 0 deletions(-)
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/dlls/msvcr90/tests/Makefile.in b/dlls/msvcr90/tests/Makefile.in
new file mode 100644
index 0000000..49f7c84
--- /dev/null
+++ b/dlls/msvcr90/tests/Makefile.in
@@ -0,0 +1,14 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = msvcr90.dll
+IMPORTS = kernel32
+
+C_SRCS = \
+ msvcr90.c
+
+RC_SRCS = \
+ msvcr90.rc
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
new file mode 100644
index 0000000..17dcebf
--- /dev/null
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -0,0 +1,151 @@
+/*
+ * 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>
+
+#include <windef.h>
+#include <winbase.h>
+#include <errno.h>
+#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 0000000..ff7566d
--- /dev/null
+++ b/dlls/msvcr90/tests/msvcr90.manifest
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity
+ type="win32"
+ name="Wine.msvcr90.Test"
+ version="1.0.0.0"
+ processorArchitecture="*"
+ />
+<description>Wine msvcr90 test suite</description>
+<dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="microsoft.vc90.crt"
+ version="9.0.20718.0"
+ processorArchitecture="*"
+ publicKeyToken="1fc8b3b9a1e18e3b"
+ language="*"
+ />
+</dependentAssembly>
+</dependency>
+</assembly>
diff --git a/dlls/msvcr90/tests/msvcr90.rc b/dlls/msvcr90/tests/msvcr90.rc
new file mode 100644
index 0000000..06feb6e
--- /dev/null
+++ b/dlls/msvcr90/tests/msvcr90.rc
@@ -0,0 +1,31 @@
+/*
+ * 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
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine tests for VC90 runtime"
+#define WINE_FILENAME_STR "msvcr90_test"
+#define WINE_FILEVERSION 9,0,30729,1
+#define WINE_FILEVERSION_STR "9.0.30729.1"
+#define WINE_PRODUCTVERSION 9,0,30729,1
+#define WINE_PRODUCTVERSION_STR "9.0.30729.1"
+
+#include "wine/wine_common_ver.rc"
+
+/* @makedep: msvcr90.manifest */
+1 24 msvcr90.manifest
+
+
--
1.7.0
More information about the wine-patches
mailing list