ReactOS 0.4.16-dev-319-g6cf4263
GetVolumeInformation.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for GetVolumeInformation
5 * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
6 */
7
8#include "precomp.h"
9
10static VOID
12{
13 BOOL Ret;
14 CHAR Outbuf[MAX_PATH];
15 DWORD i, MCL, Flags, Len;
16
17 memset(Outbuf, 0xAA, MAX_PATH);
18 Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, MAX_PATH);
19 ok(Ret != FALSE, "GetVolumeInformationA failed: %ld\n", GetLastError());
20 for (i = 0; i < MAX_PATH; ++i)
21 {
22 if (Outbuf[i] == 0)
23 {
24 break;
25 }
26 }
27 ok(i != MAX_PATH, "String was not null terminated!\n");
28
29 memset(Outbuf, 0xAA, MAX_PATH);
30 Len = i;
31 Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len + 1);
32 ok(Ret != FALSE, "GetVolumeInformationA failed: %ld\n", GetLastError());
33 for (i = 0; i < MAX_PATH; ++i)
34 {
35 if (Outbuf[i] == 0)
36 {
37 break;
38 }
39 }
40 ok(i != MAX_PATH, "String was not null terminated!\n");
41 ok(i == Len, "String was truncated\n");
42
43 memset(Outbuf, 0xAA, MAX_PATH);
44 Len = i;
45 SetLastError(0xdeadbeef);
46 Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len);
47 ok(Ret != TRUE, "GetVolumeInformationA succeed\n");
48 ok(GetLastError() == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH error, got %ld\n", GetLastError());
49 ok(Outbuf[0] != 0xAA, "Output buffer was not written to\n");
50 for (i = 0; i < MAX_PATH; ++i)
51 {
52 if (Outbuf[i] == 0)
53 {
54 break;
55 }
56 }
57 ok(i == MAX_PATH, "String was null terminated!\n");
58 for (i = 0; i < MAX_PATH; ++i)
59 {
60 if (Outbuf[i] != 0xAA)
61 {
62 break;
63 }
64 }
65 ok(i != MAX_PATH, "String was not written to!\n");
66 ok(i < Len, "Buffer has been overruned\n");
67}
68
69static VOID
71{
72 BOOL Ret;
73 WCHAR Outbuf[MAX_PATH];
74 DWORD i, MCL, Flags, Len;
75
76 memset(Outbuf, 0xAA, sizeof(Outbuf));
77 Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, MAX_PATH);
78 ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
79 for (i = 0; i < MAX_PATH; ++i)
80 {
81 if (Outbuf[i] == 0)
82 {
83 break;
84 }
85 }
86 ok(i != MAX_PATH, "String was not null terminated!\n");
87
88 memset(Outbuf, 0xAA, sizeof(Outbuf));
89 Len = i;
90 Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len + 1);
91 ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
92 for (i = 0; i < MAX_PATH; ++i)
93 {
94 if (Outbuf[i] == 0)
95 {
96 break;
97 }
98 }
99 ok(i != MAX_PATH, "String was not null terminated!\n");
100 ok(i == Len, "String was truncated\n");
101
102 memset(Outbuf, 0xAA, sizeof(Outbuf));
103 Len = i;
104 SetLastError(0xdeadbeef);
105 Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags, Outbuf, Len);
106 ok(Ret != TRUE, "GetVolumeInformationW succeed\n");
107 ok(GetLastError() == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH error, got %ld\n", GetLastError());
108 ok(Outbuf[0] != 0xAA, "Output buffer was not written to\n");
109 for (i = 0; i < MAX_PATH; ++i)
110 {
111 if (Outbuf[i] == 0)
112 {
113 break;
114 }
115 }
116 ok(i == MAX_PATH, "String was null terminated!\n");
117 ok(i >= Len, "Buffer has not been overrun\n");
118}
119
121{
124}
static VOID TestGetVolumeInformationW(VOID)
static VOID TestGetVolumeInformationA(VOID)
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define Len
Definition: deflate.h:82
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
BOOL WINAPI GetVolumeInformationA(IN LPCSTR lpRootPathName, IN LPSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define L(x)
Definition: ntvdm.h:50
#define memset(x, y, z)
Definition: compat.h:39
#define GetVolumeInformation
Definition: winbase.h:3878
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_BAD_LENGTH
Definition: winerror.h:127
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175