winmm: Fix a failing mixer test on 98 and ME.
[wine] / dlls / advpack / tests / files.c
1 /*
2  * Unit tests for advpack.dll file functions
3  *
4  * Copyright (C) 2006 James Hawkins
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdio.h>
22 #include <windows.h>
23 #include <advpub.h>
24 #include <fci.h>
25 #include "wine/test.h"
26
27 /* make the max size large so there is only one cab file */
28 #define MEDIA_SIZE          999999999
29 #define FOLDER_THRESHOLD    900000
30
31 /* function pointers */
32 HMODULE hAdvPack;
33 static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
34 static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
35 static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
36
37 CHAR CURR_DIR[MAX_PATH];
38
39 static void init_function_pointers(void)
40 {
41     hAdvPack = LoadLibraryA("advpack.dll");
42
43     if (hAdvPack)
44     {
45         pAddDelBackupEntry = (void *)GetProcAddress(hAdvPack, "AddDelBackupEntry");
46         pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
47         pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
48     }
49 }
50
51 /* creates a file with the specified name for tests */
52 static void createTestFile(const CHAR *name)
53 {
54     HANDLE file;
55     DWORD written;
56
57     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
58     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
59     WriteFile(file, name, strlen(name), &written, NULL);
60     WriteFile(file, "\n", strlen("\n"), &written, NULL);
61     CloseHandle(file);
62 }
63
64 static void create_test_files(void)
65 {
66     createTestFile("a.txt");
67     createTestFile("b.txt");
68     CreateDirectoryA("testdir", NULL);
69     createTestFile("testdir\\c.txt");
70     createTestFile("testdir\\d.txt");
71     CreateDirectoryA("dest", NULL);
72 }
73
74 static void delete_test_files(void)
75 {
76     DeleteFileA("a.txt");
77     DeleteFileA("b.txt");
78     DeleteFileA("testdir\\c.txt");
79     DeleteFileA("testdir\\d.txt");
80     RemoveDirectoryA("testdir");
81     RemoveDirectoryA("dest");
82
83     DeleteFileA("extract.cab");
84 }
85
86 static BOOL check_ini_file_attr(LPSTR filename)
87 {
88     BOOL ret;
89     DWORD expected = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY;
90     DWORD attr = GetFileAttributesA(filename);
91
92     ret = (attr & expected) && (attr != INVALID_FILE_ATTRIBUTES);
93     SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL);
94
95     return ret;
96 }
97
98 static void test_AddDelBackupEntry(void)
99 {
100     BOOL ret;
101     HRESULT res;
102     CHAR path[MAX_PATH];
103     CHAR windir[MAX_PATH];
104
105     lstrcpyA(path, CURR_DIR);
106     lstrcatA(path, "\\backup\\basename.INI");
107
108     /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
109
110     /* try a NULL file list */
111     res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
112     ok(res == S_OK, "Expected S_OK, got %d\n", res);
113     ok(!DeleteFileA(path), "Expected path to not exist\n");
114
115     lstrcpyA(path, CURR_DIR);
116     lstrcatA(path, "\\backup\\.INI");
117
118     /* try an empty base name */
119     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
120     ok(res == S_OK, "Expected S_OK, got %d\n", res);
121     ok(!DeleteFileA(path), "Expected path to not exist\n");
122
123     lstrcpyA(path, CURR_DIR);
124     lstrcatA(path, "\\basename.INI");
125
126     /* try an invalid flag */
127     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
128     ok(res == S_OK, "Expected S_OK, got %d\n", res);
129     ok(!DeleteFileA(path), "Expected path to not exist\n");
130
131     lstrcpyA(path, "c:\\basename.INI");
132
133     /* create the INF file */
134     res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
135     ok(res == S_OK, "Expected S_OK, got %d\n", res);
136     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
137     ok(DeleteFileA(path), "Expected path to exist\n");
138
139     lstrcpyA(path, CURR_DIR);
140     lstrcatA(path, "\\backup\\basename.INI");
141
142     /* try to create the INI file in a nonexistent directory */
143     RemoveDirectoryA("backup");
144     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
145     ok(res == S_OK, "Expected S_OK, got %d\n", res);
146     ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
147     ok(!DeleteFileA(path), "Expected path to not exist\n");
148
149     /* try an existent, relative backup directory */
150     CreateDirectoryA("backup", NULL);
151     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
152     ok(res == S_OK, "Expected S_OK, got %d\n", res);
153     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
154     ok(DeleteFileA(path), "Expected path to exist\n");
155     RemoveDirectoryA("backup");
156
157     GetWindowsDirectoryA(windir, sizeof(windir));
158     sprintf(path, "%s\\basename.INI", windir);
159
160     /* try a NULL backup dir, INI is created in the windows directory */
161     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
162     ok(res == S_OK, "Expected S_OK, got %d\n", res);
163
164     /* remove the entries with AADBE_DEL_ENTRY */
165     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
166     res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
167     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
168     ok(res == S_OK, "Expected S_OK, got %d\n", res);
169     ret = DeleteFileA(path);
170     ok(ret == TRUE ||
171        broken(ret == FALSE), /* win98 */
172        "Expected path to exist\n");
173 }
174
175 /* the FCI callbacks */
176
177 static void *mem_alloc(ULONG cb)
178 {
179     return HeapAlloc(GetProcessHeap(), 0, cb);
180 }
181
182 static void mem_free(void *memory)
183 {
184     HeapFree(GetProcessHeap(), 0, memory);
185 }
186
187 static BOOL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
188 {
189     return TRUE;
190 }
191
192 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
193 {
194     return 0;
195 }
196
197 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
198                        BOOL fContinuation, void *pv)
199 {
200     return 0;
201 }
202
203 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
204 {
205     HANDLE handle;
206     DWORD dwAccess = 0;
207     DWORD dwShareMode = 0;
208     DWORD dwCreateDisposition = OPEN_EXISTING;
209     
210     dwAccess = GENERIC_READ | GENERIC_WRITE;
211     /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
212     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
213
214     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
215         dwCreateDisposition = OPEN_EXISTING;
216     else
217         dwCreateDisposition = CREATE_NEW;
218
219     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
220                          dwCreateDisposition, 0, NULL);
221
222     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
223
224     return (INT_PTR)handle;
225 }
226
227 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
228 {
229     HANDLE handle = (HANDLE)hf;
230     DWORD dwRead;
231     BOOL res;
232     
233     res = ReadFile(handle, memory, cb, &dwRead, NULL);
234     ok(res, "Failed to ReadFile\n");
235
236     return dwRead;
237 }
238
239 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
240 {
241     HANDLE handle = (HANDLE)hf;
242     DWORD dwWritten;
243     BOOL res;
244
245     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
246     ok(res, "Failed to WriteFile\n");
247
248     return dwWritten;
249 }
250
251 static int fci_close(INT_PTR hf, int *err, void *pv)
252 {
253     HANDLE handle = (HANDLE)hf;
254     ok(CloseHandle(handle), "Failed to CloseHandle\n");
255
256     return 0;
257 }
258
259 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
260 {
261     HANDLE handle = (HANDLE)hf;
262     DWORD ret;
263     
264     ret = SetFilePointer(handle, dist, NULL, seektype);
265     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
266
267     return ret;
268 }
269
270 static int fci_delete(char *pszFile, int *err, void *pv)
271 {
272     BOOL ret = DeleteFileA(pszFile);
273     ok(ret, "Failed to DeleteFile %s\n", pszFile);
274
275     return 0;
276 }
277
278 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
279 {
280     LPSTR tempname;
281
282     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
283     GetTempFileNameA(".", "xx", 0, tempname);
284
285     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
286     {
287         lstrcpyA(pszTempName, tempname);
288         HeapFree(GetProcessHeap(), 0, tempname);
289         return TRUE;
290     }
291
292     HeapFree(GetProcessHeap(), 0, tempname);
293
294     return FALSE;
295 }
296
297 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
298                              USHORT *pattribs, int *err, void *pv)
299 {
300     BY_HANDLE_FILE_INFORMATION finfo;
301     FILETIME filetime;
302     HANDLE handle;
303     DWORD attrs;
304     BOOL res;
305
306     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
307                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
308
309     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
310
311     res = GetFileInformationByHandle(handle, &finfo);
312     ok(res, "Expected GetFileInformationByHandle to succeed\n");
313    
314     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
315     FileTimeToDosDateTime(&filetime, pdate, ptime);
316
317     attrs = GetFileAttributes(pszName);
318     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
319
320     return (INT_PTR)handle;
321 }
322
323 static void add_file(HFCI hfci, char *file)
324 {
325     char path[MAX_PATH];
326     BOOL res;
327
328     lstrcpyA(path, CURR_DIR);
329     lstrcatA(path, "\\");
330     lstrcatA(path, file);
331
332     res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
333                      get_open_info, tcompTYPE_MSZIP);
334     ok(res, "Expected FCIAddFile to succeed\n");
335 }
336
337 static void set_cab_parameters(PCCAB pCabParams)
338 {
339     ZeroMemory(pCabParams, sizeof(CCAB));
340
341     pCabParams->cb = MEDIA_SIZE;
342     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
343     pCabParams->setID = 0xbeef;
344     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
345     lstrcatA(pCabParams->szCabPath, "\\");
346     lstrcpyA(pCabParams->szCab, "extract.cab");
347 }
348
349 static void create_cab_file(void)
350 {
351     CCAB cabParams;
352     HFCI hfci;
353     ERF erf;
354     static CHAR a_txt[] = "a.txt",
355                 b_txt[] = "b.txt",
356                 testdir_c_txt[] = "testdir\\c.txt",
357                 testdir_d_txt[] = "testdir\\d.txt";
358     BOOL res;
359
360     set_cab_parameters(&cabParams);
361
362     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
363                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
364                       get_temp_file, &cabParams, NULL);
365
366     ok(hfci != NULL, "Failed to create an FCI context\n");
367
368     add_file(hfci, a_txt);
369     add_file(hfci, b_txt);
370     add_file(hfci, testdir_c_txt);
371     add_file(hfci, testdir_d_txt);
372
373     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
374     ok(res, "Failed to flush the cabinet\n");
375
376     res = FCIDestroy(hfci);
377     ok(res, "Failed to destroy the cabinet\n");
378 }
379
380 static void test_ExtractFiles(void)
381 {
382     HRESULT hr;
383     char destFolder[MAX_PATH];
384
385     lstrcpyA(destFolder, CURR_DIR);
386     lstrcatA(destFolder, "\\");
387     lstrcatA(destFolder, "dest");
388
389     /* try NULL cab file */
390     hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
391     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
392     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
393     
394     /* try NULL destination */
395     hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
396     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
397     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
398
399     /* extract all files in the cab to nonexistent destination directory */
400     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
401     ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) ||
402        hr == E_FAIL, /* win95 */
403        "Expected %08x or %08x, got %08x\n", E_FAIL,
404        HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
405     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
406     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
407     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
408     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
409
410     /* extract all files in the cab to the destination directory */
411     CreateDirectoryA("dest", NULL);
412     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
413     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
414     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
415     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
416     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
417     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
418     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
419
420     /* extract all files to a relative destination directory */
421     hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
422     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
423     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
424     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
425     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
426     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
427     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
428
429     /* only extract two of the files from the cab */
430     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
431     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
432     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
433     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
434     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
435     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
436     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
437
438     /* use valid chars before and after file list */
439     hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt  \t:", NULL, 0);
440     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
441     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
442     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
443     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
444     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
445     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
446
447     /* use invalid chars before and after file list */
448     hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt  a_:", NULL, 0);
449     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
450     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
451     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
452     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
453
454     /* try an empty file list */
455     hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
456     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
457     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
458     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
459
460     /* try a nonexistent file in the file list */
461     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
462     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
463     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
464     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
465     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
466 }
467
468 static void test_AdvInstallFile(void)
469 {
470     HRESULT hr;
471     HMODULE hmod;
472     char CURR_DIR[MAX_PATH];
473     char destFolder[MAX_PATH];
474
475     hmod = LoadLibrary("setupapi.dll");
476     if (!hmod)
477     {
478         skip("setupapi.dll not present\n");
479         return;
480     }
481
482     FreeLibrary(hmod);
483
484     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
485
486     lstrcpyA(destFolder, CURR_DIR);
487     lstrcatA(destFolder, "\\");
488     lstrcatA(destFolder, "dest");
489
490     createTestFile("source.txt");
491
492     /* try invalid source directory */
493     hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
494     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
495     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
496
497     /* try invalid source file */
498     hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
499     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
500     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
501
502     /* try invalid destination directory */
503     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
504     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
505     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
506
507     /* try copying to nonexistent destination directory */
508     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
509     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
510     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
511
512     /* native windows screws up if the source file doesn't exist */
513
514     /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
515     createTestFile("dest\\destination.txt");
516     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
517                          "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
518     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
519     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
520     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
521
522     DeleteFileA("source.txt");
523 }
524
525 START_TEST(files)
526 {
527     DWORD len;
528     char temp_path[MAX_PATH], prev_path[MAX_PATH];
529
530     init_function_pointers();
531
532     GetCurrentDirectoryA(MAX_PATH, prev_path);
533     GetTempPath(MAX_PATH, temp_path);
534     SetCurrentDirectoryA(temp_path);
535
536     lstrcpyA(CURR_DIR, temp_path);
537     len = lstrlenA(CURR_DIR);
538
539     if(len && (CURR_DIR[len - 1] == '\\'))
540         CURR_DIR[len - 1] = 0;
541
542     create_test_files();
543     create_cab_file();
544
545     test_AddDelBackupEntry();
546     test_ExtractFiles();
547     test_AdvInstallFile();
548
549     delete_test_files();
550
551     FreeLibrary(hAdvPack);
552     SetCurrentDirectoryA(prev_path);
553 }