Commit 846155f1 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

kernel32/tests: Reset current directory of current process.

parent da7c4f97
......@@ -157,6 +157,7 @@ static void test_GetSystemDirectoryW(void)
static void test_CreateDirectoryA(void)
{
char tmpdir[MAX_PATH];
WCHAR curdir[MAX_PATH];
BOOL ret;
ret = CreateDirectoryA(NULL, NULL);
......@@ -172,6 +173,7 @@ static void test_CreateDirectoryA(void)
ret = GetSystemDirectoryA(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
GetCurrentDirectoryW(MAX_PATH, curdir);
ret = SetCurrentDirectoryA(tmpdir);
ok(ret == TRUE, "could not chdir to the System directory\n");
......@@ -329,6 +331,7 @@ static void test_CreateDirectoryA(void)
ret = RemoveDirectoryA(tmpdir);
ok(ret == TRUE,
"RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
SetCurrentDirectoryW(curdir);
}
static void test_CreateDirectoryW(void)
......@@ -341,6 +344,7 @@ static void test_CreateDirectoryW(void)
static const WCHAR slashW[] = {'/',0};
static const WCHAR dotdotW[] = {'.','.',0};
static const WCHAR questionW[] = {'?',0};
WCHAR curdir[MAX_PATH];
ret = CreateDirectoryW(NULL, NULL);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
......@@ -358,6 +362,7 @@ static void test_CreateDirectoryW(void)
ret = GetSystemDirectoryW(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
GetCurrentDirectoryW(MAX_PATH, curdir);
ret = SetCurrentDirectoryW(tmpdir);
ok(ret == TRUE, "could not chdir to the System directory ret %u err %u\n", ret, GetLastError());
......@@ -413,6 +418,8 @@ static void test_CreateDirectoryW(void)
ret, GetLastError());
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
SetCurrentDirectoryW(curdir);
}
static void test_RemoveDirectoryA(void)
......
......@@ -1222,6 +1222,7 @@ static void test_CreateFileA(void)
{NULL, 0, -1, 0, FALSE}
};
BY_HANDLE_FILE_INFORMATION Finfo;
WCHAR curdir[MAX_PATH];
ret = GetTempPathA(MAX_PATH, temp_path);
ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
......@@ -1286,6 +1287,7 @@ static void test_CreateFileA(void)
ret = CreateDirectoryA(dirname, NULL);
ok( ret, "Createdirectory failed, gle=%d\n", GetLastError() );
/* set current drive & directory to known location */
GetCurrentDirectoryW( MAX_PATH, curdir);
SetCurrentDirectoryA( temp_path );
i = 0;
while (p[i].file)
......@@ -1340,7 +1342,7 @@ static void test_CreateFileA(void)
}
ret = RemoveDirectoryA(dirname);
ok(ret, "RemoveDirectoryA: error %d\n", GetLastError());
SetCurrentDirectoryW(curdir);
/* test opening directory as a directory */
hFile = CreateFileA( temp_path, GENERIC_READ,
......
......@@ -1117,6 +1117,7 @@ static void test_GetTempPath(void)
char save_TMP[MAX_PATH];
char windir[MAX_PATH];
char buf[MAX_PATH];
WCHAR curdir[MAX_PATH];
if (!GetEnvironmentVariableA("TMP", save_TMP, sizeof(save_TMP))) save_TMP[0] = 0;
......@@ -1149,6 +1150,7 @@ static void test_GetTempPath(void)
test_GetTempPathA(windir);
test_GetTempPathW(windir);
GetCurrentDirectoryW(MAX_PATH, curdir);
/* TMP=C: i.e. use current working directory of the specified drive */
GetWindowsDirectoryA(windir, sizeof(windir));
SetCurrentDirectoryA(windir);
......@@ -1162,6 +1164,7 @@ static void test_GetTempPath(void)
test_GetTempPathW(windir);
SetEnvironmentVariableA("TMP", save_TMP);
SetCurrentDirectoryW(curdir);
}
static void test_GetLongPathNameA(void)
......@@ -2116,9 +2119,11 @@ static void test_relative_path(void)
char path[MAX_PATH], buf[MAX_PATH];
HANDLE file;
int ret;
WCHAR curdir[MAX_PATH];
if (!pGetLongPathNameA) return;
GetCurrentDirectoryW(MAX_PATH, curdir);
GetTempPathA(MAX_PATH, path);
ret = SetCurrentDirectoryA(path);
ok(ret, "SetCurrentDirectory error %d\n", GetLastError());
......@@ -2176,6 +2181,7 @@ static void test_relative_path(void)
DeleteFileA("foo\\file");
RemoveDirectoryA("foo");
RemoveDirectoryA("bar");
SetCurrentDirectoryW(curdir);
}
static void test_CheckNameLegalDOS8Dot3(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment