From e0f7fbfa5911af062fe0a55ed0778d6dd0896eff Mon Sep 17 00:00:00 2001 From: Kirill Erofeev Date: Mon, 19 Feb 2018 15:33:41 +0100 Subject: [PATCH] msvcrt/tests: Add tests for _searchenv, _searchenv_s, _wsearchenv, _wsearchenv_s. Signed-off-by: Kirill Erofeev Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/tests/dir.c | 195 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c index aa273ea85e0..a29d32b9d39 100644 --- a/dlls/msvcrt/tests/dir.c +++ b/dlls/msvcrt/tests/dir.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,8 @@ 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) { @@ -41,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 @@ -416,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=0; i--) { + strcpy(path+path_len, dirs[i]); + ok(!rmdir(path), "rmdir failed (dir = %s)\n", path); + } +} + START_TEST(dir) { init(); @@ -424,4 +618,5 @@ START_TEST(dir) test_makepath(); test_makepath_s(); test_splitpath(); + test_searchenv(); }