ReactOS 0.4.15-dev-7842-g558ab78
diskspace.c
Go to the documentation of this file.
1/*
2 * Unit tests for disk space functions
3 *
4 * Copyright 2010 Andrew Nguyen
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 <stdarg.h>
22#include <stdio.h>
23
24#include "windef.h"
25#include "winbase.h"
26#include "winnls.h"
27#include "winuser.h"
28#include "winreg.h"
29#include "setupapi.h"
30
31#include "wine/test.h"
32
34
35#define STD_HEADER "[Version]\r\nSignature=\"$CHICAGO$\"\r\n"
36
37static inline const char* debugstr_longlong(ULONGLONG ll)
38{
39 static char string[17];
40 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
41 sprintf(string, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll);
42 else
43 sprintf(string, "%lx", (unsigned long)ll);
44 return string;
45}
46
47/* create a new file with specified contents and open it */
48static HINF inf_open_file_content(const char * tmpfilename, const char *data, UINT *err_line)
49{
50 DWORD res;
53 if (handle == INVALID_HANDLE_VALUE) return 0;
54 if (!WriteFile( handle, data, strlen(data), &res, NULL )) trace( "write error\n" );
57}
58
60{
62
64 ok(ret != NULL,
65 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
66
67 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
68
70 ok(ret != NULL,
71 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
72
73 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
74
75 SetLastError(0xdeadbeef);
77 ok(ret == NULL ||
78 broken(ret != NULL), /* NT4/Win9x/Win2k */
79 "Expected SetupCreateDiskSpaceListA to return NULL, got %p\n", ret);
80 if (!ret)
82 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
83 GetLastError());
84 else
85 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
86
87 SetLastError(0xdeadbeef);
88 ret = SetupCreateDiskSpaceListA(NULL, 0xdeadbeef, 0);
89 ok(ret == NULL,
90 "Expected SetupCreateDiskSpaceListA to return NULL, got %p\n", ret);
92 broken(GetLastError() == 0xdeadbeef), /* NT4/Win9x/Win2k */
93 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
94 GetLastError());
95
96 SetLastError(0xdeadbeef);
97 ret = SetupCreateDiskSpaceListA((void *)0xdeadbeef, 0, 0);
98 ok(ret == NULL,
99 "Expected SetupCreateDiskSpaceListA to return NULL, got %p\n", ret);
101 broken(GetLastError() == 0xdeadbeef), /* NT4/Win9x/Win2k */
102 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
103 GetLastError());
104
105 SetLastError(0xdeadbeef);
106 ret = SetupCreateDiskSpaceListA((void *)0xdeadbeef, 0xdeadbeef, 0);
107 ok(ret == NULL,
108 "Expected SetupCreateDiskSpaceListA to return NULL, got %p\n", ret);
110 broken(GetLastError() == 0xdeadbeef), /* NT4/Win9x/Win2k */
111 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
112 GetLastError());
113}
114
116{
117 HDSKSPC ret;
118
121 {
122 win_skip("SetupCreateDiskSpaceListW is not implemented\n");
123 return;
124 }
125 ok(ret != NULL,
126 "Expected SetupCreateDiskSpaceListW to return a valid handle, got NULL\n");
127
128 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
129
131 ok(ret != NULL,
132 "Expected SetupCreateDiskSpaceListW to return a valid handle, got NULL\n");
133
134 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
135
136 SetLastError(0xdeadbeef);
138 ok(ret == NULL ||
139 broken(ret != NULL), /* NT4/Win2k */
140 "Expected SetupCreateDiskSpaceListW to return NULL, got %p\n", ret);
141 if (!ret)
143 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
144 GetLastError());
145 else
146 ok(SetupDestroyDiskSpaceList(ret), "Expected SetupDestroyDiskSpaceList to succeed\n");
147
148 SetLastError(0xdeadbeef);
149 ret = SetupCreateDiskSpaceListW(NULL, 0xdeadbeef, 0);
150 ok(ret == NULL,
151 "Expected SetupCreateDiskSpaceListW to return NULL, got %p\n", ret);
153 broken(GetLastError() == 0xdeadbeef), /* NT4/Win2k */
154 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
155 GetLastError());
156
157 SetLastError(0xdeadbeef);
158 ret = SetupCreateDiskSpaceListW((void *)0xdeadbeef, 0, 0);
159 ok(ret == NULL,
160 "Expected SetupCreateDiskSpaceListW to return NULL, got %p\n", ret);
162 broken(GetLastError() == 0xdeadbeef), /* NT4/Win2k */
163 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
164 GetLastError());
165
166 SetLastError(0xdeadbeef);
167 ret = SetupCreateDiskSpaceListW((void *)0xdeadbeef, 0xdeadbeef, 0);
168 ok(ret == NULL,
169 "Expected SetupCreateDiskSpaceListW to return NULL, got %p\n", ret);
171 broken(GetLastError() == 0xdeadbeef), /* NT4/Win2k */
172 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
173 GetLastError());
174}
175
177{
178 HDSKSPC handle, duplicate;
179
180 if (is_win9x)
181 win_skip("SetupDuplicateDiskSpaceListA crashes with NULL disk space handle on Win9x\n");
182 else
183 {
184 SetLastError(0xdeadbeef);
185 duplicate = SetupDuplicateDiskSpaceListA(NULL, NULL, 0, 0);
186 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
188 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n", GetLastError());
189
190 SetLastError(0xdeadbeef);
191 duplicate = SetupDuplicateDiskSpaceListA(NULL, (void *)0xdeadbeef, 0, 0);
192 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
194 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
195
196 SetLastError(0xdeadbeef);
197 duplicate = SetupDuplicateDiskSpaceListA(NULL, NULL, 0xdeadbeef, 0);
198 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
200 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
201
202 SetLastError(0xdeadbeef);
203 duplicate = SetupDuplicateDiskSpaceListA(NULL, NULL, 0, ~0U);
204 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
206 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
207 }
208
210 ok(handle != NULL,
211 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
212
213 if (!handle)
214 {
215 skip("Failed to create a disk space handle\n");
216 return;
217 }
218
219 SetLastError(0xdeadbeef);
220 duplicate = SetupDuplicateDiskSpaceListA(handle, (void *)0xdeadbeef, 0, 0);
221 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
223 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
224
225 SetLastError(0xdeadbeef);
226 duplicate = SetupDuplicateDiskSpaceListA(handle, NULL, 0xdeadbeef, 0);
227 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
229 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
230
231 SetLastError(0xdeadbeef);
233 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
235 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
236
237 SetLastError(0xdeadbeef);
238 duplicate = SetupDuplicateDiskSpaceListA(handle, NULL, 0, ~0U);
239 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
241 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
242
243 duplicate = SetupDuplicateDiskSpaceListA(handle, NULL, 0, 0);
244 ok(duplicate != NULL, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
245 ok(duplicate != handle,
246 "Expected new handle (%p) to be different from the old handle (%p)\n", duplicate, handle);
247
248 ok(SetupDestroyDiskSpaceList(duplicate), "Expected SetupDestroyDiskSpaceList to succeed\n");
249 ok(SetupDestroyDiskSpaceList(handle), "Expected SetupDestroyDiskSpaceList to succeed\n");
250}
251
253{
254 HDSKSPC handle, duplicate;
255
256 SetLastError(0xdeadbeef);
257 duplicate = SetupDuplicateDiskSpaceListW(NULL, NULL, 0, 0);
258 if (!duplicate && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
259 {
260 win_skip("SetupDuplicateDiskSpaceListW is not available\n");
261 return;
262 }
263 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
265 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n", GetLastError());
266
267 SetLastError(0xdeadbeef);
268 duplicate = SetupDuplicateDiskSpaceListW(NULL, (void *)0xdeadbeef, 0, 0);
269 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
271 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
272
273 SetLastError(0xdeadbeef);
274 duplicate = SetupDuplicateDiskSpaceListW(NULL, NULL, 0xdeadbeef, 0);
275 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
277 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
278
279 SetLastError(0xdeadbeef);
280 duplicate = SetupDuplicateDiskSpaceListW(NULL, NULL, 0, ~0U);
281 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
283 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
284
286 ok(handle != NULL,
287 "Expected SetupCreateDiskSpaceListW to return a valid handle, got NULL\n");
288
289 if (!handle)
290 {
291 skip("Failed to create a disk space handle\n");
292 return;
293 }
294
295 SetLastError(0xdeadbeef);
296 duplicate = SetupDuplicateDiskSpaceListW(handle, (void *)0xdeadbeef, 0, 0);
297 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
299 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
300
301 SetLastError(0xdeadbeef);
302 duplicate = SetupDuplicateDiskSpaceListW(handle, NULL, 0xdeadbeef, 0);
303 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
305 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
306
307 SetLastError(0xdeadbeef);
309 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
311 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
312
313 SetLastError(0xdeadbeef);
314 duplicate = SetupDuplicateDiskSpaceListW(handle, NULL, 0, ~0U);
315 ok(!duplicate, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
317 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
318
319 duplicate = SetupDuplicateDiskSpaceListW(handle, NULL, 0, 0);
320 ok(duplicate != NULL, "Expected SetupDuplicateDiskSpaceList to return NULL, got %p\n", duplicate);
321 ok(duplicate != handle,
322 "Expected new handle (%p) to be different from the old handle (%p)\n", duplicate, handle);
323
324 ok(SetupDestroyDiskSpaceList(duplicate), "Expected SetupDestroyDiskSpaceList to succeed\n");
325 ok(SetupDestroyDiskSpaceList(handle), "Expected SetupDestroyDiskSpaceList to succeed\n");
326}
327
329{
330 HANDLE file;
332
335 if (file == INVALID_HANDLE_VALUE) return 0;
336
337 if (!GetFileSizeEx(file, &size))
338 size.QuadPart = 0;
339
341 return size.QuadPart;
342}
343
345{
346 BOOL ret;
349 char windir[MAX_PATH];
350 char drive[3];
351 char tmp[MAX_PATH];
353
354 if (is_win9x)
355 win_skip("SetupQuerySpaceRequiredOnDriveA crashes with NULL disk space handle on Win9x\n");
356 else
357 {
358 SetLastError(0xdeadbeef);
360 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
362 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
363 GetLastError());
364
365 SetLastError(0xdeadbeef);
366 space = 0xdeadbeef;
368 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
369 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
371 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
372 GetLastError());
373
374 SetLastError(0xdeadbeef);
376 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
378 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
379 GetLastError());
380
381 SetLastError(0xdeadbeef);
382 space = 0xdeadbeef;
384 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
385 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
387 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
388 GetLastError());
389 }
390
392 ok(handle != NULL,
393 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
394
395 SetLastError(0xdeadbeef);
397 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
399 GetLastError() == ERROR_INVALID_DRIVE, /* Win9x */
400 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
401 GetLastError());
402
403 SetLastError(0xdeadbeef);
404 space = 0xdeadbeef;
406 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
407 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
409 GetLastError() == ERROR_INVALID_DRIVE, /* Win9x */
410 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
411 GetLastError());
412
413 SetLastError(0xdeadbeef);
415 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
417 "Expected GetLastError() to return ERROR_INVALID_DRIVE, got %u\n",
418 GetLastError());
419
420 SetLastError(0xdeadbeef);
421 space = 0xdeadbeef;
423 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveA to return FALSE, got %d\n", ret);
424 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
426 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
427 GetLastError());
428
430 drive[0] = windir[0]; drive[1] = windir[1]; drive[2] = 0;
431
432 snprintf(tmp, MAX_PATH, "%c:\\wine-test-should-not-exist.txt", drive[0]);
433 ret = SetupAddToDiskSpaceListA(handle, tmp, 0x100000, FILEOP_COPY, 0, 0);
434 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
435
436 space = 0;
438 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
439 ok(space == 0x100000, "Expected 0x100000 as required space, got %s\n", debugstr_longlong(space));
440
441 /* adding the same file again doesn't sum up the size */
442 ret = SetupAddToDiskSpaceListA(handle, tmp, 0x200000, FILEOP_COPY, 0, 0);
443 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
444
445 space = 0;
447 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
448 ok(space == 0x200000, "Expected 0x200000 as required space, got %s\n", debugstr_longlong(space));
449
450 /* the device doesn't need to exist */
451 snprintf(tmp, MAX_PATH, "F:\\wine-test-should-not-exist.txt");
452 ret = SetupAddToDiskSpaceListA(handle, tmp, 0x200000, FILEOP_COPY, 0, 0);
453 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
454
456 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
457 ok(space == 0x200000, "Expected 0x200000 as required space, got %s\n", debugstr_longlong(space));
458
459 snprintf(tmp, MAX_PATH, "F:\\wine-test-should-not-exist.txt");
460 ret = SetupAddToDiskSpaceListA(handle, tmp, 0x200000, FILEOP_DELETE, 0, 0);
461 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
462
464 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
465 ok(space == 0x200000, "Expected 0x200000 as required space, got %s\n", debugstr_longlong(space));
466
468 "Expected SetupDestroyDiskSpaceList to succeed\n");
469
471 ok(handle != NULL,
472 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
473
474 /* the real size is subtracted unless SPDSL_IGNORE_DISK is specified */
475 snprintf(tmp, MAX_PATH, "%s\\regedit.exe", windir);
476
477 size = get_file_size(tmp);
479 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
480 space = 0;
482 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
483 ok(space == 0 || broken(space == -0x5000) || broken(space == -0x7000),
484 "Expected 0x0 as required space, got %s\n", debugstr_longlong(space));
485
486 ret = SetupAddToDiskSpaceListA(handle, tmp, size + 0x100000, FILEOP_COPY, 0, 0);
487 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
489 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
490 ok(space == 0x100000 || broken(space == 0xf9000) || broken(space == 0xfb000),
491 "Expected 0x100000 as required space, got %s\n", debugstr_longlong(space));
492
493 ret = SetupAddToDiskSpaceListA(handle, tmp, size - 0x1000, FILEOP_COPY, 0, 0);
494 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
496 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
497 ok(space == -0x1000 || broken(space == -0x6000) || broken(space == -0x8000),
498 "Expected -0x1000 as required space, got %s\n", debugstr_longlong(space));
499
501 "Expected SetupDestroyDiskSpaceList to succeed\n");
502
503 /* test FILEOP_DELETE, then FILEOP_COPY */
505 ok(handle != NULL,
506 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
507
509 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
511 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
512
513 space = 0;
515 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
516 ok(space == 0 || broken(space == -0x5000) || broken(space == -0x7000),
517 "Expected 0x0 as required space, got %s\n", debugstr_longlong(space));
518
520 "Expected SetupDestroyDiskSpaceList to succeed\n");
521
522 /* test FILEOP_COPY, then FILEOP_DELETE */
524 ok(handle != NULL,
525 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
526
528 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
530 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
531
532 space = 0;
534 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
535 ok(space == 0 || broken(space == -0x5000) || broken(space == -0x7000),
536 "Expected 0x0 as required space, got %s\n", debugstr_longlong(space));
537
539 "Expected SetupDestroyDiskSpaceList to succeed\n");
540
541 /* test FILEOP_DELETE without SPDSL_IGNORE_DISK */
543 ok(handle != NULL,
544 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
545
547 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
548 space = 0;
550 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
551 ok(space <= -size, "Expected space <= -size, got %s\n", debugstr_longlong(space));
552
554 "Expected SetupDestroyDiskSpaceList to succeed\n");
555
556 /* test FILEOP_COPY and FILEOP_DELETE with SPDSL_IGNORE_DISK */
558 ok(handle != NULL,
559 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
560
562 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
563 space = 0;
565 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
566 ok(space == 0, "Expected size = 0, got %s\n", debugstr_longlong(space));
567
569 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
571 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
572
573 space = 0;
575 ok(ret, "Expected SetupQuerySpaceRequiredOnDriveA to succeed\n");
576 ok(space >= size, "Expected size >= %s\n", debugstr_longlong(space));
577
579 "Expected SetupDestroyDiskSpaceList to succeed\n");
580}
581
583{
584 static const WCHAR emptyW[] = {0};
585
586 BOOL ret;
589
590 SetLastError(0xdeadbeef);
593 {
594 win_skip("SetupQuerySpaceRequiredOnDriveW is not available\n");
595 return;
596 }
597 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
599 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
600 GetLastError());
601
602 SetLastError(0xdeadbeef);
603 space = 0xdeadbeef;
605 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
606 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
608 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
609 GetLastError());
610
611 SetLastError(0xdeadbeef);
613 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
615 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
616 GetLastError());
617
618 SetLastError(0xdeadbeef);
619 space = 0xdeadbeef;
621 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
622 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
624 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n",
625 GetLastError());
626
628 ok(handle != NULL,
629 "Expected SetupCreateDiskSpaceListA to return a valid handle, got NULL\n");
630
631 SetLastError(0xdeadbeef);
633 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
635 GetLastError() == ERROR_INVALID_DRIVE, /* NT4/Win2k/XP/Win2k3 */
636 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
637 GetLastError());
638
639 SetLastError(0xdeadbeef);
640 space = 0xdeadbeef;
642 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
643 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
645 GetLastError() == ERROR_INVALID_DRIVE, /* NT4/Win2k/XP/Win2k3 */
646 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
647 GetLastError());
648
649 SetLastError(0xdeadbeef);
651 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
653 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
654 GetLastError());
655
656 SetLastError(0xdeadbeef);
657 space = 0xdeadbeef;
659 ok(!ret, "Expected SetupQuerySpaceRequiredOnDriveW to return FALSE, got %d\n", ret);
660 ok(space == 0xdeadbeef, "Expected output space parameter to be untouched\n");
662 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
663 GetLastError());
664
666 "Expected SetupDestroyDiskSpaceList to succeed\n");
667}
668
670{
672 BOOL ret;
673
674 ret = SetupAddToDiskSpaceListA(NULL, "C:\\some-file.dat", 0, FILEOP_COPY, 0, 0);
675 ok(!ret, "Expected SetupAddToDiskSpaceListA to return FALSE, got %d\n", ret);
677 "Expected GetLastError() to return ERROR_INVALID_HANDLE, got %u\n", GetLastError());
678
680 ok(handle != NULL,"Expected SetupCreateDiskSpaceListA to return a valid handle\n");
681
683 ok(ret || broken(!ret) /* >= Vista */, "Expected SetupAddToDiskSpaceListA to succeed\n");
684
685 ret = SetupAddToDiskSpaceListA(handle, "C:\\some-file.dat", -20, FILEOP_COPY, 0, 0);
686 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
687
688 ret = SetupAddToDiskSpaceListA(handle, "C:\\some-file.dat", 0, FILEOP_RENAME, 0, 0);
689 ok(!ret, "Expected SetupAddToDiskSpaceListA to return FALSE\n");
691 "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
692
694 ok(ret || broken(!ret) /* >= Vista */, "Expected SetupAddToDiskSpaceListA to succeed\n");
695
697 ok(ret || broken(!ret) /* >= Vista */, "Expected SetupAddToDiskSpaceListA to succeed\n");
698
700 "Expected SetupDestroyDiskSpaceList to succeed\n");
701}
702
704{
705 char buffer[MAX_PATH];
707 DWORD size;
708 BOOL ret;
709
711 ok(handle != NULL,"Expected SetupCreateDiskSpaceListA to return a valid handle\n");
712
714 ok(ret, "Expected SetupQueryDrivesInDiskSpaceListA to succeed\n");
715
716 size = 0;
718 ok(ret, "Expected SetupQueryDrivesInDiskSpaceListA to succeed\n");
719 ok(size == 1, "Expected size 1, got %u\n", size);
720
721 ret = SetupAddToDiskSpaceListA(handle, "F:\\random-file.dat", 0, FILEOP_COPY, 0, 0);
722 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
723
724 ret = SetupAddToDiskSpaceListA(handle, "G:\\random-file.dat", 0, FILEOP_COPY, 0, 0);
725 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
726
727 ret = SetupAddToDiskSpaceListA(handle, "G:\\random-file2.dat", 0, FILEOP_COPY, 0, 0);
728 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
729
730 ret = SetupAddToDiskSpaceListA(handle, "X:\\random-file.dat", 0, FILEOP_COPY, 0, 0);
731 ok(ret, "Expected SetupAddToDiskSpaceListA to succeed\n");
732
733 size = 0;
735 ok(ret, "Expected SetupQueryDrivesInDiskSpaceListA to succeed\n");
736 ok(size == 10, "Expected size 10, got %u\n", size);
737
738 size = 0;
740 ok(!ret, "Expected SetupQueryDrivesInDiskSpaceListA to fail\n");
741 ok(size == 4, "Expected size 4, got %u\n", size);
743 "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
744
745 size = 0;
747 ok(!ret, "Expected SetupQueryDrivesInDiskSpaceListA to fail\n");
748 ok(size == 7, "Expected size 7, got %u\n", size);
750 "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
751
752 size = 0;
754 ok(!ret, "Expected SetupQueryDrivesInDiskSpaceListA to fail\n");
755 ok(size == 10, "Expected size 10, got %u\n", size);
757 "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
758
759 size = 0;
760 memset(buffer, 0xff, sizeof(buffer));
762 ok(ret, "Expected SetupQueryDrivesInDiskSpaceListA to succeed\n");
763 ok(size == 10, "Expected size 10, got %u\n", size);
764 ok(!memcmp("f:\0g:\0x:\0\0", buffer, 10), "Device list does not match\n");
765
766 memset(buffer, 0xff, sizeof(buffer));
768 ok(ret, "Expected SetupQueryDrivesInDiskSpaceListA to succeed\n");
769 ok(!memcmp("f:\0g:\0x:\0\0", buffer, 10), "Device list does not match\n");
770
772 "Expected SetupDestroyDiskSpaceList to succeed\n");
773}
774
776{
777 const char *dev;
779};
780
781struct section
782{
783 const char *name;
787};
788
789static const struct
790{
791 const char *data;
792 struct section sections[2];
793 const char *devices;
796}
797section_test[] =
798{
799 /* 0 */
800 {STD_HEADER "[a]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
801 {{"a", FILEOP_COPY, TRUE, 0}, {NULL, 0, TRUE, 0}},
802 "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
803 /* 1 */
804 {STD_HEADER "[a]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
805 {{"a", FILEOP_DELETE, TRUE, 0}, {NULL, 0, TRUE, 0}},
806 "c:\00", sizeof("c:\00"), {{"c:", 0}, {NULL, 0}}},
807 /* 2 */
808 {STD_HEADER "[a]\ntest,,,\n\r\n",
809 {{"a", FILEOP_COPY, FALSE, ERROR_LINE_NOT_FOUND}, {NULL, 0, TRUE, 0}},
810 "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
811 /* 3 */
812 {STD_HEADER "[a]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\n[DestinationDirs]\nDefaultDestDir=-1,F:\\test\r\n",
813 {{"a", FILEOP_COPY, TRUE, 0}, {NULL, 0, TRUE, 0}},
814 "f:\00", sizeof("f:\00"), {{"f:", 4096}, {NULL, 0}}},
815 /* 4 */
816 {STD_HEADER "[a]\ntest,test2,,\n[SourceDisksFiles]\ntest2=1,,4096\r\n",
817 {{"a", FILEOP_COPY, TRUE, 0}, {NULL, 0, TRUE, 0}},
818 "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
819 /* 5 */
820 {STD_HEADER "[a]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
822 "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
823 /* 6 */
824 {STD_HEADER "[a]\ntest,,,\n[b]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
825 {{"a", FILEOP_COPY, TRUE, 0}, {"b", FILEOP_COPY, TRUE, 0}},
826 "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
827 /* 7 */
828 {STD_HEADER "[a]\ntest,,,\n[b]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\n[DestinationDirs]\nb=-1,F:\\test\r\n",
829 {{"a", FILEOP_COPY, TRUE, 0}, {"b", FILEOP_COPY, TRUE, 0}},
830 "c:\00f:\00", sizeof("c:\00f:\00"), {{"c:", 4096}, {"f:", 4096}}},
831 /* 8 */
832 {STD_HEADER "[a]\ntest,test1,,\n[b]\ntest,test2,,\n[SourceDisksFiles]\ntest1=1,,4096\ntest2=1,,8192\r\n",
833 {{"a", FILEOP_COPY, TRUE, 0}, {"b", FILEOP_COPY, TRUE, 0}},
834 "c:\00", sizeof("c:\00"), {{"c:", 8192}, {NULL, 0}}},
835 /* 9 */
836 {STD_HEADER "[a]\ntest1,test,,\n[b]\ntest2,test,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
837 {{"a", FILEOP_COPY, TRUE, 0}, {"b", FILEOP_COPY, TRUE, 0}},
838 "c:\00", sizeof("c:\00"), {{"c:", 8192}, {NULL, 0}}},
840
842{
843 char tmp[MAX_PATH];
844 char tmpfilename[MAX_PATH];
845 char buffer[MAX_PATH];
846 HDSKSPC diskspace;
849 BOOL ret;
850 int i, j;
851 HINF inf;
852
853 if (!GetTempPathA(MAX_PATH, tmp))
854 {
855 win_skip("GetTempPath failed with error %d\n", GetLastError());
856 return;
857 }
858
859 if (!GetTempFileNameA(tmp, "inftest", 0, tmpfilename))
860 {
861 win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
862 return;
863 }
864
865 inf = inf_open_file_content(tmpfilename, STD_HEADER "[a]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n", &err_line);
866 ok(!!inf, "Failed to open inf file (%d, line %d)\n", GetLastError(), err_line);
867
869 ok(diskspace != NULL,"Expected SetupCreateDiskSpaceListA to return a valid handle\n");
870
871 ret = SetupAddSectionToDiskSpaceListA(diskspace, NULL, NULL, "a", FILEOP_COPY, 0, 0);
872 ok(!ret, "Expected SetupAddSectionToDiskSpaceListA to fail\n");
873 ok(GetLastError() == ERROR_SECTION_NOT_FOUND, "Expected ERROR_SECTION_NOT_FOUND as error, got %u\n",
874 GetLastError());
875
877 ok(!ret, "Expected SetupAddSectionToDiskSpaceListA to fail\n");
878 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE as error, got %u\n",
879 GetLastError());
880
882 ok(!ret, "Expected SetupAddSectionToDiskSpaceListA to fail\n");
883 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE as error, got %u\n",
884 GetLastError());
885
886 ret = SetupAddSectionToDiskSpaceListA(diskspace, inf, NULL, "a", 0, 0, 0);
887 ok(ret, "Expected SetupAddSectionToDiskSpaceListA to succeed (%u)\n", GetLastError());
888
889 ok(SetupDestroyDiskSpaceList(diskspace),
890 "Expected SetupDestroyDiskSpaceList to succeed\n");
891
892 for (i = 0; i < sizeof(section_test) / sizeof(section_test[0]); i++)
893 {
894 err_line = 0;
895
897 ok(!!inf, "test %d: Failed to open inf file (%d, line %d)\n", i, GetLastError(), err_line);
898 if (!inf) continue;
899
901 ok(diskspace != NULL, "Expected SetupCreateDiskSpaceListA to return a valid handle\n");
902
903 for (j = 0; j < 2; j++)
904 {
905 const struct section *section = &section_test[i].sections[j];
906 if (!section->name)
907 continue;
908
909 SetLastError(0xdeadbeef);
911 if (section->result)
912 ok(ret, "test %d: Expected adding section %d to succeed (%u)\n", i, j, GetLastError());
913 else
914 {
915 ok(!ret, "test %d: Expected adding section %d to fail\n", i, j);
916 ok(GetLastError() == section->error_code, "test %d: Expected %u as error, got %u\n",
918 }
919 }
920
921 memset(buffer, 0x0, sizeof(buffer));
922 ret = SetupQueryDrivesInDiskSpaceListA(diskspace, buffer, sizeof(buffer), NULL);
923 ok(ret, "test %d: Expected SetupQueryDrivesInDiskSpaceListA to succeed (%u)\n", i, GetLastError());
925 "test %d: Device list (%s) does not match\n", i, buffer);
926
927 for (j = 0; j < 2; j++)
928 {
929 const struct device_usage *usage = &section_test[i].usage[j];
930 if (!usage->dev)
931 continue;
932
933 space = 0;
934 ret = SetupQuerySpaceRequiredOnDriveA(diskspace, usage->dev, &space, NULL, 0);
935 ok(ret, "test %d: Expected SetupQuerySpaceRequiredOnDriveA to succeed for device %s (%u)\n",
936 i, usage->dev, GetLastError());
937 ok(space == usage->usage, "test %d: Expected size %u for device %s, got %u\n",
938 i, (DWORD)usage->usage, usage->dev, (DWORD)space);
939 }
940
941 ok(SetupDestroyDiskSpaceList(diskspace),
942 "Expected SetupDestroyDiskSpaceList to succeed\n");
943
945 }
946
948}
949
951{
952 const char *name;
955};
956
957static const struct
958{
959 const char *data;
960 struct section_i sections[2];
961 const char *devices;
962 int device_length;
963 struct device_usage usage[2];
964}
966{
967 /* 0 */
968 {STD_HEADER "[a.Install]\nCopyFiles=a.CopyFiles\n"
969 "[a.CopyFiles]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
970 {{"a.Install", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
971 /* 1 */
972 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles\n"
973 "[a.CopyFiles]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
974 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
975 /* 2 */
976 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles\nCopyFiles=a.CopyFiles2\n"
977 "[a.CopyFiles]\ntest,,,\n[a.CopyFiles2]\ntest2,,,\n"
978 "[SourceDisksFiles]\ntest=1,,4096\ntest2=1,,4096\r\n",
979 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 8192}, {NULL, 0}}},
980 /* 3 */
981 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles,a.CopyFiles2\n"
982 "[a.CopyFiles]\ntest,,,\n[a.CopyFiles2]\ntest2,,,\n"
983 "[SourceDisksFiles]\ntest=1,,4096\ntest2=1,,4096\r\n",
984 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 8192}, {NULL, 0}}},
985 /* 4 */
986 {STD_HEADER "[a]\r\n",
987 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
988 /* 5 */
989 {STD_HEADER "[a]\nDelFiles=a.DelFiles\n"
990 "[a.nDelFiles]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
991 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
992 /* 6 */
993 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles\nDelFiles=a.DelFiles\n"
994 "[a.CopyFiles]\ntest,,,\n[a.DelFiles]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
995 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
996 /* 7 */
997 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles\n[b]\nDelFiles=b.DelFiles\n"
998 "[a.CopyFiles]\ntest,,,\n[b.DelFiles]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n",
999 {{"a", TRUE, 0}, {"b", TRUE, 0}}, "c:\00", sizeof("c:\00"), {{"c:", 4096}, {NULL, 0}}},
1000 /* 7 */
1001 {STD_HEADER "[a]\nCopyFiles=\r\n",
1002 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
1003 /* 8 */
1004 {STD_HEADER "[a]\nCopyFiles=something\r\n",
1005 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "", sizeof(""), {{NULL, 0}, {NULL, 0}}},
1006 /* 9 */
1007 {STD_HEADER "[a]\nCopyFiles=a.CopyFiles,b.CopyFiles\n[a.CopyFiles]\ntest,,,\n[b.CopyFiles]\ntest,,,\n"
1008 "[SourceDisksFiles]\ntest=1,,4096\n[DestinationDirs]\nb.CopyFiles=-1,F:\\test\r\n",
1009 {{"a", TRUE, 0}, {NULL, TRUE, 0}}, "c:\00f:\00", sizeof("c:\00f:\00"), {{"c:", 4096}, {"f:", 4096}}},
1011
1013{
1014 char tmp[MAX_PATH];
1015 char tmpfilename[MAX_PATH];
1016 char buffer[MAX_PATH];
1017 HDSKSPC diskspace;
1019 UINT err_line;
1020 BOOL ret;
1021 int i, j;
1022 HINF inf;
1023
1024 if (!GetTempPathA(MAX_PATH, tmp))
1025 {
1026 win_skip("GetTempPath failed with error %d\n", GetLastError());
1027 return;
1028 }
1029
1030 if (!GetTempFileNameA(tmp, "inftest", 0, tmpfilename))
1031 {
1032 win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
1033 return;
1034 }
1035
1036 inf = inf_open_file_content(tmpfilename, STD_HEADER "[a]\nCopyFiles=b\n[b]\ntest,,,\n[SourceDisksFiles]\ntest=1,,4096\r\n", &err_line);
1037 ok(!!inf, "Failed to open inf file (%d, line %d)\n", GetLastError(), err_line);
1038
1040 ok(diskspace != NULL,"Expected SetupCreateDiskSpaceListA to return a valid handle\n");
1041
1042 ret = SetupAddInstallSectionToDiskSpaceListA(diskspace, NULL, NULL, "a", 0, 0);
1043 ok(ret, "Expected SetupAddInstallSectionToDiskSpaceListA to succeed\n");
1044
1046 ok(!ret, "Expected SetupAddInstallSectionToDiskSpaceListA to fail\n");
1047 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE as error, got %u\n",
1048 GetLastError());
1049
1050 ret = SetupAddInstallSectionToDiskSpaceListA(diskspace, inf, NULL, NULL, 0, 0);
1051 ok(!ret || broken(ret), "Expected SetupAddSectionToDiskSpaceListA to fail\n");
1053 "Expected ERROR_INVALID_PARAMETER as error, got %u\n", GetLastError());
1054
1055 ret = SetupAddInstallSectionToDiskSpaceListA(diskspace, inf, NULL, "", 0, 0);
1056 ok(ret, "Expected SetupAddInstallSectionToDiskSpaceListA to succeed (%u)\n", GetLastError());
1057
1058 ok(SetupDestroyDiskSpaceList(diskspace),
1059 "Expected SetupDestroyDiskSpaceList to succeed\n");
1060
1061 for (i = 0; i < sizeof(section_test_i) / sizeof(section_test_i[0]); i++)
1062 {
1063 err_line = 0;
1064
1066 ok(!!inf, "test %d: Failed to open inf file (%d, line %d)\n", i, GetLastError(), err_line);
1067 if (!inf) continue;
1068
1070 ok(diskspace != NULL,"Expected SetupCreateDiskSpaceListA to return a valid handle\n");
1071
1072 for (j = 0; j < 2; j++)
1073 {
1074 const struct section_i *section = &section_test_i[i].sections[j];
1075 if (!section->name)
1076 continue;
1077
1078 SetLastError(0xdeadbeef);
1079 ret = SetupAddInstallSectionToDiskSpaceListA(diskspace, inf, NULL, section->name, 0, 0);
1080 if (section->result)
1081 ok(ret, "test %d: Expected adding section %d to succeed (%u)\n", i, j, GetLastError());
1082 else
1083 {
1084 ok(!ret, "test %d: Expected adding section %d to fail\n", i, j);
1085 ok(GetLastError() == section->error_code, "test %d: Expected %u as error, got %u\n",
1087 }
1088 }
1089
1090 memset(buffer, 0x0, sizeof(buffer));
1091 ret = SetupQueryDrivesInDiskSpaceListA(diskspace, buffer, sizeof(buffer), NULL);
1092 ok(ret, "test %d: Expected SetupQueryDrivesInDiskSpaceListA to succeed (%u)\n", i, GetLastError());
1094 "test %d: Device list (%s) does not match\n", i, buffer);
1095
1096 for (j = 0; j < 2; j++)
1097 {
1098 const struct device_usage *usage = &section_test_i[i].usage[j];
1099 if (!usage->dev)
1100 continue;
1101
1102 space = 0;
1103 ret = SetupQuerySpaceRequiredOnDriveA(diskspace, usage->dev, &space, NULL, 0);
1104 ok(ret, "test %d: Expected SetupQuerySpaceRequiredOnDriveA to succeed for device %s (%u)\n",
1105 i, usage->dev, GetLastError());
1106 ok(space == usage->usage, "test %d: Expected size %u for device %s, got %u\n",
1107 i, (DWORD)usage->usage, usage->dev, (DWORD)space);
1108 }
1109
1110 ok(SetupDestroyDiskSpaceList(diskspace),
1111 "Expected SetupDestroyDiskSpaceList to succeed\n");
1112
1113 SetupCloseInfFile(inf);
1114 }
1115
1117}
1118
1119START_TEST(diskspace)
1120{
1121 is_win9x = !SetupCreateDiskSpaceListW((void *)0xdeadbeef, 0xdeadbeef, 0) &&
1133}
#define broken(x)
Definition: _sntprintf.h:21
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define U(x)
Definition: wordpad.c:45
w ll
Definition: byte_order.h:167
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define GetFileSizeEx
Definition: compat.h:757
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:97
HDSKSPC WINAPI SetupDuplicateDiskSpaceListA(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:128
BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, LPCSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:201
BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace, LPCWSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:147
HDSKSPC WINAPI SetupCreateDiskSpaceListW(PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:38
BOOL WINAPI SetupAddToDiskSpaceListA(HDSKSPC diskspace, PCSTR targetfile, LONGLONG filesize, UINT operation, PVOID reserved1, UINT reserved2)
Definition: diskspace.c:255
BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
Definition: diskspace.c:245
HDSKSPC WINAPI SetupCreateDiskSpaceListA(PVOID Reserved1, DWORD Reserved2, UINT Flags)
Definition: diskspace.c:89
BOOL WINAPI SetupAddInstallSectionToDiskSpaceListA(HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, LPCSTR SectionName, PVOID Reserved1, UINT Reserved2)
Definition: diskspace.c:136
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define FILEOP_COPY
Definition: fileqsup.h:42
#define FILEOP_RENAME
Definition: fileqsup.h:43
#define FILEOP_DELETE
Definition: fileqsup.h:44
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static const WCHAR emptyW[]
Definition: navigate.c:40
#define INF_STYLE_WIN4
Definition: infsupp.h:41
char string[160]
Definition: util.h:11
#define CREATE_ALWAYS
Definition: disk.h:72
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static DWORD get_file_size(void)
Definition: integrity.c:149
int device_length
Definition: diskspace.c:794
static HINF inf_open_file_content(const char *tmpfilename, const char *data, UINT *err_line)
Definition: diskspace.c:48
static void test_SetupDuplicateDiskSpaceListW(void)
Definition: diskspace.c:252
static const struct @1689 section_test[]
struct section sections[2]
Definition: diskspace.c:792
static void test_SetupCreateDiskSpaceListA(void)
Definition: diskspace.c:59
#define STD_HEADER
Definition: diskspace.c:35
static void test_SetupAddSectionToDiskSpaceListA(void)
Definition: diskspace.c:841
static void test_SetupQuerySpaceRequiredOnDriveW(void)
Definition: diskspace.c:582
const char * devices
Definition: diskspace.c:793
const char * data
Definition: diskspace.c:791
static const struct @1690 section_test_i[]
static const char * debugstr_longlong(ULONGLONG ll)
Definition: diskspace.c:37
static BOOL is_win9x
Definition: diskspace.c:33
static void test_SetupCreateDiskSpaceListW(void)
Definition: diskspace.c:115
static void test_SetupQueryDrivesInDiskSpaceListA(void)
Definition: diskspace.c:703
static void test_SetupDuplicateDiskSpaceListA(void)
Definition: diskspace.c:176
static void test_SetupAddInstallSectionToDiskSpaceListA(void)
Definition: diskspace.c:1012
static void test_SetupQuerySpaceRequiredOnDriveA(void)
Definition: diskspace.c:344
static void test_SetupAddToDiskSpaceListA(void)
Definition: diskspace.c:669
static const char tmpfilename[]
Definition: parser.c:49
UINT err_line
Definition: parser.c:106
unsigned int UINT
Definition: ndis.h:50
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define win_skip
Definition: test.h:160
#define memset(x, y, z)
Definition: compat.h:39
#define SPDSL_IGNORE_DISK
Definition: setupapi.h:543
WINSETUPAPI BOOL WINAPI SetupQueryDrivesInDiskSpaceListA(_In_ HDSKSPC DiskSpace, _Out_writes_opt_(ReturnBufferSize) PSTR ReturnBuffer, _In_ DWORD ReturnBufferSize, _Out_opt_ PDWORD RequiredSize)
#define ERROR_SECTION_NOT_FOUND
Definition: setupapi.h:293
WINSETUPAPI BOOL WINAPI SetupAddSectionToDiskSpaceListA(_In_ HDSKSPC, _In_ HINF, _In_opt_ HINF, _In_ PCSTR, _In_ UINT, _Reserved_ PVOID, _Reserved_ UINT)
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:294
LONGLONG usage
Definition: diskspace.c:778
const char * dev
Definition: diskspace.c:777
Definition: fci.c:127
const char * name
Definition: diskspace.c:952
DWORD error_code
Definition: diskspace.c:954
BOOL result
Definition: diskspace.c:953
Definition: parser.c:56
const WCHAR * name
Definition: parser.c:57
const char * name
Definition: diskspace.c:783
DWORD error_code
Definition: diskspace.c:786
UINT fileop
Definition: diskspace.c:784
BOOL result
Definition: diskspace.c:785
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_DRIVE
Definition: winerror.h:118
#define snprintf
Definition: wintirpc.h:48
__wchar_t WCHAR
Definition: xmlstorage.h:180