msvcrt[2/3]: add initial tests for dlls/msvcrt/data.c [try 3]

Andrew Ziem ahziem1 at mailbolt.com
Wed Jun 14 08:33:29 CDT 2006


In try 3, a patch comment is more explicit.  Thank you Uwe Bonnes for
pointing out the ambiguity.

In try 2, the tests no longer use dynamic loading.  Thank you Alexandre
Julliard.

---

 dlls/msvcrt/tests/Makefile.in |    1 
 dlls/msvcrt/tests/data.c      |   88 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100644 dlls/msvcrt/tests/data.c

3aead0d541a8796e5e21f1b39b6e1dbb2243891d
diff --git a/dlls/msvcrt/tests/Makefile.in b/dlls/msvcrt/tests/Makefile.in
index 9569f1e..38ddf05 100644
--- a/dlls/msvcrt/tests/Makefile.in
+++ b/dlls/msvcrt/tests/Makefile.in
@@ -9,6 +9,7 @@ EXTRAINCL = -I$(TOPSRCDIR)/include/msvcr
 
 CTESTS = \
 	cpp.c \
+	data.c \
 	dir.c \
 	environ.c \
 	file.c \
diff --git a/dlls/msvcrt/tests/data.c b/dlls/msvcrt/tests/data.c
new file mode 100644
index 0000000..3fb2610
--- /dev/null
+++ b/dlls/msvcrt/tests/data.c
@@ -0,0 +1,88 @@
+/*
+ * Tests msvcrt/data.c
+ *
+ * Copyright 2006 Andrew Ziem
+ *
+ * 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 "msvcrt.h"
+#include "wine/test.h"
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <io.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <process.h>
+#include <errno.h>
+
+static int callbacked;
+
+void initcallback(void)
+{
+   callbacked++;
+}
+
+#define initterm_test(start, end, expected) \
+    callbacked = 0; \
+    rc = _initterm(start, end); \
+    ok(expected == rc, "_initterm: return result mismatch: got %i, expected %i\n", rc, expected); \
+    ok(expected == callbacked,"_initterm: callbacks count mismatch: got %i, expected %i\n", callbacked, expected);
+
+void test_initterm(void)
+{
+    int i;
+    int rc;
+    static _INITTERMFUN callbacks[4];
+
+    for (i = 0; i < 4; i++)
+    {
+        callbacks[i] = initcallback;
+    }
+    
+    /* address 1 < address 2 */
+    initterm_test(&callbacks[0], &callbacks[1], 1);
+    initterm_test(&callbacks[0], &callbacks[2], 2);
+    initterm_test(&callbacks[0], &callbacks[3], 3);
+
+    /* disabled because tests on W2K yield inconsistent results */
+#if 0
+    /* address 1 == address 2 */
+    initterm_test(&callbacks[0], &callbacks[0], 0); /* W2K: 0 or 1 */
+
+    /* address 1 > address 2 */
+    initterm_test(&callbacks[1], &callbacks[0], 0); /* W2K: 0 or 4 */
+
+    /* one or more address is NULL */
+    initterm_test(&callbacks[0], NULL, 6); /* W2K: 6 or 0 */
+#endif
+
+    callbacks[1] = NULL;
+    initterm_test(&callbacks[0], &callbacks[3], 2);
+
+    /* disabled because test crashes Wine and W2K */
+#if 0
+    initterm_test(NULL, &callbacks[0], 0);
+#endif
+}
+
+START_TEST(data)
+{
+    test_initterm();
+}
-- 
1.3.3




More information about the wine-patches mailing list