https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1c9ac7a2d214e247004ace...
commit 1c9ac7a2d214e247004ace694fc9922bd6d2a7d0 Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Tue Apr 3 13:42:04 2018 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Tue Apr 3 13:42:04 2018 +0100
[MSVCRT_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/msvcrt/cpp.c | 5 +- modules/rostests/winetests/msvcrt/data.c | 14 +- modules/rostests/winetests/msvcrt/dir.c | 209 +++++++++++++++++++++++++++- modules/rostests/winetests/msvcrt/environ.c | 3 +- modules/rostests/winetests/msvcrt/file.c | 15 +- modules/rostests/winetests/msvcrt/headers.c | 34 ++++- modules/rostests/winetests/msvcrt/heap.c | 5 +- modules/rostests/winetests/msvcrt/locale.c | 5 +- modules/rostests/winetests/msvcrt/misc.c | 15 +- modules/rostests/winetests/msvcrt/precomp.h | 2 + modules/rostests/winetests/msvcrt/printf.c | 11 +- modules/rostests/winetests/msvcrt/scanf.c | 4 +- modules/rostests/winetests/msvcrt/signal.c | 4 +- modules/rostests/winetests/msvcrt/string.c | 14 +- modules/rostests/winetests/msvcrt/time.c | 12 +- 15 files changed, 326 insertions(+), 26 deletions(-)
diff --git a/modules/rostests/winetests/msvcrt/cpp.c b/modules/rostests/winetests/msvcrt/cpp.c index 22f59124e3..cf5e4c7d60 100644 --- a/modules/rostests/winetests/msvcrt/cpp.c +++ b/modules/rostests/winetests/msvcrt/cpp.c @@ -16,8 +16,9 @@ * 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 "precomp.h" +#include "wine/test.h" +#include "winbase.h" +#include "winnt.h"
typedef void (*vtable_ptr)(void);
diff --git a/modules/rostests/winetests/msvcrt/data.c b/modules/rostests/winetests/msvcrt/data.c index 724eb67c9b..9aacac7b50 100644 --- a/modules/rostests/winetests/msvcrt/data.c +++ b/modules/rostests/winetests/msvcrt/data.c @@ -18,8 +18,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.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> #include <direct.h>
void __cdecl __getmainargs(int *, char ***, char ***, int, int *); diff --git a/modules/rostests/winetests/msvcrt/dir.c b/modules/rostests/winetests/msvcrt/dir.c index ad96ae70b9..a29d32b9d3 100644 --- a/modules/rostests/winetests/msvcrt/dir.c +++ b/modules/rostests/winetests/msvcrt/dir.c @@ -18,12 +18,25 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - +#include "wine/test.h" +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <direct.h> +#include <sys/stat.h> +#include <io.h> #include <mbctype.h> +#include <windef.h> +#include <winbase.h> +#include <winnls.h> +#include <process.h> +#include <errno.h>
static int (__cdecl *p_makepath_s)(char *, size_t, const char *, const char *, const char *, const char *); static int (__cdecl *p_wmakepath_s)(wchar_t *, size_t, const wchar_t *,const wchar_t *, const wchar_t *, const wchar_t *); +static int (__cdecl *p_searchenv_s)(const char*, const char*, char*, size_t); +static int (__cdecl *p_wsearchenv_s)(const wchar_t*, const wchar_t*, wchar_t*, size_t);
static void init(void) { @@ -31,6 +44,8 @@ static void init(void)
p_makepath_s = (void *)GetProcAddress(hmod, "_makepath_s"); p_wmakepath_s = (void *)GetProcAddress(hmod, "_wmakepath_s"); + p_searchenv_s = (void *)GetProcAddress(hmod, "_searchenv_s"); + p_wsearchenv_s = (void *)GetProcAddress(hmod, "_wsearchenv_s"); }
typedef struct @@ -406,6 +421,195 @@ static void test_splitpath(void) _setmbcp(prev_cp); }
+static void test_searchenv(void) +{ + const char *dirs[] = { + "\search_env_test", + "\search_env_test\dir1", + "\search_env_test\dir2", + "\search_env_test\dir3longer" + }; + + const char *files[] = { + "\search_env_test\dir1\1.dat", + "\search_env_test\dir1\2.dat", + "\search_env_test\dir2\1.dat", + "\search_env_test\dir2\3.dat", + "\search_env_test\dir3longer\3.dat" + }; + + const WCHAR env_w[] = {'T','E','S','T','_','P','A','T','H',0}; + const WCHAR dat1_w[] = {'1','.','d','a','t',0}; + const WCHAR dat3_w[] = {'3','.','d','a','t',0}; + + char env1[4*MAX_PATH], env2[4*MAX_PATH], tmppath[MAX_PATH], path[2*MAX_PATH]; + char result[MAX_PATH], exp[2*MAX_PATH]; + WCHAR result_w[MAX_PATH]; + int i, path_len; + FILE *tmp_file; + + if (getenv("TEST_PATH")) { + skip("TEST_PATH environment variable already set\n"); + return; + } + + path_len = GetTempPathA(MAX_PATH, tmppath); + ok(path_len, "GetTempPath failed\n"); + memcpy(path, tmppath, path_len); + + for(i=0; i<sizeof(dirs)/sizeof(*dirs); i++) { + strcpy(path+path_len, dirs[i]); + ok(!mkdir(path), "mkdir failed (dir = %s)\n", path); + } + + for(i=0; i<sizeof(files)/sizeof(*files); i++) { + strcpy(path+path_len, files[i]); + tmp_file = fopen(path, "wb"); + ok(tmp_file != NULL, "fopen failed (file = %s)\n", path); + fclose(tmp_file); + } + + strcpy(env1, "TEST_PATH="); + strcpy(env2, "TEST_PATH=;"); + for(i=1; i<sizeof(dirs)/sizeof(*dirs); i++) { + strcat(env1, tmppath); + strcat(env1, dirs[i]); + strcat(env1, ";"); + + strcat(env2, tmppath); + strcat(env2, dirs[i]); + strcat(env2, ";;"); + } + + if (!p_searchenv_s || !p_wsearchenv_s) + win_skip("searchenv_s or wsearchenv_s function is not available\n"); + + putenv(env1); + memset(result, 'x', sizeof(result)); + _searchenv("fail", "TEST_PATH", result); + ok(!result[0], "got %s, expected ''\n", result); + + if (p_searchenv_s) { + memset(result, 'x', sizeof(result)); + i = p_searchenv_s("fail", "TEST_PATH", result, MAX_PATH); + ok(i == ENOENT, "searchenv_s returned %d\n", i); + ok(!result[0], "got %s, expected ''\n", result); + } + + memset(result, 'x', sizeof(result)); + strcpy(exp, tmppath); + strcat(exp, files[0]); + _searchenv("1.dat", "TEST_PATH", result); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_searchenv_s) { + memset(result, 'x', sizeof(result)); + i = p_searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH); + ok(!i, "searchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result_w, 'x', sizeof(result_w)); + _wsearchenv(dat1_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_wsearchenv_s) { + memset(result_w, 'x', sizeof(result_w)); + i = p_wsearchenv_s(dat1_w, env_w, result_w, MAX_PATH); + ok(!i, "wsearchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result, 'x', sizeof(result)); + strcpy(exp, tmppath); + strcat(exp, files[3]); + _searchenv("3.dat", "TEST_PATH", result); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_searchenv_s) { + memset(result, 'x', sizeof(result)); + i = p_searchenv_s("3.dat", "TEST_PATH", result, MAX_PATH); + ok(!i, "searchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result_w, 'x', sizeof(result_w)); + _wsearchenv(dat3_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_wsearchenv_s) { + memset(result_w, 'x', sizeof(result_w)); + i = p_wsearchenv_s(dat3_w, env_w, result_w, MAX_PATH); + ok(!i, "wsearchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + putenv(env2); + memset(result, 'x', sizeof(result)); + strcpy(exp, tmppath); + strcat(exp, files[0]); + _searchenv("1.dat", "TEST_PATH", result); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_searchenv_s) { + memset(result, 'x', sizeof(result)); + i = p_searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH); + ok(!i, "searchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result_w, 'x', sizeof(result_w)); + _wsearchenv(dat1_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_wsearchenv_s) { + memset(result_w, 'x', sizeof(result_w)); + i = p_wsearchenv_s(dat1_w, env_w, result_w, MAX_PATH); + ok(!i, "wsearchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result, 'x', sizeof(result)); + strcpy(exp, tmppath); + strcat(exp, files[3]); + _searchenv("3.dat", "TEST_PATH", result); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_searchenv_s) { + memset(result, 'x', sizeof(result)); + i = p_searchenv_s("3.dat", "TEST_PATH", result, MAX_PATH); + ok(!i, "searchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + memset(result_w, 'x', sizeof(result_w)); + _wsearchenv(dat3_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + if (p_wsearchenv_s) { + memset(result_w, 'x', sizeof(result_w)); + i = p_wsearchenv_s(dat3_w, env_w, result_w, MAX_PATH); + ok(!i, "wsearchenv_s returned %d\n", i); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + } + + putenv("TEST_PATH="); + + for(i=sizeof(files)/sizeof(*files)-1; i>=0; i--) { + strcpy(path+path_len, files[i]); + ok(!remove(path), "remove failed (file = %s)\n", path); + } + + for(i=sizeof(dirs)/sizeof(*dirs)-1; i>=0; i--) { + strcpy(path+path_len, dirs[i]); + ok(!rmdir(path), "rmdir failed (dir = %s)\n", path); + } +} + START_TEST(dir) { init(); @@ -414,4 +618,5 @@ START_TEST(dir) test_makepath(); test_makepath_s(); test_splitpath(); + test_searchenv(); } diff --git a/modules/rostests/winetests/msvcrt/environ.c b/modules/rostests/winetests/msvcrt/environ.c index d74922fbba..fdfe81f5ee 100644 --- a/modules/rostests/winetests/msvcrt/environ.c +++ b/modules/rostests/winetests/msvcrt/environ.c @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" +#include "wine/test.h" +#include <stdlib.h>
static const char *a_very_long_env_string = "LIBRARY_PATH=" diff --git a/modules/rostests/winetests/msvcrt/file.c b/modules/rostests/winetests/msvcrt/file.c index d27e0d49f7..136ee1563e 100644 --- a/modules/rostests/winetests/msvcrt/file.c +++ b/modules/rostests/winetests/msvcrt/file.c @@ -19,13 +19,22 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - -#include <winreg.h> +#include "wine/test.h" +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> #include <fcntl.h> #include <share.h> #include <sys/stat.h> #include <io.h> +#include <direct.h> +#include <windef.h> +#include <winbase.h> +#include <winnls.h> +#include <winreg.h> +#include <process.h> +#include <errno.h> +#include <locale.h>
#define MSVCRT_FD_BLOCK_SIZE 32 typedef struct { diff --git a/modules/rostests/winetests/msvcrt/headers.c b/modules/rostests/winetests/msvcrt/headers.c index 6a5660f7d8..52d739e107 100644 --- a/modules/rostests/winetests/msvcrt/headers.c +++ b/modules/rostests/winetests/msvcrt/headers.c @@ -20,7 +20,39 @@ * symbols defined in msvcrt.h (prefixed by MSVCRT_). */
-#include "precomp.h" +#include "dos.h" +#include "math.h" +#include "stdlib.h" +#include "io.h" +#include "errno.h" +#include "fcntl.h" +#include "malloc.h" +#include "limits.h" +#include "mbctype.h" +#include "stdio.h" +#include "wchar.h" +#include "ctype.h" +#include "crtdbg.h" +#include "share.h" +#include "search.h" +#include "wctype.h" +#include "float.h" +#include "stddef.h" +#include "mbstring.h" +#include "sys/locking.h" +#include "sys/utime.h" +#include "sys/types.h" +#include "sys/stat.h" +#include "sys/timeb.h" +#include "direct.h" +#include "conio.h" +#include "process.h" +#include "string.h" +#include "signal.h" +#include "time.h" +#include "locale.h" +#include "setjmp.h" +#include "wine/test.h"
#ifdef __WINE_USE_MSVCRT /* Wine-specific msvcrt headers */ diff --git a/modules/rostests/winetests/msvcrt/heap.c b/modules/rostests/winetests/msvcrt/heap.c index e7fa3ecf13..4a3c7a8170 100644 --- a/modules/rostests/winetests/msvcrt/heap.c +++ b/modules/rostests/winetests/msvcrt/heap.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - +#include <stdlib.h> #include <malloc.h> +#include <errno.h> +#include "wine/test.h"
static void (__cdecl *p_aligned_free)(void*) = NULL; static void * (__cdecl *p_aligned_malloc)(size_t,size_t) = NULL; diff --git a/modules/rostests/winetests/msvcrt/locale.c b/modules/rostests/winetests/msvcrt/locale.c index 195b7738ae..f87a7914d0 100644 --- a/modules/rostests/winetests/msvcrt/locale.c +++ b/modules/rostests/winetests/msvcrt/locale.c @@ -18,7 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" +#include <locale.h> + +#include "wine/test.h" +#include "winnls.h"
static BOOL (__cdecl *p__crtGetStringTypeW)(DWORD, DWORD, const wchar_t*, int, WORD*); static int (__cdecl *pmemcpy_s)(void *, size_t, void*, size_t); diff --git a/modules/rostests/winetests/msvcrt/misc.c b/modules/rostests/winetests/msvcrt/misc.c index d64cfe86cc..20253342d9 100644 --- a/modules/rostests/winetests/msvcrt/misc.c +++ b/modules/rostests/winetests/msvcrt/misc.c @@ -18,15 +18,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - -#include <msvcrt.h> +#include "wine/test.h" +#include <errno.h> +#include <stdio.h> +#include <math.h> +#include "msvcrt.h" +#include <process.h>
static inline float __port_infinity(void) { static const unsigned __inf_bytes = 0x7f800000; return *(const float *)&__inf_bytes; } +#ifdef __REACTOS__ +#undef INFINITY +#endif #define INFINITY __port_infinity()
static inline float __port_nan(void) @@ -34,6 +40,9 @@ static inline float __port_nan(void) static const unsigned __nan_bytes = 0x7fc00000; return *(const float *)&__nan_bytes; } +#ifdef __REACTOS__ +#undef NAN +#endif #define NAN __port_nan()
static inline BOOL almost_equal(double d1, double d2) { diff --git a/modules/rostests/winetests/msvcrt/precomp.h b/modules/rostests/winetests/msvcrt/precomp.h index 6cc0b62bc3..63a519d703 100644 --- a/modules/rostests/winetests/msvcrt/precomp.h +++ b/modules/rostests/winetests/msvcrt/precomp.h @@ -1,9 +1,11 @@ + #ifndef _MSVCRT_WINETEST_PRECOMP_H_ #define _MSVCRT_WINETEST_PRECOMP_H_
#define WIN32_NO_STATUS #define _INC_WINDOWS #define COM_NO_WINDOWS_H + #define _CRT_NON_CONFORMING_SWPRINTFS
#include <wine/test.h> diff --git a/modules/rostests/winetests/msvcrt/printf.c b/modules/rostests/winetests/msvcrt/printf.c index 43b2ec3dda..64658ce25f 100644 --- a/modules/rostests/winetests/msvcrt/printf.c +++ b/modules/rostests/winetests/msvcrt/printf.c @@ -23,8 +23,17 @@ /* With Visual Studio >= 2005, swprintf() takes an extra parameter unless * the following macro is defined. */ +#define _CRT_NON_CONFORMING_SWPRINTFS + +#include <stdio.h> +#include <errno.h> +#include <locale.h>
-#include "precomp.h" +#include "windef.h" +#include "winbase.h" +#include "winnls.h" + +#include "wine/test.h"
static inline float __port_infinity(void) { diff --git a/modules/rostests/winetests/msvcrt/scanf.c b/modules/rostests/winetests/msvcrt/scanf.c index d25bee6a00..359b07937a 100644 --- a/modules/rostests/winetests/msvcrt/scanf.c +++ b/modules/rostests/winetests/msvcrt/scanf.c @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" +#include <stdio.h> + +#include "wine/test.h"
static void test_sscanf( void ) { diff --git a/modules/rostests/winetests/msvcrt/signal.c b/modules/rostests/winetests/msvcrt/signal.c index 5947889841..ad6ea6ecf9 100644 --- a/modules/rostests/winetests/msvcrt/signal.c +++ b/modules/rostests/winetests/msvcrt/signal.c @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - +#include "wine/test.h" +#include <winbase.h> #include <signal.h>
static int test_value = 0; diff --git a/modules/rostests/winetests/msvcrt/string.c b/modules/rostests/winetests/msvcrt/string.c index 4fc34ebfc4..b270366599 100644 --- a/modules/rostests/winetests/msvcrt/string.c +++ b/modules/rostests/winetests/msvcrt/string.c @@ -18,13 +18,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - +#include "wine/test.h" +#include <string.h> #include <mbstring.h> #include <wchar.h> +#include <stdlib.h> +#include <stdio.h> #include <mbctype.h> +#include <locale.h> +#include <errno.h> +#include <limits.h> #include <math.h>
+/* make it use a definition from string.h */ +#undef strncpy +#include "winbase.h" +#include "winnls.h" + static char *buf_to_string(const unsigned char *bin, int len, int nr) { static char buf[2][1024]; diff --git a/modules/rostests/winetests/msvcrt/time.c b/modules/rostests/winetests/msvcrt/time.c index 176ead348e..a5a2df18bb 100644 --- a/modules/rostests/winetests/msvcrt/time.c +++ b/modules/rostests/winetests/msvcrt/time.c @@ -18,9 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "precomp.h" - -#include <time.h> +#include "wine/test.h" +#include "winbase.h" +#include "winnls.h" +#include "time.h" + +#include <stdlib.h> /*setenv*/ +#include <stdio.h> /*printf*/ +#include <locale.h> +#include <errno.h>
#define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)