quartz: Add tests for avi splitter.
[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     HRESULT res;
101     CHAR path[MAX_PATH];
102     CHAR windir[MAX_PATH];
103
104     lstrcpyA(path, CURR_DIR);
105     lstrcatA(path, "\\backup\\basename.INI");
106
107     /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
108
109     /* try a NULL file list */
110     res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
111     ok(res == S_OK, "Expected S_OK, got %d\n", res);
112     ok(!DeleteFileA(path), "Expected path to not exist\n");
113
114     lstrcpyA(path, CURR_DIR);
115     lstrcatA(path, "\\backup\\.INI");
116
117     /* try an empty base name */
118     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
119     ok(res == S_OK, "Expected S_OK, got %d\n", res);
120     ok(!DeleteFileA(path), "Expected path to not exist\n");
121
122     lstrcpyA(path, CURR_DIR);
123     lstrcatA(path, "\\basename.INI");
124
125     /* try an invalid flag */
126     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
127     ok(res == S_OK, "Expected S_OK, got %d\n", res);
128     ok(!DeleteFileA(path), "Expected path to not exist\n");
129
130     lstrcpyA(path, "c:\\basename.INI");
131
132     /* create the INF file */
133     res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
134     ok(res == S_OK, "Expected S_OK, got %d\n", res);
135     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
136     ok(DeleteFileA(path), "Expected path to exist\n");
137
138     lstrcpyA(path, CURR_DIR);
139     lstrcatA(path, "\\backup\\basename.INI");
140
141     /* try to create the INI file in a nonexistent directory */
142     RemoveDirectoryA("backup");
143     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
144     ok(res == S_OK, "Expected S_OK, got %d\n", res);
145     ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
146     ok(!DeleteFileA(path), "Expected path to not exist\n");
147
148     /* try an existent, relative backup directory */
149     CreateDirectoryA("backup", NULL);
150     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
151     ok(res == S_OK, "Expected S_OK, got %d\n", res);
152     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
153     ok(DeleteFileA(path), "Expected path to exist\n");
154     RemoveDirectoryA("backup");
155
156     GetWindowsDirectoryA(windir, sizeof(windir));
157     sprintf(path, "%s\\basename.INI", windir);
158
159     /* try a NULL backup dir, INI is created in the windows directory */
160     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
161     ok(res == S_OK, "Expected S_OK, got %d\n", res);
162
163     /* remove the entries with AADBE_DEL_ENTRY */
164     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
165     res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
166     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
167     ok(res == S_OK, "Expected S_OK, got %d\n", res);
168     ok(DeleteFileA(path), "Expected path to exist\n");
169 }
170
171 /* the FCI callbacks */
172
173 static void *mem_alloc(ULONG cb)
174 {
175     return HeapAlloc(GetProcessHeap(), 0, cb);
176 }
177
178 static void mem_free(void *memory)
179 {
180     HeapFree(GetProcessHeap(), 0, memory);
181 }
182
183 static BOOL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
184 {
185     return TRUE;
186 }
187
188 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
189 {
190     return 0;
191 }
192
193 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
194                        BOOL fContinuation, void *pv)
195 {
196     return 0;
197 }
198
199 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
200 {
201     HANDLE handle;
202     DWORD dwAccess = 0;
203     DWORD dwShareMode = 0;
204     DWORD dwCreateDisposition = OPEN_EXISTING;
205     
206     dwAccess = GENERIC_READ | GENERIC_WRITE;
207     /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
208     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
209
210     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
211         dwCreateDisposition = OPEN_EXISTING;
212     else
213         dwCreateDisposition = CREATE_NEW;
214
215     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
216                          dwCreateDisposition, 0, NULL);
217
218     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
219
220     return (INT_PTR)handle;
221 }
222
223 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
224 {
225     HANDLE handle = (HANDLE)hf;
226     DWORD dwRead;
227     BOOL res;
228     
229     res = ReadFile(handle, memory, cb, &dwRead, NULL);
230     ok(res, "Failed to ReadFile\n");
231
232     return dwRead;
233 }
234
235 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
236 {
237     HANDLE handle = (HANDLE)hf;
238     DWORD dwWritten;
239     BOOL res;
240
241     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
242     ok(res, "Failed to WriteFile\n");
243
244     return dwWritten;
245 }
246
247 static int fci_close(INT_PTR hf, int *err, void *pv)
248 {
249     HANDLE handle = (HANDLE)hf;
250     ok(CloseHandle(handle), "Failed to CloseHandle\n");
251
252     return 0;
253 }
254
255 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
256 {
257     HANDLE handle = (HANDLE)hf;
258     DWORD ret;
259     
260     ret = SetFilePointer(handle, dist, NULL, seektype);
261     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
262
263     return ret;
264 }
265
266 static int fci_delete(char *pszFile, int *err, void *pv)
267 {
268     BOOL ret = DeleteFileA(pszFile);
269     ok(ret, "Failed to DeleteFile %s\n", pszFile);
270
271     return 0;
272 }
273
274 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
275 {
276     LPSTR tempname;
277
278     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
279     GetTempFileNameA(".", "xx", 0, tempname);
280
281     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
282     {
283         lstrcpyA(pszTempName, tempname);
284         HeapFree(GetProcessHeap(), 0, tempname);
285         return TRUE;
286     }
287
288     HeapFree(GetProcessHeap(), 0, tempname);
289
290     return FALSE;
291 }
292
293 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
294                              USHORT *pattribs, int *err, void *pv)
295 {
296     BY_HANDLE_FILE_INFORMATION finfo;
297     FILETIME filetime;
298     HANDLE handle;
299     DWORD attrs;
300     BOOL res;
301
302     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
303                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
304
305     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
306
307     res = GetFileInformationByHandle(handle, &finfo);
308     ok(res, "Expected GetFileInformationByHandle to succeed\n");
309    
310     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
311     FileTimeToDosDateTime(&filetime, pdate, ptime);
312
313     attrs = GetFileAttributes(pszName);
314     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
315
316     return (INT_PTR)handle;
317 }
318
319 static void add_file(HFCI hfci, char *file)
320 {
321     char path[MAX_PATH];
322     BOOL res;
323
324     lstrcpyA(path, CURR_DIR);
325     lstrcatA(path, "\\");
326     lstrcatA(path, file);
327
328     res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
329                      get_open_info, tcompTYPE_MSZIP);
330     ok(res, "Expected FCIAddFile to succeed\n");
331 }
332
333 static void set_cab_parameters(PCCAB pCabParams)
334 {
335     ZeroMemory(pCabParams, sizeof(CCAB));
336
337     pCabParams->cb = MEDIA_SIZE;
338     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
339     pCabParams->setID = 0xbeef;
340     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
341     lstrcatA(pCabParams->szCabPath, "\\");
342     lstrcpyA(pCabParams->szCab, "extract.cab");
343 }
344
345 static void create_cab_file(void)
346 {
347     CCAB cabParams;
348     HFCI hfci;
349     ERF erf;
350     static CHAR a_txt[] = "a.txt",
351                 b_txt[] = "b.txt",
352                 testdir_c_txt[] = "testdir\\c.txt",
353                 testdir_d_txt[] = "testdir\\d.txt";
354     BOOL res;
355
356     set_cab_parameters(&cabParams);
357
358     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
359                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
360                       get_temp_file, &cabParams, NULL);
361
362     ok(hfci != NULL, "Failed to create an FCI context\n");
363
364     add_file(hfci, a_txt);
365     add_file(hfci, b_txt);
366     add_file(hfci, testdir_c_txt);
367     add_file(hfci, testdir_d_txt);
368
369     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
370     ok(res, "Failed to flush the cabinet\n");
371
372     res = FCIDestroy(hfci);
373     ok(res, "Failed to destroy the cabinet\n");
374 }
375
376 static void test_ExtractFiles(void)
377 {
378     HRESULT hr;
379     char destFolder[MAX_PATH];
380
381     lstrcpyA(destFolder, CURR_DIR);
382     lstrcatA(destFolder, "\\");
383     lstrcatA(destFolder, "dest");
384
385     /* try NULL cab file */
386     hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
387     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
388     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
389     
390     /* try NULL destination */
391     hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
392     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
393     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
394
395     /* extract all files in the cab to nonexistent destination directory */
396     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
397     ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) ||
398        hr == E_FAIL, /* win95 */
399        "Expected %08x or %08x, got %08x\n", E_FAIL,
400        HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
401     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
402     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
403     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
404     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
405
406     /* extract all files in the cab to the destination directory */
407     CreateDirectoryA("dest", NULL);
408     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
409     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
410     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
411     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
412     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
413     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
414     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
415
416     /* extract all files to a relative destination directory */
417     hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
418     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
419     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
420     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
421     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
422     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
423     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
424
425     /* only extract two of the files from the cab */
426     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
427     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
428     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
429     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
430     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
431     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
432     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
433
434     /* use valid chars before and after file list */
435     hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt  \t:", NULL, 0);
436     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
437     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
438     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
439     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
440     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
441     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
442
443     /* use invalid chars before and after file list */
444     hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt  a_:", NULL, 0);
445     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
446     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
447     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
448     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
449
450     /* try an empty file list */
451     hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
452     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
453     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
454     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
455
456     /* try a nonexistent file in the file list */
457     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
458     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
459     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
460     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
461     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
462 }
463
464 static void test_AdvInstallFile(void)
465 {
466     HRESULT hr;
467     HMODULE hmod;
468     char CURR_DIR[MAX_PATH];
469     char destFolder[MAX_PATH];
470
471     hmod = LoadLibrary("setupapi.dll");
472     if (!hmod)
473     {
474         skip("setupapi.dll not present\n");
475         return;
476     }
477
478     FreeLibrary(hmod);
479
480     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
481
482     lstrcpyA(destFolder, CURR_DIR);
483     lstrcatA(destFolder, "\\");
484     lstrcatA(destFolder, "dest");
485
486     createTestFile("source.txt");
487
488     /* try invalid source directory */
489     hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
490     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
491     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
492
493     /* try invalid source file */
494     hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
495     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
496     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
497
498     /* try invalid destination directory */
499     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
500     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
501     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
502
503     /* try copying to nonexistent destination directory */
504     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
505     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
506     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
507
508     /* native windows screws up if the source file doesn't exist */
509
510     /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
511     createTestFile("dest\\destination.txt");
512     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
513                          "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
514     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
515     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
516     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
517
518     DeleteFileA("source.txt");
519 }
520
521 START_TEST(files)
522 {
523     DWORD len;
524     char temp_path[MAX_PATH], prev_path[MAX_PATH];
525
526     init_function_pointers();
527
528     GetCurrentDirectoryA(MAX_PATH, prev_path);
529     GetTempPath(MAX_PATH, temp_path);
530     SetCurrentDirectoryA(temp_path);
531
532     lstrcpyA(CURR_DIR, temp_path);
533     len = lstrlenA(CURR_DIR);
534
535     if(len && (CURR_DIR[len - 1] == '\\'))
536         CURR_DIR[len - 1] = 0;
537
538     create_test_files();
539     create_cab_file();
540
541     test_AddDelBackupEntry();
542     test_ExtractFiles();
543     test_AdvInstallFile();
544
545     delete_test_files();
546
547     FreeLibrary(hAdvPack);
548     SetCurrentDirectoryA(prev_path);
549 }