On Fri Aug 26 17:15:03 2022 +0000, **** wrote:
Zebediah Figura replied on the mailing list:
On 8/25/22 08:07, Joel Holdsworth wrote: > + > + if (pFindFirstVolumeA) { > + handle = pFindFirstVolumeA(volume_guid, MAX_PATH); > + ok(handle != INVALID_HANDLE_VALUE, "FindFirstVolumeA error\n"); > + do { > + ret = GetDiskFreeSpaceA(volume_guid, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters); > + if (!ret) > + /* GetDiskFreeSpaceA() should succeed, but it can fail with too many > + different GetLastError() results to be usable for an ok() */ > + trace("GetDiskFreeSpaceA(%s) failed with %ld\n", volume_guid, GetLastError()); If it should succeed, don't we want ok(ret == TRUE, ...); or under what circumstances can this actually fail? > + } while (pFindNextVolumeA(handle, volume_guid, MAX_PATH)); > + pFindVolumeClose(handle); > + } > } ... > START_TEST(drive) > { > HANDLE hkernel32 = GetModuleHandleA("kernel32"); > pGetDiskFreeSpaceExA = (void *) GetProcAddress(hkernel32, "GetDiskFreeSpaceExA"); > + pFindFirstVolumeA = (void *) GetProcAddress(hkernel32, "FindFirstVolumeA"); > + pFindFirstVolumeW = (void *) GetProcAddress(hkernel32, "FindFirstVolumeW"); > + pFindNextVolumeA = (void *) GetProcAddress(hkernel32, "FindNextVolumeA"); > + pFindNextVolumeW = (void *) GetProcAddress(hkernel32, "FindNextVolumeW"); > + pFindVolumeClose = (void *) GetProcAddress(hkernel32, "FindVolumeClose"); > > test_GetDriveTypeA(); > test_GetDriveTypeW(); These are available since at least XP; I think we can link to them directly.
The tracing of `GetDiskFreeSpaceA` is copy-pasted from the code further up in the test, where the function is tested with DOS paths.
Stepping back... what do we want this test to look like? `GetDiskFreeSpaceA` can legitimately fail for a variety of reasons, which is why other parts of the unit test stop short of doing `ok(ret == TRUE, ...)`. In similar fashion, this test code simply gets all the drive NT GUID paths (which come from `mountmgr.sys`), and then verifies that `mountmgr.sys` can cope with `FileFsSizeInfo` queries on the paths it listed out.
So it seemed to me, the best I can do is exercise the API, without checking for errors.
Thanks for the feedback on `GetProcAddress`