Module: wine Branch: master Commit: 9eb0c8720459fa73da61600d4ed45e39f9aeff57 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9eb0c8720459fa73da61600d4e...
Author: Kirill K. Smirnov lich@math.spbu.ru Date: Wed Apr 25 11:41:11 2007 +0400
kernel32/tests: Add tests for NeedCurrentDirectoryForExePath.
---
dlls/kernel32/tests/path.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 33fcf6f..47ec23f 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -53,6 +53,10 @@ static const CHAR is_char_ok[] ="11111110111111111011"; static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR,LPSTR,DWORD); static DWORD (WINAPI *pGetLongPathNameW)(LPWSTR,LPWSTR,DWORD);
+/* Present in Win2003+ */ +static BOOL (WINAPI *pNeedCurrentDirectoryForExePathA)(LPCSTR); +static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR); + /* a structure to deal with wine todos somewhat cleanly */ typedef struct { DWORD shortlen; @@ -1074,6 +1078,44 @@ static void test_GetWindowsDirectory(void) res, GetLastError(), buffer, total); }
+static void test_NeedCurrentDirectoryForExePathA(void) +{ + /* Crashes in Windows */ + if (0) + ok(pNeedCurrentDirectoryForExePathA(NULL), "returned FALSE for NULL\n"); + + SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL); + ok(pNeedCurrentDirectoryForExePathA("."), "returned FALSE for "."\n"); + ok(pNeedCurrentDirectoryForExePathA("c:\"), "returned FALSE for "c:\"\n"); + ok(pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned FALSE for "cmd.exe"\n"); + + SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya"); + ok(!pNeedCurrentDirectoryForExePathA("."), "returned TRUE for "."\n"); + ok(pNeedCurrentDirectoryForExePathA("c:\"), "returned FALSE for "c:\"\n"); + ok(!pNeedCurrentDirectoryForExePathA("cmd.exe"), "returned TRUE for "cmd.exe"\n"); +} + +static void test_NeedCurrentDirectoryForExePathW(void) +{ + const WCHAR thispath[] = {'.', 0}; + const WCHAR fullpath[] = {'c', ':', '\', 0}; + const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0}; + + /* Crashes in Windows */ + if (0) + ok(pNeedCurrentDirectoryForExePathW(NULL), "returned FALSE for NULL\n"); + + SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", NULL); + ok(pNeedCurrentDirectoryForExePathW(thispath), "returned FALSE for "."\n"); + ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for "c:\"\n"); + ok(pNeedCurrentDirectoryForExePathW(cmdname), "returned FALSE for "cmd.exe"\n"); + + SetEnvironmentVariableA("NoDefaultCurrentDirectoryInExePath", "nya"); + ok(!pNeedCurrentDirectoryForExePathW(thispath), "returned TRUE for "."\n"); + ok(pNeedCurrentDirectoryForExePathW(fullpath), "returned FALSE for "c:\"\n"); + ok(!pNeedCurrentDirectoryForExePathW(cmdname), "returned TRUE for "cmd.exe"\n"); +} + START_TEST(path) { CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive; @@ -1081,6 +1123,13 @@ START_TEST(path) "GetLongPathNameA" ); pGetLongPathNameW = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll") , "GetLongPathNameW" ); + pNeedCurrentDirectoryForExePathA = + (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"), + "NeedCurrentDirectoryForExePathA" ); + pNeedCurrentDirectoryForExePathW = + (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"), + "NeedCurrentDirectoryForExePathW" ); + test_InitPathA(curdir, &curDrive, &otherDrive); test_CurrentDirectoryA(origdir,curdir); test_PathNameA(curdir, curDrive, otherDrive); @@ -1089,4 +1138,12 @@ START_TEST(path) test_GetLongPathNameW(); test_GetSystemDirectory(); test_GetWindowsDirectory(); + if (pNeedCurrentDirectoryForExePathA) + { + test_NeedCurrentDirectoryForExePathA(); + } + if (pNeedCurrentDirectoryForExePathW) + { + test_NeedCurrentDirectoryForExePathW(); + } }