2 * Unit test suite for drive functions.
4 * Copyright 2002 Dmitry Timoshkov
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/test.h"
28 void test_GetDriveTypeA(void)
30 char drive[] = "?:\\";
34 logical_drives = GetLogicalDrives();
35 ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
37 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
39 type = GetDriveTypeA(drive);
40 ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
42 if (!(logical_drives & 1))
43 ok(type == DRIVE_NO_ROOT_DIR,
44 "GetDriveTypeA should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
51 void test_GetDriveTypeW(void)
53 WCHAR drive[] = {'?',':','\\',0};
57 logical_drives = GetLogicalDrives();
58 ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
60 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
62 type = GetDriveTypeW(drive);
63 if (type == DRIVE_UNKNOWN && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
65 /* Must be Win9x which doesn't support the Unicode functions */
68 ok(type > 0 && type <= 6, "not a valid drive %c: type %u\n", drive[0], type);
70 if (!(logical_drives & 1))
71 ok(type == DRIVE_NO_ROOT_DIR,
72 "GetDriveTypeW should return DRIVE_NO_ROOT_DIR for inexistant drive %c: but not %u\n",
79 void test_GetDiskFreeSpaceA(void)
82 DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
83 char drive[] = "?:\\";
86 ret = GetDiskFreeSpaceA(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
87 ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
89 ret = GetDiskFreeSpaceA("", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
90 ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_NAME),
91 "GetDiskFreeSpaceA(\"\"): ret=%d GetLastError=%ld\n",
94 ret = GetDiskFreeSpaceA("\\", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
95 ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
97 ret = GetDiskFreeSpaceA("/", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
98 ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
100 logical_drives = GetLogicalDrives();
101 ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
103 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
105 /* Skip floppy drives because NT pops up a MessageBox if no
108 if (GetDriveTypeA(drive)!=DRIVE_REMOVABLE)
110 ret = GetDiskFreeSpaceA(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
111 if (!(logical_drives & 1))
112 ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_DRIVE),
113 "GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
114 drive, ret, GetLastError());
117 (!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
118 "GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
119 drive, ret, GetLastError());
121 logical_drives >>= 1;
125 void test_GetDiskFreeSpaceW(void)
128 DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
129 WCHAR drive[] = {'?',':','\\',0};
130 DWORD logical_drives;
131 static const WCHAR empty_pathW[] = { 0 };
132 static const WCHAR root_pathW[] = { '\\', 0 };
133 static const WCHAR unix_style_root_pathW[] = { '/', 0 };
135 ret = GetDiskFreeSpaceW(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
136 if (ret == 0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
138 /* Must be Win9x which doesn't support the Unicode functions */
141 ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
143 ret = GetDiskFreeSpaceW(empty_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
144 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
145 "GetDiskFreeSpaceW(\"\"): ret=%d GetLastError=%ld\n",
146 ret, GetLastError());
148 ret = GetDiskFreeSpaceW(root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
149 ok(ret, "GetDiskFreeSpaceW(\"\") error %ld\n", GetLastError());
151 ret = GetDiskFreeSpaceW(unix_style_root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
152 ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
154 logical_drives = GetLogicalDrives();
155 ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
157 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
159 /* Skip floppy drives because NT4 pops up a MessageBox if no floppy is present */
160 if (GetDriveTypeW(drive)!=DRIVE_REMOVABLE)
162 ret = GetDiskFreeSpaceW(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
163 if (!(logical_drives & 1))
164 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
165 "GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
166 drive[0], ret, GetLastError());
168 ok(ret || GetLastError() == ERROR_NOT_READY,
169 "GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
170 drive[0], ret, GetLastError());
172 logical_drives >>= 1;
178 test_GetDriveTypeA();
179 test_GetDriveTypeW();
181 test_GetDiskFreeSpaceA();
182 test_GetDiskFreeSpaceW();