kernel32/tests: Use skip.
[wine] / dlls / kernel32 / tests / volume.c
1 /*
2  * Unit test suite
3  *
4  * Copyright 2006 Stefan Leichter
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23
24 #define CDROM   "CDROM"
25 #define FLOPPY  "FLOPPY"
26 #define HARDISK "HARDDISK"
27 #define LANMAN  "LANMANREDIRECTOR"
28 #define RAMDISK "RAMDISK"
29
30 static HINSTANCE hdll;
31 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
32 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
33
34 /* ############################### */
35
36 static void test_query_dos_deviceA(void)
37 {
38     char drivestr[] = "a:";
39     char *p, buffer[2000];
40     DWORD ret;
41     for (;drivestr[0] <= 'z'; drivestr[0]++) {
42         ret = QueryDosDeviceA( drivestr, buffer, sizeof(buffer));
43         if(ret) {
44             for (p = buffer; *p; p++) *p = toupper(*p);
45             todo_wine
46             ok( strstr( buffer, CDROM)   || strstr( buffer, FLOPPY) ||
47                 strstr( buffer, HARDISK) || strstr( buffer, LANMAN) ||
48                 strstr( buffer, RAMDISK), "expect the string %s contains %s,%s,%s,%s or %s\n",
49                 buffer, CDROM, FLOPPY, HARDISK, LANMAN, RAMDISK);
50         }
51     }
52 }
53
54 static void test_GetVolumeNameForVolumeMountPointA(void)
55 {
56     BOOL ret;
57     char volume[MAX_PATH], path[] = "c:\\";
58     DWORD len = sizeof(volume);
59
60     /* not present before w2k */
61     if (!pGetVolumeNameForVolumeMountPointA) {
62         skip("GetVolumeNameForVolumeMountPointA not found\n");
63         return;
64     }
65
66     ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0);
67     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
68
69     if (0) { /* these crash on XP */
70     ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len);
71     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
72
73     ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len);
74     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
75     }
76
77     ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
78     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
79 }
80
81 static void test_GetVolumeNameForVolumeMountPointW(void)
82 {
83     BOOL ret;
84     WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
85     DWORD len = sizeof(volume) / sizeof(WCHAR);
86
87     /* not present before w2k */
88     if (!pGetVolumeNameForVolumeMountPointW) {
89         skip("GetVolumeNameForVolumeMountPointW not found\n");
90         return;
91     }
92
93     ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0);
94     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
95
96     if (0) { /* these crash on XP */
97     ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len);
98     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
99
100     ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len);
101     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
102     }
103
104     ret = pGetVolumeNameForVolumeMountPointW(path, volume, len);
105     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
106 }
107
108 START_TEST(volume)
109 {
110     hdll = GetModuleHandleA("kernel32.dll");
111     pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA");
112     pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW");
113
114     test_query_dos_deviceA();
115     test_GetVolumeNameForVolumeMountPointA();
116     test_GetVolumeNameForVolumeMountPointW();
117 }