4 * Copyright 2007 James Hawkins
5 * Copyright 2007 Hans Leidekker
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
34 static CHAR CURR_DIR[MAX_PATH];
37 * - fails if not administrator
38 * - what if it's not a .inf file?
39 * - copied to %windir%/Inf
40 * - SourceInfFileName should be a full path
41 * - SourceInfFileName should be <= MAX_PATH
45 static void append_str(char **str, const char *data)
51 static void create_inf_file(LPCSTR filename)
55 DWORD dwNumberOfBytesWritten;
56 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
57 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
59 append_str(&ptr, "[Version]\n");
60 append_str(&ptr, "Signature=\"$Chicago$\"\n");
61 append_str(&ptr, "AdvancedINF=2.5\n");
62 append_str(&ptr, "[DefaultInstall]\n");
63 append_str(&ptr, "RegisterOCXs=RegisterOCXsSection\n");
64 append_str(&ptr, "[RegisterOCXsSection]\n");
65 append_str(&ptr, "%%11%%\\ole32.dll\n");
67 WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
71 static void get_temp_filename(LPSTR path)
76 GetTempFileName(CURR_DIR, "set", 0, temp);
77 ptr = strrchr(temp, '\\');
79 lstrcpy(path, ptr + 1);
82 static BOOL file_exists(LPSTR path)
84 return GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES;
87 static BOOL check_format(LPSTR path, LPSTR inf)
92 static const CHAR format[] = "\\INF\\oem";
94 GetWindowsDirectory(check, MAX_PATH);
95 lstrcat(check, format);
96 res = !strncasecmp(check, path, lstrlen(check)) &&
97 path[lstrlen(check)] != '\\';
99 return (!inf) ? res : res && (inf == path + lstrlen(check) - 3);
102 static void test_SetupCopyOEMInf(void)
104 CHAR toolong[MAX_PATH * 2];
105 CHAR path[MAX_PATH], dest[MAX_PATH];
106 CHAR tmpfile[MAX_PATH], dest_save[MAX_PATH];
111 /* try NULL SourceInfFileName */
112 SetLastError(0xdeadbeef);
113 res = SetupCopyOEMInf(NULL, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
114 ok(res == FALSE, "Expected FALSE, got %d\n", res);
115 ok(GetLastError() == ERROR_INVALID_PARAMETER,
116 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
118 /* try empty SourceInfFileName */
119 SetLastError(0xdeadbeef);
120 res = SetupCopyOEMInf("", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
121 ok(res == FALSE, "Expected FALSE, got %d\n", res);
122 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
123 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
125 /* try a relative nonexistent SourceInfFileName */
126 SetLastError(0xdeadbeef);
127 res = SetupCopyOEMInf("nonexistent", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
128 ok(res == FALSE, "Expected FALSE, got %d\n", res);
129 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
130 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
132 /* try an absolute nonexistent SourceInfFileName */
133 lstrcpy(path, CURR_DIR);
134 lstrcat(path, "\\nonexistent");
135 SetLastError(0xdeadbeef);
136 res = SetupCopyOEMInf(path, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
137 ok(res == FALSE, "Expected FALSE, got %d\n", res);
138 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
139 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
141 /* try a long SourceInfFileName */
142 memset(toolong, 'a', MAX_PATH * 2);
143 toolong[MAX_PATH * 2 - 1] = '\0';
144 SetLastError(0xdeadbeef);
145 res = SetupCopyOEMInf(toolong, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
146 ok(res == FALSE, "Expected FALSE, got %d\n", res);
147 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
148 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
150 get_temp_filename(tmpfile);
151 create_inf_file(tmpfile);
153 /* try a relative SourceInfFileName */
154 SetLastError(0xdeadbeef);
155 res = SetupCopyOEMInf(tmpfile, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
156 ok(res == FALSE, "Expected FALSE, got %d\n", res);
157 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
158 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
159 ok(file_exists(tmpfile), "Expected tmpfile to exist\n");
161 /* try SP_COPY_REPLACEONLY, dest does not exist */
162 SetLastError(0xdeadbeef);
163 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, NULL, 0, NULL, NULL);
164 ok(res == FALSE, "Expected FALSE, got %d\n", res);
165 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
166 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
167 ok(file_exists(tmpfile), "Expected source inf to exist\n");
169 /* try an absolute SourceInfFileName, without DestinationInfFileName */
170 lstrcpy(path, CURR_DIR);
172 lstrcat(path, tmpfile);
173 SetLastError(0xdeadbeef);
174 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, 0, NULL, 0, NULL, NULL);
175 ok(res == TRUE, "Expected TRUE, got %d\n", res);
176 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
177 ok(file_exists(path), "Expected source inf to exist\n");
179 /* try SP_COPY_REPLACEONLY, dest exists */
180 SetLastError(0xdeadbeef);
181 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, NULL, 0, NULL, NULL);
182 ok(res == TRUE, "Expected TRUE, got %d\n", res);
183 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
184 ok(file_exists(path), "Expected source inf to exist\n");
186 /* try SP_COPY_NOOVERWRITE */
187 SetLastError(0xdeadbeef);
188 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
189 ok(res == FALSE, "Expected FALSE, got %d\n", res);
190 ok(GetLastError() == ERROR_FILE_EXISTS,
191 "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
193 /* get the DestinationInfFileName */
194 SetLastError(0xdeadbeef);
195 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, NULL, NULL);
196 ok(res == TRUE, "Expected TRUE, got %d\n", res);
197 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
198 ok(lstrlen(dest) != 0, "Expected a non-zero length string\n");
199 ok(file_exists(dest), "Expected destination inf to exist\n");
200 ok(check_format(dest, NULL), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
201 ok(file_exists(path), "Expected source inf to exist\n");
203 lstrcpy(dest_save, dest);
204 DeleteFile(dest_save);
206 /* get the DestinationInfFileName, DestinationInfFileNameSize is too small
207 * - inf is still copied
209 lstrcpy(dest, "aaa");
211 SetLastError(0xdeadbeef);
212 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, 0, dest, 5, &size, NULL);
213 ok(res == FALSE, "Expected FALSE, got %d\n", res);
214 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
215 "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
216 ok(file_exists(path), "Expected source inf to exist\n");
217 ok(file_exists(dest_save), "Expected dest inf to exist\n");
218 ok(!lstrcmp(dest, "aaa"), "Expected dest to be unchanged\n");
219 ok(size == lstrlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
221 /* get the DestinationInfFileName and DestinationInfFileNameSize */
222 SetLastError(0xdeadbeef);
223 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, NULL);
224 ok(res == TRUE, "Expected TRUE, got %d\n", res);
225 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
226 ok(lstrlen(dest) + 1 == size, "Expected sizes to match, got (%d, %d)\n", lstrlen(dest), size);
227 ok(file_exists(dest), "Expected destination inf to exist\n");
228 ok(check_format(dest, NULL), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
229 ok(file_exists(path), "Expected source inf to exist\n");
230 ok(size == lstrlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
232 /* get the DestinationInfFileName, DestinationInfFileNameSize, and DestinationInfFileNameComponent */
233 SetLastError(0xdeadbeef);
234 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, &inf);
235 ok(res == TRUE, "Expected TRUE, got %d\n", res);
236 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
237 ok(lstrlen(dest) + 1 == size, "Expected sizes to match, got (%d, %d)\n", lstrlen(dest), size);
238 ok(file_exists(dest), "Expected destination inf to exist\n");
239 ok(check_format(dest, inf), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
240 ok(file_exists(path), "Expected source inf to exist\n");
241 ok(size == lstrlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
243 /* try SP_COPY_DELETESOURCE */
244 SetLastError(0xdeadbeef);
245 res = SetupCopyOEMInf(path, NULL, SPOST_NONE, SP_COPY_DELETESOURCE, NULL, 0, NULL, NULL);
246 ok(res == TRUE, "Expected TRUE, got %d\n", res);
247 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
248 ok(!file_exists(path), "Expected source inf to not exist\n");
251 static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
256 handle = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
257 WriteFile(handle, data, size, &written, NULL);
261 static BOOL compare_file_data(LPSTR file, const BYTE *data, DWORD size)
268 handle = CreateFileA(file, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
269 buffer = HeapAlloc(GetProcessHeap(), 0, size);
272 ReadFile(handle, buffer, size, &read, NULL);
273 if (read == size && !memcmp(data, buffer, size)) ret = TRUE;
274 HeapFree(GetProcessHeap(), 0, buffer);
280 static const BYTE uncompressed[] = {
281 'u','n','c','o','m','p','r','e','s','s','e','d','\r','\n'
283 static const BYTE comp_lzx[] = {
284 0x53, 0x5a, 0x44, 0x44, 0x88, 0xf0, 0x27, 0x33, 0x41, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xff, 0x00,
285 0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x3f, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64
287 static const BYTE comp_zip[] = {
288 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11,
289 0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x15, 0x00, 0x77, 0x69,
290 0x6e, 0x65, 0x55, 0x54, 0x09, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46, 0xfd, 0x0d, 0x10, 0x46, 0x55,
291 0x78, 0x04, 0x00, 0xe8, 0x03, 0xe8, 0x03, 0x00, 0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x72,
292 0x65, 0x73, 0x73, 0x65, 0x64, 0x50, 0x4b, 0x01, 0x02, 0x17, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11, 0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
294 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00,
295 0x00, 0x00, 0x00, 0x77, 0x69, 0x6e, 0x65, 0x55, 0x54, 0x05, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46,
296 0x55, 0x78, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
297 0x3f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00
299 static const BYTE comp_cab_lzx[] = {
300 0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
302 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x0f, 0x0e, 0x00, 0x00, 0x00,
303 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x36, 0x86, 0x72, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
304 0x00, 0x19, 0xd0, 0x1a, 0xe3, 0x22, 0x00, 0x0e, 0x00, 0x5b, 0x80, 0x80, 0x8d, 0x00, 0x30, 0xe0,
305 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x63,
306 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x0d, 0x0a
308 static const BYTE comp_cab_zip[] = {
309 0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00,
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x36, 0x2f, 0xa5, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
313 0x00, 0x7c, 0x80, 0x26, 0x2b, 0x12, 0x00, 0x0e, 0x00, 0x43, 0x4b, 0x2b, 0xcd, 0x4b, 0xce, 0xcf,
314 0x2d, 0x28, 0x4a, 0x2d, 0x2e, 0x4e, 0x4d, 0xe1, 0xe5, 0x02, 0x00
317 static void test_SetupGetFileCompressionInfoEx(void)
320 DWORD required_len, source_size, target_size;
321 char source[MAX_PATH], temp[MAX_PATH], name[MAX_PATH];
324 GetTempPathA(sizeof(temp), temp);
325 GetTempFileNameA(temp, "doc", 0, source);
327 ret = SetupGetFileCompressionInfoExA(NULL, NULL, 0, NULL, NULL, NULL, NULL);
328 ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
330 ret = SetupGetFileCompressionInfoExA(source, NULL, 0, NULL, NULL, NULL, NULL);
331 ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
333 ret = SetupGetFileCompressionInfoExA(source, NULL, 0, &required_len, NULL, NULL, NULL);
334 ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
335 ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
337 create_source_file(source, comp_lzx, sizeof(comp_lzx));
339 ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
340 ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
341 ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
342 ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
343 ok(source_size == sizeof(comp_lzx), "got %d\n", source_size);
344 ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
345 ok(type == FILE_COMPRESSION_WINLZA, "got %d, expected FILE_COMPRESSION_WINLZA\n", type);
348 create_source_file(source, comp_zip, sizeof(comp_zip));
350 ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
351 ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
352 ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
353 ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
354 ok(source_size == sizeof(comp_zip), "got %d\n", source_size);
355 ok(target_size == sizeof(comp_zip), "got %d\n", target_size);
356 ok(type == FILE_COMPRESSION_NONE, "got %d, expected FILE_COMPRESSION_NONE\n", type);
359 create_source_file(source, comp_cab_lzx, sizeof(comp_cab_lzx));
361 ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
362 ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
363 ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
364 ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
365 ok(source_size == sizeof(comp_cab_lzx), "got %d\n", source_size);
366 ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
367 ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
370 create_source_file(source, comp_cab_zip, sizeof(comp_cab_zip));
372 ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
373 ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
374 ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
375 ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
376 ok(source_size == sizeof(comp_cab_zip), "got %d\n", source_size);
377 ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
378 ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
382 static void test_SetupDecompressOrCopyFile(void)
385 char source[MAX_PATH], target[MAX_PATH], temp[MAX_PATH], *p;
388 GetTempPathA(sizeof(temp), temp);
389 GetTempFileNameA(temp, "doc", 0, source);
390 GetTempFileNameA(temp, "doc", 0, target);
392 /* parameter tests */
394 create_source_file(source, uncompressed, sizeof(uncompressed));
396 ret = SetupDecompressOrCopyFileA(NULL, NULL, NULL);
397 ok(ret == ERROR_INVALID_PARAMETER, "SetupDecompressOrCopyFile failed unexpectedly\n");
399 type = FILE_COMPRESSION_NONE;
400 ret = SetupDecompressOrCopyFileA(NULL, target, &type);
401 ok(ret == ERROR_INVALID_PARAMETER, "SetupDecompressOrCopyFile failed unexpectedly\n");
403 ret = SetupDecompressOrCopyFileA(source, NULL, &type);
404 ok(ret == ERROR_INVALID_PARAMETER, "SetupDecompressOrCopyFile failed unexpectedly\n");
406 type = 5; /* try an invalid compression type */
407 ret = SetupDecompressOrCopyFileA(source, target, &type);
408 ok(ret == ERROR_INVALID_PARAMETER, "SetupDecompressOrCopyFile failed unexpectedly\n");
412 /* no compression tests */
414 ret = SetupDecompressOrCopyFileA(source, target, NULL);
415 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
416 ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
418 /* try overwriting existing file */
419 ret = SetupDecompressOrCopyFileA(source, target, NULL);
420 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
423 type = FILE_COMPRESSION_NONE;
424 ret = SetupDecompressOrCopyFileA(source, target, &type);
425 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
426 ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
429 type = FILE_COMPRESSION_WINLZA;
430 ret = SetupDecompressOrCopyFileA(source, target, &type);
431 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
432 ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
435 /* lz compression tests */
437 create_source_file(source, comp_lzx, sizeof(comp_lzx));
439 ret = SetupDecompressOrCopyFileA(source, target, NULL);
440 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
443 /* zip compression tests */
445 create_source_file(source, comp_zip, sizeof(comp_zip));
447 ret = SetupDecompressOrCopyFileA(source, target, NULL);
448 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
449 ok(compare_file_data(target, comp_zip, sizeof(comp_zip)), "incorrect target file\n");
452 /* cabinet compression tests */
454 create_source_file(source, comp_cab_zip, sizeof(comp_cab_zip));
456 p = strrchr(target, '\\');
457 lstrcpyA(p + 1, "wine");
459 ret = SetupDecompressOrCopyFileA(source, target, NULL);
460 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
461 ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
463 /* try overwriting existing file */
464 ret = SetupDecompressOrCopyFileA(source, target, NULL);
465 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
467 /* try zip compression */
468 type = FILE_COMPRESSION_MSZIP;
469 ret = SetupDecompressOrCopyFileA(source, target, &type);
470 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
471 ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
473 /* try no compression */
474 type = FILE_COMPRESSION_NONE;
475 ret = SetupDecompressOrCopyFileA(source, target, &type);
476 ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
477 ok(compare_file_data(target, comp_cab_zip, sizeof(comp_cab_zip)), "incorrect target file\n");
485 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
487 test_SetupCopyOEMInf();
488 test_SetupGetFileCompressionInfoEx();
489 test_SetupDecompressOrCopyFile();