kernel32/tests: Typo fixes.
[wine/multimedia.git] / dlls / kernel32 / tests / volume.c
blobf52c592a01ed45a3f3bed51c3e12ec98f07ab96e
1 /*
2 * Unit test suite for volume functions
4 * Copyright 2006 Stefan Leichter
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.
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.
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
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include <stdio.h>
25 static HINSTANCE hdll;
26 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
27 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
28 static HANDLE (WINAPI *pFindFirstVolumeA)(LPSTR,DWORD);
29 static BOOL (WINAPI *pFindNextVolumeA)(HANDLE,LPSTR,DWORD);
30 static BOOL (WINAPI *pFindVolumeClose)(HANDLE);
31 static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
32 static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
33 static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
35 /* ############################### */
37 static void test_query_dos_deviceA(void)
39 char drivestr[] = "a:";
40 char *p, *buffer, buffer2[2000];
41 DWORD ret, ret2, buflen=32768;
42 BOOL iswin9x, found = FALSE;
44 buffer = HeapAlloc( GetProcessHeap(), 0, buflen );
45 SetLastError(0xdeadbeef);
46 ret = QueryDosDeviceA( NULL, buffer, buflen );
47 iswin9x = !ret && (GetLastError() == ERROR_INVALID_PARAMETER /* win98 */
48 || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED /* win95*/);
49 ok((ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || broken(iswin9x),
50 "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
52 if (ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
53 p = buffer;
54 for (;;) {
55 if (!strlen(p)) break;
56 ret2 = QueryDosDeviceA( p, buffer2, sizeof(buffer2) );
57 ok(ret2, "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", p, GetLastError());
58 p += strlen(p) + 1;
59 if (ret <= (p-buffer)) break;
63 for (;drivestr[0] <= 'z'; drivestr[0]++) {
64 /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */
65 ret = QueryDosDeviceA( drivestr, buffer, buflen - 1);
66 /* fails for all drives in win9x */
67 ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND || broken(!ret && iswin9x),
68 "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", drivestr, GetLastError());
69 if(ret) {
70 for (p = buffer; *p; p++) *p = toupper(*p);
71 if (strstr(buffer, "HARDDISK") || strstr(buffer, "RAMDISK")) found = TRUE;
74 ok(found ^ iswin9x, "expected at least one devicename to contain HARDDISK or RAMDISK except on win9x\n");
75 HeapFree( GetProcessHeap(), 0, buffer );
78 static void test_FindFirstVolume(void)
80 char volume[51];
81 HANDLE handle;
83 /* not present before w2k */
84 if (!pFindFirstVolumeA) {
85 win_skip("FindFirstVolumeA not found\n");
86 return;
89 handle = pFindFirstVolumeA( volume, 0 );
90 ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
91 ok( GetLastError() == ERROR_MORE_DATA || /* XP */
92 GetLastError() == ERROR_FILENAME_EXCED_RANGE, /* Vista */
93 "wrong error %u\n", GetLastError() );
94 handle = pFindFirstVolumeA( volume, 49 );
95 ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
96 ok( GetLastError() == ERROR_FILENAME_EXCED_RANGE, "wrong error %u\n", GetLastError() );
97 handle = pFindFirstVolumeA( volume, 51 );
98 ok( handle != INVALID_HANDLE_VALUE, "failed err %u\n", GetLastError() );
99 if (handle != INVALID_HANDLE_VALUE)
103 ok( strlen(volume) == 49, "bad volume name %s\n", volume );
104 ok( !memcmp( volume, "\\\\?\\Volume{", 11 ), "bad volume name %s\n", volume );
105 ok( !memcmp( volume + 47, "}\\", 2 ), "bad volume name %s\n", volume );
106 } while (pFindNextVolumeA( handle, volume, MAX_PATH ));
107 ok( GetLastError() == ERROR_NO_MORE_FILES, "wrong error %u\n", GetLastError() );
108 pFindVolumeClose( handle );
112 static void test_GetVolumeNameForVolumeMountPointA(void)
114 BOOL ret;
115 char volume[MAX_PATH], path[] = "c:\\";
116 DWORD len = sizeof(volume), reti;
117 char temp_path[MAX_PATH];
119 /* not present before w2k */
120 if (!pGetVolumeNameForVolumeMountPointA) {
121 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
122 return;
125 reti = GetTempPathA(MAX_PATH, temp_path);
126 ok(reti != 0, "GetTempPathA error %d\n", GetLastError());
127 ok(reti < MAX_PATH, "temp path should fit into MAX_PATH\n");
129 ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0);
130 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
131 ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
132 GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
133 "wrong error, last=%d\n", GetLastError());
135 if (0) { /* these crash on XP */
136 ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len);
137 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
139 ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len);
140 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
143 ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
144 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
145 ok(!strncmp( volume, "\\\\?\\Volume{", 11),
146 "GetVolumeNameForVolumeMountPointA failed to return valid string <%s>\n",
147 volume);
149 /* test with too small buffer */
150 ret = pGetVolumeNameForVolumeMountPointA(path, volume, 10);
151 ok(ret == FALSE && GetLastError() == ERROR_FILENAME_EXCED_RANGE,
152 "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n",
153 GetLastError());
155 /* Try on a arbitrary directory */
156 /* On FAT filesystems it seems that GetLastError() is set to
157 ERROR_INVALID_FUNCTION. */
158 ret = pGetVolumeNameForVolumeMountPointA(temp_path, volume, len);
159 ok(ret == FALSE && (GetLastError() == ERROR_NOT_A_REPARSE_POINT ||
160 GetLastError() == ERROR_INVALID_FUNCTION),
161 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
162 temp_path, GetLastError());
164 /* Try on a nonexistent dos drive */
165 path[2] = 0;
166 for (;path[0] <= 'z'; path[0]++) {
167 ret = QueryDosDeviceA( path, volume, len);
168 if(!ret) break;
170 if (path[0] <= 'z')
172 path[2] = '\\';
173 ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
174 ok(ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND,
175 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
176 path, GetLastError());
178 /* Try without trailing \ and on a nonexistent dos drive */
179 path[2] = 0;
180 ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
181 ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
182 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
183 path, GetLastError());
187 static void test_GetVolumeNameForVolumeMountPointW(void)
189 BOOL ret;
190 WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
191 DWORD len = sizeof(volume) / sizeof(WCHAR);
193 /* not present before w2k */
194 if (!pGetVolumeNameForVolumeMountPointW) {
195 win_skip("GetVolumeNameForVolumeMountPointW not found\n");
196 return;
199 ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0);
200 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
201 ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
202 GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
203 "wrong error, last=%d\n", GetLastError());
205 if (0) { /* these crash on XP */
206 ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len);
207 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
209 ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len);
210 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
213 ret = pGetVolumeNameForVolumeMountPointW(path, volume, len);
214 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
217 static void test_GetLogicalDriveStringsA(void)
219 UINT size, size2;
220 char *buf, *ptr;
222 ok( pGetLogicalDriveStringsA != NULL, "GetLogicalDriveStringsA not available\n");
223 if(!pGetLogicalDriveStringsA) {
224 return;
227 size = pGetLogicalDriveStringsA(0, NULL);
228 ok(size%4 == 1, "size = %d\n", size);
230 buf = HeapAlloc(GetProcessHeap(), 0, size);
232 *buf = 0;
233 size2 = pGetLogicalDriveStringsA(2, buf);
234 ok(size2 == size, "size2 = %d\n", size2);
235 ok(!*buf, "buf changed\n");
237 size2 = pGetLogicalDriveStringsA(size, buf);
238 ok(size2 == size-1, "size2 = %d\n", size2);
240 for(ptr = buf; ptr < buf+size2; ptr += 4) {
241 ok(('A' <= *ptr && *ptr <= 'Z') ||
242 (broken('a' <= *ptr && *ptr <= 'z')), /* Win9x and WinMe */
243 "device name '%c' is not uppercase\n", *ptr);
244 ok(ptr[1] == ':', "ptr[1] = %c, expected ':'\n", ptr[1]);
245 ok(ptr[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr[2]);
246 ok(!ptr[3], "ptr[3] = %c expected nullbyte\n", ptr[3]);
248 ok(!*ptr, "buf[size2] is not nullbyte\n");
250 HeapFree(GetProcessHeap(), 0, buf);
253 static void test_GetLogicalDriveStringsW(void)
255 UINT size, size2;
256 WCHAR *buf, *ptr;
258 ok( pGetLogicalDriveStringsW != NULL, "GetLogicalDriveStringsW not available\n");
259 if(!pGetLogicalDriveStringsW) {
260 return;
263 SetLastError(0xdeadbeef);
264 size = pGetLogicalDriveStringsW(0, NULL);
265 if (size == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
266 win_skip("GetLogicalDriveStringsW not implemented\n");
267 return;
269 ok(size%4 == 1, "size = %d\n", size);
271 buf = HeapAlloc(GetProcessHeap(), 0, size*sizeof(WCHAR));
273 *buf = 0;
274 size2 = pGetLogicalDriveStringsW(2, buf);
275 ok(size2 == size, "size2 = %d\n", size2);
276 ok(!*buf, "buf changed\n");
278 size2 = pGetLogicalDriveStringsW(size, buf);
279 ok(size2 == size-1, "size2 = %d\n", size2);
281 for(ptr = buf; ptr < buf+size2; ptr += 4) {
282 ok('A' <= *ptr && *ptr <= 'Z', "device name '%c' is not uppercase\n", *ptr);
283 ok(ptr[1] == ':', "ptr[1] = %c, expected ':'\n", ptr[1]);
284 ok(ptr[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr[2]);
285 ok(!ptr[3], "ptr[3] = %c expected nullbyte\n", ptr[3]);
287 ok(!*ptr, "buf[size2] is not nullbyte\n");
289 HeapFree(GetProcessHeap(), 0, buf);
292 static void test_GetVolumeInformationA(void)
294 BOOL ret;
295 UINT result;
296 char Root_Colon[]="C:";
297 char Root_Slash[]="C:\\";
298 char Root_UNC[]="\\\\?\\C:\\";
299 char volume[MAX_PATH+1];
300 DWORD vol_name_size=MAX_PATH+1, vol_serial_num=-1, max_comp_len=0, fs_flags=0, fs_name_len=MAX_PATH+1;
301 char vol_name_buf[MAX_PATH+1], fs_name_buf[MAX_PATH+1];
302 char windowsdir[MAX_PATH+10];
303 char currentdir[MAX_PATH+1];
305 ok( pGetVolumeInformationA != NULL, "GetVolumeInformationA not found\n");
306 if(!pGetVolumeInformationA) {
307 return;
310 /* get windows drive letter and update strings for testing */
311 result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
312 ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
313 ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
314 Root_Colon[0] = windowsdir[0];
315 Root_Slash[0] = windowsdir[0];
316 Root_UNC[4] = windowsdir[0];
318 result = GetCurrentDirectory(MAX_PATH, currentdir);
319 ok(result, "GetCurrentDirectory: error %d\n", GetLastError());
320 /* Note that GetCurrentDir yields no trailing slash for subdirs */
322 /* check for NO error on no trailing \ when current dir is root dir */
323 ret = SetCurrentDirectory(Root_Slash);
324 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
325 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
326 NULL, NULL, fs_name_buf, fs_name_len);
327 todo_wine
328 ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
330 /* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
331 ret = SetCurrentDirectory(windowsdir);
332 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
333 SetLastError(0xdeadbeef);
334 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
335 NULL, NULL, fs_name_buf, fs_name_len);
336 ok(!ret && (GetLastError() == ERROR_INVALID_NAME ||
337 broken(GetLastError() == ERROR_BAD_PATHNAME/* win9x */)),
338 "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
340 /* reset current directory */
341 ret = SetCurrentDirectory(currentdir);
342 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
344 if (toupper(currentdir[0]) == toupper(windowsdir[0])) {
345 skip("Please re-run from another device than %c:\n", windowsdir[0]);
346 /* FIXME: Use GetLogicalDrives to find another device to avoid this skip. */
347 } else {
348 char Root_Env[]="=C:"; /* where MS maintains the per volume directory */
349 Root_Env[1] = windowsdir[0];
351 /* C:\windows becomes the current directory on drive C: */
352 /* Note that paths to subdirs are stored without trailing slash, like what GetCurrentDir yields. */
353 ret = SetEnvironmentVariable(Root_Env, windowsdir);
354 ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
356 ret = SetCurrentDirectory(windowsdir);
357 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
358 ret = SetCurrentDirectory(currentdir);
359 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
361 /* windows dir is current on the root drive, call fails */
362 SetLastError(0xdeadbeef);
363 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
364 NULL, NULL, fs_name_buf, fs_name_len);
365 ok(!ret && (GetLastError() == ERROR_INVALID_NAME ||
366 broken(GetLastError() == ERROR_BAD_PATHNAME/* Win9x */)),
367 "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
369 /* Try normal drive letter with trailing \ */
370 ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL,
371 NULL, NULL, fs_name_buf, fs_name_len);
372 ok(ret, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
374 ret = SetCurrentDirectory(Root_Slash);
375 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
376 ret = SetCurrentDirectory(currentdir);
377 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
379 /* windows dir is STILL CURRENT on root drive; the call fails as before, */
380 /* proving that SetCurrentDir did not remember the other drive's directory */
381 SetLastError(0xdeadbeef);
382 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
383 NULL, NULL, fs_name_buf, fs_name_len);
384 ok(!ret && (GetLastError() == ERROR_INVALID_NAME ||
385 broken(GetLastError() == ERROR_BAD_PATHNAME/* Win9x */)),
386 "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
388 /* Now C:\ becomes the current directory on drive C: */
389 ret = SetEnvironmentVariable(Root_Env, Root_Slash); /* set =C:=C:\ */
390 ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
392 /* \ is current on root drive, call succeeds */
393 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
394 NULL, NULL, fs_name_buf, fs_name_len);
395 todo_wine ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
397 /* again, SetCurrentDirectory on another drive does not matter */
398 ret = SetCurrentDirectory(Root_Slash);
399 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
400 ret = SetCurrentDirectory(currentdir);
401 ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
403 /* \ is current on root drive, call succeeds */
404 ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
405 NULL, NULL, fs_name_buf, fs_name_len);
406 todo_wine ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
409 /* try null root directory to return "root of the current directory" */
410 ret = pGetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL,
411 NULL, NULL, fs_name_buf, fs_name_len);
412 ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
414 /* Try normal drive letter with trailing \ */
415 ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size,
416 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
417 ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash, GetLastError());
419 /* try again with drive letter and the "disable parsing" prefix */
420 SetLastError(0xdeadbeef);
421 ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
422 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
423 todo_wine ok(ret || broken(!ret /* win9x */ && GetLastError()==ERROR_BAD_NETPATH),
424 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
426 /* try again with device name space */
427 Root_UNC[2] = '.';
428 SetLastError(0xdeadbeef);
429 ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
430 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
431 todo_wine ok(ret || broken(!ret /* win9x */ && GetLastError()==ERROR_BAD_NETPATH),
432 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
434 /* try again with a directory off the root - should generate error */
435 if (windowsdir[strlen(windowsdir)-1] != '\\') strcat(windowsdir, "\\");
436 SetLastError(0xdeadbeef);
437 ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
438 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
439 todo_wine ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT ||
440 broken(GetLastError()==ERROR_BAD_PATHNAME/* win9x */)),
441 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
442 /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */
443 if (windowsdir[strlen(windowsdir)-1] == '\\') windowsdir[strlen(windowsdir)-1] = 0;
444 SetLastError(0xdeadbeef);
445 ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
446 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
447 ok(!ret && (GetLastError()==ERROR_INVALID_NAME ||
448 broken(GetLastError()==ERROR_BAD_PATHNAME/* win9x */)),
449 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
451 if (!pGetVolumeNameForVolumeMountPointA) {
452 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
453 return;
455 /* get the unique volume name for the windows drive */
456 ret = pGetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH);
457 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
459 /* try again with unique volume name */
460 ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
461 &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
462 todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
465 /* Test to check that unique volume name from windows dir mount point */
466 /* matches at least one of the unique volume names returned from the */
467 /* FindFirstVolumeA/FindNextVolumeA list. */
468 static void test_enum_vols(void)
470 DWORD ret;
471 HANDLE hFind = INVALID_HANDLE_VALUE;
472 char Volume_1[MAX_PATH] = {0};
473 char Volume_2[MAX_PATH] = {0};
474 char path[] = "c:\\";
475 BOOL found = FALSE;
476 char windowsdir[MAX_PATH];
478 if (!pGetVolumeNameForVolumeMountPointA) {
479 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
480 return;
483 /*get windows drive letter and update strings for testing */
484 ret = GetWindowsDirectory( windowsdir, sizeof(windowsdir) );
485 ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
486 ok(ret != 0, "GetWindowsDirecory: error %d\n", GetLastError());
487 path[0] = windowsdir[0];
489 /* get the unique volume name for the windows drive */
490 ret = pGetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH );
491 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
492 ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1);
494 /* get first unique volume name of list */
495 hFind = pFindFirstVolumeA( Volume_2, MAX_PATH );
496 ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%u\n",
497 GetLastError());
501 /* validate correct length of unique volume name */
502 ok(strlen(Volume_2) == 49, "Find[First/Next]Volume returned wrong length name %s\n", Volume_1);
503 if (memcmp(Volume_1, Volume_2, 49) == 0)
505 found = TRUE;
506 break;
508 } while (pFindNextVolumeA( hFind, Volume_2, MAX_PATH ));
509 ok(found, "volume name %s not found by Find[First/Next]Volume\n", Volume_1);
510 pFindVolumeClose( hFind );
513 START_TEST(volume)
515 hdll = GetModuleHandleA("kernel32.dll");
516 pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA");
517 pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW");
518 pFindFirstVolumeA = (void *) GetProcAddress(hdll, "FindFirstVolumeA");
519 pFindNextVolumeA = (void *) GetProcAddress(hdll, "FindNextVolumeA");
520 pFindVolumeClose = (void *) GetProcAddress(hdll, "FindVolumeClose");
521 pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA");
522 pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
523 pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
525 test_query_dos_deviceA();
526 test_FindFirstVolume();
527 test_GetVolumeNameForVolumeMountPointA();
528 test_GetVolumeNameForVolumeMountPointW();
529 test_GetLogicalDriveStringsA();
530 test_GetLogicalDriveStringsW();
531 test_GetVolumeInformationA();
532 test_enum_vols();