Detlef Riekenberg : ntprint/tests: Add initial test.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 21 09:47:37 CDT 2007
Module: wine
Branch: master
Commit: a114483e497432b95ec3557362cbae04fee99c13
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a114483e497432b95ec3557362cbae04fee99c13
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Thu Jun 21 06:07:10 2007 +0200
ntprint/tests: Add initial test.
---
.gitignore | 4 +
Makefile.in | 2 +
configure | 3 +
configure.ac | 1 +
dlls/Makefile.in | 1 +
dlls/ntprint/tests/Makefile.in | 13 ++++
dlls/ntprint/tests/ntprint.c | 129 ++++++++++++++++++++++++++++++++++++++++
programs/winetest/Makefile.in | 3 +
programs/winetest/winetest.rc | 1 +
9 files changed, 157 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index b70d332..5d2ed28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -384,6 +384,9 @@ dlls/ntdll/version.res
dlls/ntdsapi/libntdsapi.def
dlls/ntoskrnl.exe/libntoskrnl.exe.def
dlls/ntprint/ntprint.res
+dlls/ntprint/tests/*.ok
+dlls/ntprint/tests/ntprint_crosstest.exe
+dlls/ntprint/tests/testlist.c
dlls/objsel/objsel.res
dlls/odbc32/libodbc32.def
dlls/odbccp32/libodbccp32.def
@@ -874,6 +877,7 @@ programs/winetest/msvcrtd_test.exe
programs/winetest/msxml3_test.exe
programs/winetest/netapi32_test.exe
programs/winetest/ntdll_test.exe
+programs/winetest/ntprint_test.exe
programs/winetest/odbccp32_test.exe
programs/winetest/ole32_test.exe
programs/winetest/oleaut32_test.exe
diff --git a/Makefile.in b/Makefile.in
index fe6731b..f0045d3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -315,6 +315,7 @@ ALL_MAKEFILES = \
dlls/ntdsapi/Makefile \
dlls/ntoskrnl.exe/Makefile \
dlls/ntprint/Makefile \
+ dlls/ntprint/tests/Makefile \
dlls/objsel/Makefile \
dlls/odbc32/Makefile \
dlls/odbccp32/Makefile \
@@ -671,6 +672,7 @@ dlls/ntdll/tests/Makefile: dlls/ntdll/tests/Makefile.in dlls/Maketest.rules
dlls/ntdsapi/Makefile: dlls/ntdsapi/Makefile.in dlls/Makedll.rules
dlls/ntoskrnl.exe/Makefile: dlls/ntoskrnl.exe/Makefile.in dlls/Makedll.rules
dlls/ntprint/Makefile: dlls/ntprint/Makefile.in dlls/Makedll.rules
+dlls/ntprint/tests/Makefile: dlls/ntprint/tests/Makefile.in dlls/Maketest.rules
dlls/objsel/Makefile: dlls/objsel/Makefile.in dlls/Makedll.rules
dlls/odbc32/Makefile: dlls/odbc32/Makefile.in dlls/Makedll.rules
dlls/odbccp32/Makefile: dlls/odbccp32/Makefile.in dlls/Makedll.rules
diff --git a/configure b/configure
index 88b8eb8..06b92fc 100755
--- a/configure
+++ b/configure
@@ -20700,6 +20700,8 @@ ac_config_files="$ac_config_files dlls/ntoskrnl.exe/Makefile"
ac_config_files="$ac_config_files dlls/ntprint/Makefile"
+ac_config_files="$ac_config_files dlls/ntprint/tests/Makefile"
+
ac_config_files="$ac_config_files dlls/objsel/Makefile"
ac_config_files="$ac_config_files dlls/odbc32/Makefile"
@@ -21791,6 +21793,7 @@ do
"dlls/ntdsapi/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ntdsapi/Makefile" ;;
"dlls/ntoskrnl.exe/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ntoskrnl.exe/Makefile" ;;
"dlls/ntprint/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ntprint/Makefile" ;;
+ "dlls/ntprint/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ntprint/tests/Makefile" ;;
"dlls/objsel/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/objsel/Makefile" ;;
"dlls/odbc32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/odbc32/Makefile" ;;
"dlls/odbccp32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/odbccp32/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index b5bffb8..d28be8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1602,6 +1602,7 @@ AC_CONFIG_FILES([dlls/ntdll/tests/Makefile])
AC_CONFIG_FILES([dlls/ntdsapi/Makefile])
AC_CONFIG_FILES([dlls/ntoskrnl.exe/Makefile])
AC_CONFIG_FILES([dlls/ntprint/Makefile])
+AC_CONFIG_FILES([dlls/ntprint/tests/Makefile])
AC_CONFIG_FILES([dlls/objsel/Makefile])
AC_CONFIG_FILES([dlls/odbc32/Makefile])
AC_CONFIG_FILES([dlls/odbccp32/Makefile])
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 265b541..89e5b33 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -269,6 +269,7 @@ TESTSUBDIRS = \
msxml3/tests \
netapi32/tests \
ntdll/tests \
+ ntprint/tests \
odbccp32/tests \
ole32/tests \
oleaut32/tests \
diff --git a/dlls/ntprint/tests/Makefile.in b/dlls/ntprint/tests/Makefile.in
new file mode 100644
index 0000000..65febfe
--- /dev/null
+++ b/dlls/ntprint/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = ntprint.dll
+IMPORTS = kernel32
+
+CTESTS = \
+ ntprint.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/ntprint/tests/ntprint.c b/dlls/ntprint/tests/ntprint.c
new file mode 100644
index 0000000..280876b
--- /dev/null
+++ b/dlls/ntprint/tests/ntprint.c
@@ -0,0 +1,129 @@
+/*
+ * Unit test suite for the Spooler Setup API (Printing)
+ *
+ * Copyright 2007 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 <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wingdi.h"
+#include "wine/test.h"
+
+
+/* ##### */
+
+static HMODULE hdll;
+static HANDLE (WINAPI *pPSetupCreateMonitorInfo)(LPVOID, LPVOID, LPVOID);
+static VOID (WINAPI *pPSetupDestroyMonitorInfo)(HANDLE);
+
+/* ########################### */
+
+static LPCSTR load_functions(void)
+{
+ LPCSTR ptr;
+
+ ptr = "ntprint.dll";
+ hdll = LoadLibraryA(ptr);
+ if (!hdll) return ptr;
+
+ ptr = "PSetupCreateMonitorInfo";
+ pPSetupCreateMonitorInfo = (VOID *) GetProcAddress(hdll, ptr);
+ if (!pPSetupCreateMonitorInfo) return ptr;
+
+ ptr = "PSetupDestroyMonitorInfo";
+ pPSetupDestroyMonitorInfo = (VOID *) GetProcAddress(hdll, ptr);
+ if (!pPSetupDestroyMonitorInfo) return ptr;
+
+
+ return NULL;
+}
+
+/* ########################### */
+
+static void test_PSetupCreateMonitorInfo(VOID)
+{
+ HANDLE mi;
+ BYTE buffer[1024] ;
+
+ SetLastError(0xdeadbeef);
+ mi = pPSetupCreateMonitorInfo(NULL, NULL, NULL);
+ ok( mi != NULL, "got %p with %u (expected '!= NULL')\n", mi, GetLastError());
+ if (mi) pPSetupDestroyMonitorInfo(mi);
+
+
+ memset(buffer, 0, sizeof(buffer));
+ SetLastError(0xdeadbeef);
+ mi = pPSetupCreateMonitorInfo(buffer, NULL, NULL);
+ ok( mi != NULL, "got %p with %u (expected '!= NULL')\n", mi, GetLastError());
+ if (mi) pPSetupDestroyMonitorInfo(mi);
+
+}
+
+/* ########################### */
+
+static void test_PSetupDestroyMonitorInfo(VOID)
+{
+ HANDLE mi;
+
+
+ SetLastError(0xdeadbeef);
+ pPSetupDestroyMonitorInfo(NULL);
+ /* lasterror is returned */
+ trace("returned with %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ mi = pPSetupCreateMonitorInfo(NULL, NULL, NULL);
+ ok( mi != NULL, "got %p with %u (expected '!= NULL')\n", mi, GetLastError());
+
+ if (!mi) return;
+
+ SetLastError(0xdeadbeef);
+ pPSetupDestroyMonitorInfo(mi);
+ /* lasterror is returned */
+ trace("returned with %u\n", GetLastError());
+
+ /* Try to destroy the handle twice crash with native ntprint.dll */
+ if (0) {
+ SetLastError(0xdeadbeef);
+ pPSetupDestroyMonitorInfo(mi);
+ trace(" with %u\n", GetLastError());
+ }
+
+}
+
+/* ########################### */
+
+START_TEST(ntprint)
+{
+ LPCSTR ptr;
+
+ /* ntprint.dll does not exist on win9x */
+ ptr = load_functions();
+ if (ptr) {
+ skip("%s not found\n", ptr);
+ return;
+ }
+
+ test_PSetupCreateMonitorInfo();
+ test_PSetupDestroyMonitorInfo();
+
+}
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index bf2fd4a..3b85ea9 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -60,6 +60,7 @@ TESTBINS = \
msxml3_test.exe \
netapi32_test.exe \
ntdll_test.exe \
+ ntprint_test.exe \
odbccp32_test.exe \
ole32_test.exe \
oleaut32_test.exe \
@@ -162,6 +163,8 @@ netapi32_test.exe: $(DLLDIR)/netapi32/tests/netapi32_test.exe$(DLLEXT)
cp $(DLLDIR)/netapi32/tests/netapi32_test.exe$(DLLEXT) $@ && $(STRIP) $@
ntdll_test.exe: $(DLLDIR)/ntdll/tests/ntdll_test.exe$(DLLEXT)
cp $(DLLDIR)/ntdll/tests/ntdll_test.exe$(DLLEXT) $@ && $(STRIP) $@
+ntprint_test.exe: $(DLLDIR)/ntprint/tests/ntprint_test.exe$(DLLEXT)
+ cp $(DLLDIR)/ntprint/tests/ntprint_test.exe$(DLLEXT) $@ && $(STRIP) $@
odbccp32_test.exe: $(DLLDIR)/odbccp32/tests/odbccp32_test.exe$(DLLEXT)
cp $(DLLDIR)/odbccp32/tests/odbccp32_test.exe$(DLLEXT) $@ && $(STRIP) $@
ole32_test.exe: $(DLLDIR)/ole32/tests/ole32_test.exe$(DLLEXT)
diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc
index e8a0772..d6d0c0d 100644
--- a/programs/winetest/winetest.rc
+++ b/programs/winetest/winetest.rc
@@ -183,6 +183,7 @@ msvcrtd_test.exe TESTRES "msvcrtd_test.exe"
msxml3_test.exe TESTRES "msxml3_test.exe"
netapi32_test.exe TESTRES "netapi32_test.exe"
ntdll_test.exe TESTRES "ntdll_test.exe"
+ntprint_test.exe TESTRES "ntprint_test.exe"
odbccp32_test.exe TESTRES "odbccp32_test.exe"
ole32_test.exe TESTRES "ole32_test.exe"
oleaut32_test.exe TESTRES "oleaut32_test.exe"
More information about the wine-cvs
mailing list