From 7c27a969973d2b54215be7906bf465239d15a260 Mon Sep 17 00:00:00 2001 From: Alexandre Goujon Date: Wed, 11 Jul 2012 22:26:48 +0200 Subject: [PATCH] kernel32/tests: Add a helper to test CDROM ioctl. --- dlls/kernel32/tests/volume.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 2755af5a106..b459ba6b178 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -730,6 +730,48 @@ static void test_GetVolumePathNamesForVolumeNameW(void) ok(error == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND got %u\n", error); } +static void test_cdrom_ioctl(void) +{ + char drive_letter, drive_path[] = "A:\\", drive_full_path[] = "\\\\.\\A:"; + DWORD bitmask; + HANDLE handle; + + bitmask = GetLogicalDrives(); + if(!bitmask) + { + trace("GetLogicalDrives failed : %u\n", GetLastError()); + return; + } + + for(drive_letter='A'; drive_letter<='Z'; drive_letter++) + { + if(!(bitmask & (1 << (drive_letter-'A') ))) + continue; + + drive_path[0] = drive_letter; + if(GetDriveTypeA(drive_path) != DRIVE_CDROM) + { + trace("Skipping %c:, not a CDROM drive.\n", drive_letter); + continue; + } + + trace("Testing with %c:\n", drive_letter); + + drive_full_path[4] = drive_letter; + handle = CreateFileA(drive_full_path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); + if(handle == INVALID_HANDLE_VALUE) + { + trace("Failed to open the device : %u\n", GetLastError()); + continue; + } + + /* Add your tests here */ + + CloseHandle(handle); + } + +} + START_TEST(volume) { hdll = GetModuleHandleA("kernel32.dll"); @@ -756,4 +798,5 @@ START_TEST(volume) test_disk_extents(); test_GetVolumePathNamesForVolumeNameA(); test_GetVolumePathNamesForVolumeNameW(); + test_cdrom_ioctl(); } -- 2.11.4.GIT