Checking an empty CDROM drive

2009-01-26 Thread Paul Vriens
Hi,

I'm trying to come up with some test to show that GetDriveType returns 
DRIVE_CDROM regardless whether there is or isn't a CD mounted.

I have the following:

diff --git a/dlls/kernel32/tests/drive.c b/dlls/kernel32/tests/drive.c
index a94cbdf..53b0262 100644
--- a/dlls/kernel32/tests/drive.c
+++ b/dlls/kernel32/tests/drive.c
@@ -46,6 +46,24 @@ static void test_GetDriveTypeA(void)
 GetDriveTypeA should return DRIVE_NO_ROOT_DIR for inexistent 
drive %c: but not %u\n,
 drive[0], type);

+/* Check if type is still DRIVE_CDROM even when no CD is mounted */
+if (type == 5)
+{
+DWORD attrs;
+
+SetLastError(0xdeadbeef);
+attrs = GetFileAttributesA(drive);
+if (attrs == INVALID_FILE_ATTRIBUTES)
+{
+trace(Unmounted CDROM with type DRIVE_CDROM\n);
+ok(GetLastError() == ERROR_NOT_READY,
+   Expected ERROR_NOT_READY for an unmounted CDROM\n);
+}
+else
+   ok((attrs  FILE_ATTRIBUTE_DIRECTORY) == 
FILE_ATTRIBUTE_DIRECTORY,
+  Expected FILE_ATTRIBUTE_DIRECTORY for a mounted CDROM\n);
+}
+
  logical_drives = 1;
  }
  }

The idea however is to show that Wine is wrong in returning DRIVE_NO_ROOT_DIR 
for an unmounted CD. The test above of course doesn't show that, it only proves 
that Windows does it this way.

(All is related to bug http://bugs.winehq.org/show_bug.cgi?id=16592)

-- 
Cheers,

Paul.




Re: Checking an empty CDROM drive

2009-01-26 Thread Paul Vriens
Paul Vriens wrote:
 Hi,
 
 I'm trying to come up with some test to show that GetDriveType returns 
 DRIVE_CDROM regardless whether there is or isn't a CD mounted.
 
 I have the following:
 
 diff --git a/dlls/kernel32/tests/drive.c b/dlls/kernel32/tests/drive.c
 index a94cbdf..53b0262 100644
 --- a/dlls/kernel32/tests/drive.c
 +++ b/dlls/kernel32/tests/drive.c
 @@ -46,6 +46,24 @@ static void test_GetDriveTypeA(void)
 GetDriveTypeA should return DRIVE_NO_ROOT_DIR for 
 inexistent drive %c: but not %u\n,
 drive[0], type);
 
 +/* Check if type is still DRIVE_CDROM even when no CD is 
 mounted */
 +if (type == 5)
 +{
 +DWORD attrs;
 +
 +SetLastError(0xdeadbeef);
 +attrs = GetFileAttributesA(drive);
 +if (attrs == INVALID_FILE_ATTRIBUTES)
 +{
 +trace(Unmounted CDROM with type DRIVE_CDROM\n);
 +ok(GetLastError() == ERROR_NOT_READY,
 +   Expected ERROR_NOT_READY for an unmounted CDROM\n);
 +}
 +else
 +   ok((attrs  FILE_ATTRIBUTE_DIRECTORY) == 
 FILE_ATTRIBUTE_DIRECTORY,
 +  Expected FILE_ATTRIBUTE_DIRECTORY for a mounted 
 CDROM\n);
 +}
 +
  logical_drives = 1;
  }
  }
 
 The idea however is to show that Wine is wrong in returning 
 DRIVE_NO_ROOT_DIR for an unmounted CD. The test above of course doesn't 
 show that, it only proves that Windows does it this way.
 
 (All is related to bug http://bugs.winehq.org/show_bug.cgi?id=16592)
 
Oh, and the same is true (of course) for floppy drives (GetDriveType should 
always return DRIVE_REMOVABLE).

-- 
Cheers,

Paul.