André Hentschel : qmgr/tests: Use a temporary path to avoid failures.
Alexandre Julliard
julliard at winehq.org
Thu Dec 23 11:28:02 CST 2010
Module: wine
Branch: master
Commit: c71998d742ff41b028ff4400b67d0f91658fb040
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c71998d742ff41b028ff4400b67d0f91658fb040
Author: André Hentschel <nerv at dawncrow.de>
Date: Wed Dec 22 23:28:44 2010 +0100
qmgr/tests: Use a temporary path to avoid failures.
---
dlls/qmgr/tests/job.c | 66 +++++++++---------------------------------------
1 files changed, 13 insertions(+), 53 deletions(-)
diff --git a/dlls/qmgr/tests/job.c b/dlls/qmgr/tests/job.c
index d0e2306..f972547 100644
--- a/dlls/qmgr/tests/job.c
+++ b/dlls/qmgr/tests/job.c
@@ -28,65 +28,26 @@
/* Globals used by many tests */
static const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0};
-static const WCHAR test_remoteNameA[] = {'r','e','m','o','t','e','A', 0};
-static const WCHAR test_remoteNameB[] = {'r','e','m','o','t','e','B', 0};
-static const WCHAR test_localNameA[] = {'l','o','c','a','l','A', 0};
-static const WCHAR test_localNameB[] = {'l','o','c','a','l','B', 0};
-static WCHAR *test_currentDir;
-static WCHAR *test_remotePathA;
-static WCHAR *test_remotePathB;
-static WCHAR *test_localPathA;
-static WCHAR *test_localPathB;
+static WCHAR test_remotePathA[MAX_PATH];
+static WCHAR test_remotePathB[MAX_PATH];
+static WCHAR test_localPathA[MAX_PATH];
+static WCHAR test_localPathB[MAX_PATH];
static IBackgroundCopyManager *test_manager;
static IBackgroundCopyJob *test_job;
static GUID test_jobId;
static BG_JOB_TYPE test_type;
-static BOOL init_paths(void)
+static VOID init_paths(void)
{
- static const WCHAR format[] = {'%','s','\\','%','s', 0};
- DWORD n;
+ WCHAR tmpDir[MAX_PATH];
+ WCHAR prefix[] = {'q', 'm', 'g', 'r', 0};
- n = GetCurrentDirectoryW(0, NULL);
- if (n == 0)
- {
- skip("Couldn't get current directory size\n");
- return FALSE;
- }
-
- test_currentDir = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
- test_localPathA
- = HeapAlloc(GetProcessHeap(), 0,
- (n + 1 + lstrlenW(test_localNameA)) * sizeof(WCHAR));
- test_localPathB
- = HeapAlloc(GetProcessHeap(), 0,
- (n + 1 + lstrlenW(test_localNameB)) * sizeof(WCHAR));
- test_remotePathA
- = HeapAlloc(GetProcessHeap(), 0,
- (n + 1 + lstrlenW(test_remoteNameA)) * sizeof(WCHAR));
- test_remotePathB
- = HeapAlloc(GetProcessHeap(), 0,
- (n + 1 + lstrlenW(test_remoteNameB)) * sizeof(WCHAR));
-
- if (!test_currentDir || !test_localPathA || !test_localPathB
- || !test_remotePathA || !test_remotePathB)
- {
- skip("Couldn't allocate memory for full paths\n");
- return FALSE;
- }
+ GetTempPathW(MAX_PATH, tmpDir);
- if (GetCurrentDirectoryW(n, test_currentDir) != n - 1)
- {
- skip("Couldn't get current directory\n");
- return FALSE;
- }
-
- wsprintfW(test_localPathA, format, test_currentDir, test_localNameA);
- wsprintfW(test_localPathB, format, test_currentDir, test_localNameB);
- wsprintfW(test_remotePathA, format, test_currentDir, test_remoteNameA);
- wsprintfW(test_remotePathB, format, test_currentDir, test_remoteNameB);
-
- return TRUE;
+ GetTempFileNameW(tmpDir, prefix, 0, test_localPathA);
+ GetTempFileNameW(tmpDir, prefix, 0, test_localPathB);
+ GetTempFileNameW(tmpDir, prefix, 0, test_remotePathA);
+ GetTempFileNameW(tmpDir, prefix, 0, test_remotePathB);
}
/* Generic test setup */
@@ -545,8 +506,7 @@ START_TEST(job)
};
const test_t *test;
- if (!init_paths())
- return;
+ init_paths();
CoInitialize(NULL);
More information about the wine-cvs
mailing list