[APITESTS]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sat, 21 Jul 2012 17:15:08 +0000 (17:15 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sat, 21 Jul 2012 17:15:08 +0000 (17:15 +0000)
- Move _vsnprintf to crt tests, where it belongs, and make it pass for crtdll

svn path=/trunk/; revision=56925

rostests/apitests/crt/_vsnprintf.c [new file with mode: 0644]
rostests/apitests/crt/crtdll_crt_apitest.cmake
rostests/apitests/crt/msvcrt_crt_apitest.cmake
rostests/apitests/crt/ntdll_crt_apitest.cmake
rostests/apitests/crt/testlist.c
rostests/apitests/msvcrt/CMakeLists.txt
rostests/apitests/msvcrt/_vsnprintf.c [deleted file]
rostests/apitests/msvcrt/testlist.c

diff --git a/rostests/apitests/crt/_vsnprintf.c b/rostests/apitests/crt/_vsnprintf.c
new file mode 100644 (file)
index 0000000..a6b1165
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for _vsnprintf
+ */
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <wine/test.h>
+#include <tchar.h>
+#include <pseh/pseh2.h>
+#include <ndk/mmfuncs.h>
+#include <ndk/rtlfuncs.h>
+
+#define StartSeh()              ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
+#define EndSeh(ExpectedStatus)  } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
+
+void call_varargs(char* buf, size_t buf_size, int expected_ret, LPCSTR formatString, ...)
+{
+    va_list args;
+    int ret;
+    /* Test the basic functionality */
+    va_start(args, formatString);
+    ret = _vsnprintf(buf, 255, formatString, args);
+    ok(expected_ret == ret, "Test failed: expected %i, got %i.\n", expected_ret, ret);
+}
+
+START_TEST(_vsnprintf)
+{
+    char buffer[255];
+    NTSTATUS ExceptionStatus;
+    /* Test basic functionality */
+    call_varargs(buffer, 255, 12, "%s world!", "hello");
+    /* This is how WINE implements _vcsprintf, and they are obviously wrong */
+    StartSeh()
+        call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does");
+#if defined(TEST_CRTDLL) || defined(TEST_USER32)
+    EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+    EndSeh(STATUS_SUCCESS);
+#endif
+    /* This one is no better */
+    StartSeh()    
+        call_varargs(NULL, 0, -1, "%s it really work?", "does");
+#if defined(TEST_CRTDLL) || defined(TEST_USER32)
+    EndSeh(STATUS_ACCESS_VIOLATION);
+#else
+    EndSeh(STATUS_SUCCESS);
+#endif
+}
index f739fb5..5cf8dd2 100644 (file)
@@ -314,7 +314,7 @@ list(APPEND SOURCE_CRTDLL
 #    _unlink.c
 #    _unloaddll.c
 #    _utime.c
-#    _vsnprintf.c
+    _vsnprintf.c
 #    _vsnwprintf.c
 #    _wcsdup.c
 #    _wcsicmp.c
index 5c75c23..3994110 100644 (file)
@@ -832,7 +832,7 @@ list(APPEND SOURCE_MSVCRT
 #    _vscwprintf.c
 #    _vscwprintf_l
 #    _vscwprintf_p_l
-#    _vsnprintf.c
+    _vsnprintf.c
 #    _vsnprintf_c.c _vsnprintf
 #    _vsnprintf_c_l.c _vsnprintf_l
 #    _vsnprintf_l.c
index 3b3560e..5542114 100644 (file)
@@ -34,7 +34,7 @@ list(APPEND SOURCE_NTDLL
 #    _ultoa.c
 #    _ultow.c
 #    _vscwprintf.c
-#    _vsnprintf.c
+    _vsnprintf.c
 #    _vsnwprintf.c
 #    _wcsicmp.c
 #    _wcslwr.c
index 4c2546c..780c739 100644 (file)
@@ -5,11 +5,13 @@
 #define STANDALONE
 #include "wine/test.h"
 
+extern void func__vsnprintf(void);
 extern void func_sprintf(void);
 extern void func_strcpy(void);
 
 const struct test winetest_testlist[] =
 {
+    { "_vsnprintf", func__vsnprintf },
     { "sprintf", func_sprintf },
     { "strcpy", func_strcpy },
 #if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT)
index c4a9d86..59c6772 100644 (file)
@@ -2,7 +2,6 @@
 add_definitions(-D_DLL -D__USE_CRTIMP)
 
 list(APPEND SOURCE
-    _vsnprintf.c
     ieee.c
     splitpath.c
     testlist.c)
diff --git a/rostests/apitests/msvcrt/_vsnprintf.c b/rostests/apitests/msvcrt/_vsnprintf.c
deleted file mode 100644 (file)
index d345c6b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * PROJECT:         ReactOS api tests
- * LICENSE:         GPL - See COPYING in the top level directory
- * PURPOSE:         Test for _vsnprintf
- */
-
-#include <wine/test.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <stdarg.h>
-
-void call_varargs(char* buf, size_t buf_size, int expected_ret, LPCSTR formatString, ...)
-{
-    va_list args;
-    int ret;
-    /* Test the basic functionality */
-    va_start(args, formatString);
-    ret = _vsnprintf(buf, 255, formatString, args);
-    ok(expected_ret == ret, "Test failed: expected %i, got %i.\n", expected_ret, ret);
-}
-
-START_TEST(_vsnprintf)
-{
-    char buffer[255];
-    /* Test basic functionality */
-    call_varargs(buffer, 255, 12, "%s world!", "hello");
-    /* This is how WINE implements _vcsprintf, and they are obviously wrong */
-    call_varargs(NULL, INT_MAX, -1, "%s it really work?", "does");
-    /* This one is no better */
-    call_varargs(NULL, 0, -1, "%s it really work?", "does");
-}
index d0b2c86..0e57890 100644 (file)
@@ -5,13 +5,11 @@
 #define STANDALONE
 #include "wine/test.h"
 
-extern void func__vsnprintf(void);
 extern void func_ieee(void);
 extern void func_splitpath(void);
 
 const struct test winetest_testlist[] =
 {
-    { "_vsnprintf", func__vsnprintf},
     { "ieee", func_ieee },
     { "splitpath", func_splitpath },