ReactOS 0.4.15-dev-7942-gd23573b
RtlGetFullPathName_U.c File Reference
#include "precomp.h"
Include dependency graph for RtlGetFullPathName_U.c:

Go to the source code of this file.

Macros

#define broken(x)   0
 

Enumerations

enum  PREFIX_TYPE {
  PrefixNone , PrefixCurrentDrive , PrefixCurrentPath , PrefixCurrentPathWithoutLastPart ,
  PrefixNone , PrefixCurrentDrive , PrefixCurrentPath , PrefixCurrentPathWithoutLastPart ,
  PrefixNone , PrefixCurrentDrive , PrefixCurrentPath , PrefixCurrentPathWithoutLastPart
}
 

Functions

static BOOLEAN CheckStringBuffer (PCWSTR Buffer, SIZE_T Length, SIZE_T MaximumLength, PCWSTR Expected)
 
static VOID RunTestCases (VOID)
 
 START_TEST (RtlGetFullPathName_U)
 

Macro Definition Documentation

◆ broken

#define broken (   x)    0

Definition at line 72 of file RtlGetFullPathName_U.c.

Enumeration Type Documentation

◆ PREFIX_TYPE

Enumerator
PrefixNone 
PrefixCurrentDrive 
PrefixCurrentPath 
PrefixCurrentPathWithoutLastPart 
PrefixNone 
PrefixCurrentDrive 
PrefixCurrentPath 
PrefixCurrentPathWithoutLastPart 
PrefixNone 
PrefixCurrentDrive 
PrefixCurrentPath 
PrefixCurrentPathWithoutLastPart 

Definition at line 74 of file RtlGetFullPathName_U.c.

Function Documentation

◆ CheckStringBuffer()

static BOOLEAN CheckStringBuffer ( PCWSTR  Buffer,
SIZE_T  Length,
SIZE_T  MaximumLength,
PCWSTR  Expected 
)
static

Definition at line 23 of file RtlGetFullPathName_U.c.

28{
29 SIZE_T ExpectedLength = wcslen(Expected) * sizeof(WCHAR);
30 SIZE_T EqualLength;
32 SIZE_T i;
33
34 if (Length != ExpectedLength)
35 {
36 ok(0, "String length is %lu, expected %lu\n", (ULONG)Length, (ULONG)ExpectedLength);
37 Result = FALSE;
38 }
39
40 EqualLength = RtlCompareMemory(Buffer, Expected, Length);
41 if (EqualLength != Length)
42 {
43 ok(0, "String is '%S', expected '%S'\n", Buffer, Expected);
44 Result = FALSE;
45 }
46
47 if (Buffer[Length / sizeof(WCHAR)] != UNICODE_NULL)
48 {
49 ok(0, "Not null terminated\n");
50 Result = FALSE;
51 }
52
53 /* The function nulls the rest of the buffer! */
54 for (i = Length + sizeof(UNICODE_NULL); i < MaximumLength; i++)
55 {
56 UCHAR Char = ((PUCHAR)Buffer)[i];
57 if (Char != 0)
58 {
59 ok(0, "Found 0x%x at offset %lu, expected 0x%x\n", Char, (ULONG)i, 0);
60 /* Don't count this as a failure unless the string was actually wrong */
61 //Result = FALSE;
62 /* Don't flood the log */
63 break;
64 }
65 }
66
67 return Result;
68}
BOOLEAN Expected
unsigned char BOOLEAN
#define ok(value,...)
Definition: atltest.h:57
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RunTestCases().

◆ RunTestCases()

static VOID RunTestCases ( VOID  )
static

Definition at line 84 of file RtlGetFullPathName_U.c.

85{
86 /* TODO: don't duplicate this in the other tests */
87 /* TODO: Drive Relative tests don't work yet if the current drive isn't C: */
88 struct
89 {
90 ULONG Line;
92 PREFIX_TYPE PrefixType;
93 PCWSTR FullPathName;
94 PREFIX_TYPE FilePartPrefixType;
95 SIZE_T FilePartSize;
96 } TestCases[] =
97 {
98// { __LINE__, L"C:", PrefixCurrentPath, L"", PrefixCurrentPathWithoutLastPart },
99 { __LINE__, L"C:\\", PrefixNone, L"C:\\" },
100 { __LINE__, L"C:\\test", PrefixNone, L"C:\\test", PrefixCurrentDrive },
101 { __LINE__, L"C:\\test\\", PrefixNone, L"C:\\test\\" },
102 { __LINE__, L"C:/test/", PrefixNone, L"C:\\test\\" },
103
104 { __LINE__, L"C:\\\\test", PrefixNone, L"C:\\test", PrefixCurrentDrive },
105 { __LINE__, L"test", PrefixCurrentPath, L"\\test", PrefixCurrentPath, sizeof(WCHAR) },
106 { __LINE__, L"\\test", PrefixCurrentDrive, L"test", PrefixCurrentDrive },
107 { __LINE__, L"/test", PrefixCurrentDrive, L"test", PrefixCurrentDrive },
108 { __LINE__, L".\\test", PrefixCurrentPath, L"\\test", PrefixCurrentPath, sizeof(WCHAR) },
109
110 { __LINE__, L"\\.", PrefixCurrentDrive, L"" },
111 { __LINE__, L"\\.\\", PrefixCurrentDrive, L"" },
112 { __LINE__, L"\\\\.", PrefixNone, L"\\\\.\\" },
113 { __LINE__, L"\\\\.\\", PrefixNone, L"\\\\.\\" },
114 { __LINE__, L"\\\\.\\Something\\", PrefixNone, L"\\\\.\\Something\\" },
115
116 { __LINE__, L"\\??\\", PrefixCurrentDrive, L"??\\" },
117 { __LINE__, L"\\??\\C:", PrefixCurrentDrive, L"??\\C:", PrefixCurrentDrive, 3 * sizeof(WCHAR) },
118 { __LINE__, L"\\??\\C:\\", PrefixCurrentDrive, L"??\\C:\\" },
119 { __LINE__, L"\\??\\C:\\test", PrefixCurrentDrive, L"??\\C:\\test", PrefixCurrentDrive, 6 * sizeof(WCHAR) },
120 { __LINE__, L"\\??\\C:\\test\\", PrefixCurrentDrive, L"??\\C:\\test\\" },
121
122 { __LINE__, L"\\\\??\\", PrefixNone, L"\\\\??\\" },
123 { __LINE__, L"\\\\??\\C:", PrefixNone, L"\\\\??\\C:" },
124 { __LINE__, L"\\\\??\\C:\\", PrefixNone, L"\\\\??\\C:\\" },
125 { __LINE__, L"\\\\??\\C:\\test", PrefixNone, L"\\\\??\\C:\\test", PrefixNone, sizeof(L"\\\\??\\C:\\") },
126 { __LINE__, L"\\\\??\\C:\\test\\", PrefixNone, L"\\\\??\\C:\\test\\" },
127 };
128 WCHAR FullPathNameBuffer[MAX_PATH];
131 WCHAR ExpectedPathName[MAX_PATH];
132 SIZE_T FilePartSize;
133 SIZE_T ExpectedFilePartSize;
134 const INT TestCount = sizeof(TestCases) / sizeof(TestCases[0]);
135 INT i;
136 BOOLEAN Okay;
137
138 for (i = 0; i < TestCount; i++)
139 {
140 trace("i = %d\n", i);
141 switch (TestCases[i].PrefixType)
142 {
143 case PrefixNone:
144 ExpectedPathName[0] = UNICODE_NULL;
145 break;
147 GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName);
148 ExpectedPathName[3] = UNICODE_NULL;
149 break;
151 Length = GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName);
152 if (Length == 3 && TestCases[i].FullPathName[0])
153 ExpectedPathName[2] = UNICODE_NULL;
154 break;
155 default:
156 skip("Invalid test!\n");
157 continue;
158 }
159 wcscat(ExpectedPathName, TestCases[i].FullPathName);
160 RtlFillMemory(FullPathNameBuffer, sizeof(FullPathNameBuffer), 0xAA);
161 Length = 0;
162 StartSeh()
164 sizeof(FullPathNameBuffer),
165 FullPathNameBuffer,
166 &ShortName);
168
169 Okay = CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName);
170 ok(Okay, "Line %lu: Wrong path name '%S', expected '%S'\n", TestCases[i].Line, FullPathNameBuffer, ExpectedPathName);
171
172 if (!ShortName)
173 FilePartSize = 0;
174 else
175 FilePartSize = ShortName - FullPathNameBuffer;
176
177 switch (TestCases[i].FilePartPrefixType)
178 {
179 case PrefixNone:
180 ExpectedFilePartSize = 0;
181 break;
183 ExpectedFilePartSize = sizeof(L"C:\\");
184 break;
186 ExpectedFilePartSize = GetCurrentDirectoryW(0, NULL) * sizeof(WCHAR);
187 if (ExpectedFilePartSize == sizeof(L"C:\\"))
188 ExpectedFilePartSize -= sizeof(WCHAR);
189 break;
191 {
192 WCHAR CurrentPath[MAX_PATH];
194 ExpectedFilePartSize = GetCurrentDirectoryW(sizeof(CurrentPath) / sizeof(WCHAR), CurrentPath) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
195 if (ExpectedFilePartSize == sizeof(L"C:\\"))
196 ExpectedFilePartSize = 0;
197 else
198 {
199 BackSlash = wcsrchr(CurrentPath, L'\\');
200 if (BackSlash)
201 ExpectedFilePartSize -= wcslen(BackSlash + 1) * sizeof(WCHAR);
202 else
203 ok(0, "Line %lu: GetCurrentDirectory returned %S\n", TestCases[i].Line, CurrentPath);
204 }
205 break;
206 }
207 default:
208 skip("Invalid test!\n");
209 continue;
210 }
211 ExpectedFilePartSize += TestCases[i].FilePartSize;
212 if (ExpectedFilePartSize != 0)
213 ExpectedFilePartSize = (ExpectedFilePartSize - sizeof(UNICODE_NULL)) / sizeof(WCHAR);
214 ok(FilePartSize == ExpectedFilePartSize,
215 "Line %lu: FilePartSize = %lu, expected %lu\n", TestCases[i].Line, (ULONG)FilePartSize, (ULONG)ExpectedFilePartSize);
216 }
217}
static TEST_CASE TestCases[]
Definition: CommandLine.c:101
static BOOLEAN CheckStringBuffer(PCWSTR Buffer, SIZE_T Length, SIZE_T MaximumLength, PCWSTR Expected)
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
static const WCHAR BackSlash[]
Definition: devclass.c:29
switch(r->id)
Definition: btrfs.c:3046
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1306
struct _FileName FileName
Definition: fatprocs.h:896
GLdouble n
Definition: glext.h:7729
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
if(dx< 0)
Definition: linetemp.h:194
BOOL expected
Definition: store.c:2063
NTSYSAPI ULONG NTAPI RtlGetFullPathName_U(_In_ PCWSTR FileName, _In_ ULONG Size, _Out_z_bytecap_(Size) PWSTR Buffer, _Out_opt_ PWSTR *ShortName)
Definition: path.c:1987
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ncftp.h:79
Definition: movable.cpp:9
Definition: name.c:39
else
Definition: tritemp.h:161
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( RtlGetFullPathName_U  )

Definition at line 219 of file RtlGetFullPathName_U.c.

220{
224
225 /* Parameter checks */
226 StartSeh()
228 ok(Length == 0, "Length = %lu\n", Length);
230
231 StartSeh()
233 ok(Length == 0, "Length = %lu\n", Length);
235
237 StartSeh()
239 ok(Length == 0, "Length = %lu\n", Length);
242 broken(ShortName == NULL) /* Win7 */, "ShortName = %p\n", ShortName);
243
244 StartSeh()
246 ok(Length == 0, "Length = %lu\n", Length);
248
250 StartSeh()
252 ok(Length == 0, "Length = %lu\n", Length);
255 broken(ShortName == NULL) /* Win7 */, "ShortName = %p\n", ShortName);
256
257 StartSeh()
259 ok(Length == sizeof(L"C:\\test"), "Length = %lu\n", Length);
261
262 FileName = L"C:\\test";
264 StartSeh()
266 ok(Length == sizeof(L"C:\\test"), "Length = %lu\n", Length);
269 broken(ShortName == NULL) /* Win7 */, "ShortName = %p\n", ShortName);
270
271 /* Check the actual functionality with different paths */
272 RunTestCases();
273}
static VOID RunTestCases(VOID)
#define broken(x)
#define InvalidPointer
Definition: terminate.cpp:24
GLfloat GLfloat p
Definition: glext.h:8902
#define test
Definition: rosglue.h:37