ntprint/tests: Add initial test.
authorDetlef Riekenberg <wine.dev@web.de>
Thu, 21 Jun 2007 04:07:10 +0000 (06:07 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 21 Jun 2007 13:37:36 +0000 (15:37 +0200)
.gitignore
Makefile.in
configure
configure.ac
dlls/Makefile.in
dlls/ntprint/tests/Makefile.in [new file with mode: 0644]
dlls/ntprint/tests/ntprint.c [new file with mode: 0644]
programs/winetest/Makefile.in
programs/winetest/winetest.rc

index b70d332..5d2ed28 100644 (file)
@@ -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
index fe6731b..f0045d3 100644 (file)
@@ -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
index 88b8eb8..06b92fc 100755 (executable)
--- 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" ;;
index b5bffb8..d28be8c 100644 (file)
@@ -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])
index 265b541..89e5b33 100644 (file)
@@ -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 (file)
index 0000000..65febfe
--- /dev/null
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = ntprint.dll
+IMPORTS   = kernel32
+
+CTESTS = \
+       ntprint.c
+
+@MAKE_TEST_RULES@
+
+@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 (file)
index 0000000..280876b
--- /dev/null
@@ -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();
+
+}
index bf2fd4a..3b85ea9 100644 (file)
@@ -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)
index e8a0772..d6d0c0d 100644 (file)
@@ -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"