36 static int (
__cdecl *p_makepath_s)(
char *,
size_t,
const char *,
const char *,
const char *,
const char *);
37 static int (
__cdecl *p_wmakepath_s)(
wchar_t *,
size_t,
const wchar_t *,
const wchar_t *,
const wchar_t *,
const wchar_t *);
38 static int (
__cdecl *p_searchenv_s)(
const char*,
const char*,
char*,
size_t);
39 static int (
__cdecl *p_wsearchenv_s)(
const wchar_t*,
const wchar_t*,
wchar_t*,
size_t);
61 #define USE_BUFF ((char*)~0ul) 81 {
"foo",
NULL,
USE_BUFF,
"file",
"ext",
"foo\\file.ext" },
84 {
NULL,
"c",
"dir",
"file",
"ext",
"c:dir\\file.ext" },
85 {
NULL,
"c:",
"dir",
"file",
"ext",
"c:dir\\file.ext" },
86 {
NULL,
"c:\\",
"dir",
"file",
"ext",
"c:dir\\file.ext" }
141 static const WCHAR expected0[] = {
'\0',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
142 static const WCHAR expected1[] = {
'\0',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
143 static const WCHAR expected2[] = {
'\0',
':',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
144 static const WCHAR expected3[] = {
'\0',
':',
'd',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
145 static const WCHAR expected4[] = {
'\0',
':',
'd',
'\\',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
146 static const WCHAR expected5[] = {
'\0',
':',
'd',
'\\',
'f',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
147 static const WCHAR expected6[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
148 static const WCHAR expected7[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'l',
'X',
'X',
'X',
'X',
'X',
'X'};
149 static const WCHAR expected8[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'l',
'e',
'X',
'X',
'X',
'X',
'X'};
150 static const WCHAR expected9[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'l',
'e',
'.',
'X',
'X',
'X',
'X'};
151 static const WCHAR expected10[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'l',
'e',
'.',
'e',
'X',
'X',
'X'};
152 static const WCHAR expected11[] = {
'\0',
':',
'd',
'\\',
'f',
'i',
'l',
'e',
'.',
'e',
'x',
'X',
'X'};
165 static const WCHAR expected22[] = {
'\0',
'o',
'o',
'\0',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X',
'X'};
166 static const WCHAR expected23[] = {
'\0',
'o',
'o',
'\\',
'f',
'i',
'l',
'X',
'X',
'X',
'X',
'X',
'X'};
167 static const WCHAR expected24[] = {
'\0',
'o',
'o',
'\\',
'f',
'i',
'l',
'e',
'.',
'e',
'x',
'X',
'X'};
187 {
NULL, 1,
"c:",
"d\\",
"file",
"ext",
"\0XXXXXXXXXXXX",
expected0, 13},
188 {
NULL, 2,
"c:",
"d\\",
"file",
"ext",
"\0XXXXXXXXXXXX",
expected1, 13},
189 {
NULL, 3,
"c:",
"d\\",
"file",
"ext",
"\0:XXXXXXXXXXX",
expected2, 13},
190 {
NULL, 4,
"c:",
"d\\",
"file",
"ext",
"\0:dXXXXXXXXXX",
expected3, 13},
191 {
NULL, 5,
"c:",
"d\\",
"file",
"ext",
"\0:d\\XXXXXXXXX",
expected4, 13},
192 {
NULL, 6,
"c:",
"d\\",
"file",
"ext",
"\0:d\\fXXXXXXXX",
expected5, 13},
193 {
NULL, 7,
"c:",
"d\\",
"file",
"ext",
"\0:d\\fiXXXXXXX",
expected6, 13},
194 {
NULL, 8,
"c:",
"d\\",
"file",
"ext",
"\0:d\\filXXXXXX",
expected7, 13},
195 {
NULL, 9,
"c:",
"d\\",
"file",
"ext",
"\0:d\\fileXXXXX",
expected8, 13},
196 {
NULL, 10,
"c:",
"d\\",
"file",
"ext",
"\0:d\\file.XXXX",
expected9, 13},
197 {
NULL, 11,
"c:",
"d\\",
"file",
"ext",
"\0:d\\file.eXXX",
expected10, 13},
198 {
NULL, 12,
"c:",
"d\\",
"file",
"ext",
"\0:d\\file.exXX",
expected11, 13},
200 {
NULL, 3,
"c:",
"dir",
"f",
"ext",
"\0:XXXXXXXX",
expected12, 10},
201 {
NULL, 4,
"c:",
"dir",
"f",
"ext",
"\0:dXXXXXXX",
expected13, 10},
202 {
NULL, 5,
"c:",
"dir",
"f",
"ext",
"\0:diXXXXXX",
expected14, 10},
203 {
NULL, 6,
"c:",
"dir",
"f",
"ext",
"\0:dirXXXXX",
expected15, 10},
204 {
NULL, 7,
"c:",
"dir",
"f",
"ext",
"\0:dir\\XXXX",
expected16, 10},
229 if (!p_makepath_s || !p_wmakepath_s)
231 win_skip(
"Safe makepath functions are not available\n");
237 ok(
ret ==
EINVAL,
"Expected _makepath_s to return EINVAL, got %d\n",
ret);
242 ok(
ret ==
EINVAL,
"Expected _makepath_s to return EINVAL, got %d\n",
ret);
247 ok(
ret ==
EINVAL,
"Expected _wmakepath_s to return EINVAL, got %d\n",
ret);
252 ok(
ret ==
EINVAL,
"Expected _wmakepath_s to return EINVAL, got %d\n",
ret);
270 ok(
ret == 0,
"[%d] Expected _makepath_s to return 0, got %d\n",
i,
ret);
291 ok(
ret == 0,
"[%d] Expected _wmakepath_s to return 0, got %d\n",
i,
ret);
314 ok(
ret ==
ERANGE,
"[%d] Expected _makepath_s to return ERANGE, got %d\n",
i,
ret);
316 ok(!
memcmp(
p->expected,
buffer,
p->expected_length),
"unexpected output for case %d\n",
i);
330 ret = p_wmakepath_s(bufferW,
p->length,
335 ok(
ret ==
ERANGE,
"[%d] Expected _wmakepath_s to return ERANGE, got %d\n",
i,
ret);
338 ok(!
memcmp(
p->expected_unicode, bufferW,
p->expected_length *
sizeof(
WCHAR)),
"unexpected output for case %d\n",
i);
357 strcat(level1,
"msvcrt-test\\");
364 strcat(level2,
"nextlevel\\");
371 strcpy(teststring,level2);
372 strcat(teststring,
"test");
373 ok(
strcmp(full,teststring)==0,
"Invalid Path returned %s\n",full);
375 memcpy(teststring,level2,3);
377 strcat(teststring,
"test");
378 ok(
strcmp(full,teststring)==0,
"Invalid Path returned %s\n",full);
380 strcpy(teststring,level1);
381 strcat(teststring,
"test");
382 ok(
strcmp(full,teststring)==0,
"Invalid Path returned %s\n",full);
383 ok(
_fullpath(full,
"..\\test", 10)==
NULL,
"_fullpath failed to generate error\n");
386 ok(freeme!=
NULL,
"No path returned\n");
387 strcpy(teststring,level2);
388 strcat(teststring,
"test");
389 ok(
strcmp(freeme,teststring)==0,
"Invalid Path returned %s\n",freeme);
401 const char*
path =
"c:\\\x83\x5c\x83\x74\x83\x67.bin";
410 ok(!
strcmp(fname,
"\x83\x74\x83\x67"),
"got %s\n", fname);
418 ok(!
strcmp(fname,
"\x83\x5c\x83\x74\x83\x67"),
"got %s\n", fname);
426 const char *dirs[] = {
428 "\\search_env_test\\dir1",
429 "\\search_env_test\\dir2",
430 "\\search_env_test\\dir3longer" 433 const char *files[] = {
434 "\\search_env_test\\dir1\\1.dat",
435 "\\search_env_test\\dir1\\2.dat",
436 "\\search_env_test\\dir2\\1.dat",
437 "\\search_env_test\\dir2\\3.dat",
438 "\\search_env_test\\dir3longer\\3.dat" 441 const WCHAR env_w[] = {
'T',
'E',
'S',
'T',
'_',
'P',
'A',
'T',
'H',0};
442 const WCHAR dat1_w[] = {
'1',
'.',
'd',
'a',
't',0};
443 const WCHAR dat3_w[] = {
'3',
'.',
'd',
'a',
't',0};
451 if (
getenv(
"TEST_PATH")) {
452 skip(
"TEST_PATH environment variable already set\n");
468 ok(tmp_file !=
NULL,
"fopen failed (file = %s)\n",
path);
472 strcpy(env1,
"TEST_PATH=");
473 strcpy(env2,
"TEST_PATH=;");
484 if (!p_searchenv_s || !p_wsearchenv_s)
485 win_skip(
"searchenv_s or wsearchenv_s function is not available\n");
495 ok(
i ==
ENOENT,
"searchenv_s returned %d\n",
i);
508 ok(!
i,
"searchenv_s returned %d\n",
i);
512 memset(result_w,
'x',
sizeof(result_w));
517 if (p_wsearchenv_s) {
518 memset(result_w,
'x',
sizeof(result_w));
519 i = p_wsearchenv_s(dat1_w, env_w, result_w,
MAX_PATH);
520 ok(!
i,
"wsearchenv_s returned %d\n",
i);
533 ok(!
i,
"searchenv_s returned %d\n",
i);
537 memset(result_w,
'x',
sizeof(result_w));
542 if (p_wsearchenv_s) {
543 memset(result_w,
'x',
sizeof(result_w));
544 i = p_wsearchenv_s(dat3_w, env_w, result_w,
MAX_PATH);
545 ok(!
i,
"wsearchenv_s returned %d\n",
i);
559 ok(!
i,
"searchenv_s returned %d\n",
i);
563 memset(result_w,
'x',
sizeof(result_w));
568 if (p_wsearchenv_s) {
569 memset(result_w,
'x',
sizeof(result_w));
570 i = p_wsearchenv_s(dat1_w, env_w, result_w,
MAX_PATH);
571 ok(!
i,
"wsearchenv_s returned %d\n",
i);
584 ok(!
i,
"searchenv_s returned %d\n",
i);
588 memset(result_w,
'x',
sizeof(result_w));
593 if (p_wsearchenv_s) {
594 memset(result_w,
'x',
sizeof(result_w));
595 i = p_wsearchenv_s(dat3_w, env_w, result_w,
MAX_PATH);
596 ok(!
i,
"wsearchenv_s returned %d\n",
i);
static const WCHAR expected13[]
static const WCHAR expected15[]
_CRTIMP void __cdecl _wmakepath(_Pre_notnull_ _Post_z_ wchar_t *_ResultPath, _In_opt_z_ const wchar_t *_Drive, _In_opt_z_ const wchar_t *_Dir, _In_opt_z_ const wchar_t *_Filename, _In_opt_z_ const wchar_t *_Ext)
static const WCHAR expected21[]
_Check_return_ _CRTIMP int __cdecl putenv(_In_z_ const char *_EnvString)
_Check_return_ _CRTIMP char *__cdecl _fullpath(_Out_writes_opt_z_(_SizeInBytes) char *_FullPath, _In_z_ const char *_Path, _In_ size_t _SizeInBytes)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define WideCharToMultiByte
char * strcat(char *DstString, const char *SrcString)
static const WCHAR expected12[]
_CRTIMP void __cdecl _makepath(_Pre_notnull_ _Post_z_ char *_Path, _In_opt_z_ const char *_Drive, _In_opt_z_ const char *_Dir, _In_opt_z_ const char *_Filename, _In_opt_z_ const char *_Ext)
static const WCHAR expected25[]
const WCHAR * expected_unicode
static const makepath_case makepath_cases[]
static const WCHAR expected22[]
static void test_searchenv(void)
DWORD WINAPI GetLastError(VOID)
_CRTIMP void __cdecl _splitpath(_In_z_ const char *_FullPath, _Pre_maybenull_ _Post_z_ char *_Drive, _Pre_maybenull_ _Post_z_ char *_Dir, _Pre_maybenull_ _Post_z_ char *_Filename, _Pre_maybenull_ _Post_z_ char *_Ext)
static const WCHAR expected2[]
_CRTIMP int __cdecl _getmbcp(void)
static const WCHAR expected18[]
static void test_splitpath(void)
static void test_makepath_s(void)
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
static const WCHAR expected4[]
static const WCHAR expected11[]
static const WCHAR expected16[]
static void test_makepath(void)
_CRTIMP void __cdecl _wsearchenv(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_EnvVar, _Pre_notnull_ _Post_z_ wchar_t *_ResultPath)
static const WCHAR expected8[]
static const WCHAR expected1[]
int __cdecl _setmbcp(int)
static const WCHAR expected9[]
static const WCHAR expected23[]
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
#define memcpy(s1, s2, n)
static const WCHAR expected7[]
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static const WCHAR expected3[]
static const WCHAR expected6[]
static PEXPLICIT_ACCESSW *static HMODULE hmod
static const WCHAR expected17[]
static const WCHAR expected19[]
static const WCHAR expected5[]
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static const WCHAR expected20[]
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
static void test_fullpath(void)
static int(__cdecl *p_makepath_s)(char *
_CRTIMP void __cdecl _searchenv(_In_z_ const char *_Filename, _In_z_ const char *_EnvVar, _Pre_notnull_ _Post_z_ char *_ResultPath)
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
#define MultiByteToWideChar
static const WCHAR expected14[]
char * strcpy(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
static const makepath_s_case makepath_s_cases[]
#define GetProcAddress(x, y)
static const WCHAR expected24[]
#define ERROR_ALREADY_EXISTS
static const WCHAR fileW[]
static const WCHAR expected26[]
static const WCHAR expected0[]
static const WCHAR expected10[]