2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for RtlDosSearchPath_Ustr
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
10 #define WIN32_NO_STATUS
11 #include <ndk/rtlfuncs.h>
16 RtlDosSearchPath_Ustr(
18 IN PUNICODE_STRING PathString,
19 IN PUNICODE_STRING FileNameString,
20 IN PUNICODE_STRING ExtensionString,
21 IN PUNICODE_STRING CallerBuffer,
22 IN OUT PUNICODE_STRING DynamicString OPTIONAL,
23 OUT PUNICODE_STRING *FullNameOut OPTIONAL,
24 OUT PSIZE_T FilePartSize OPTIONAL,
25 OUT PSIZE_T LengthNeeded OPTIONAL
29 #define ok_eq_ulong(value, expected) ok((value) == (expected), #value " = %lu, expected %lu\n", value, expected)
30 #define ok_eq_hex(value, expected) ok((value) == (expected), #value " = 0x%lx, expected 0x%lx\n", value, expected)
31 #define ok_eq_pointer(value, expected) ok((value) == (expected), #value " = %p, expected %p\n", value, expected)
33 #define ok_eq_ustr(str1, str2) do { \
34 ok((str1)->Buffer == (str2)->Buffer, "Buffer modified\n"); \
35 ok((str1)->Length == (str2)->Length, "Length modified\n"); \
36 ok((str1)->MaximumLength == (str2)->MaximumLength, "MaximumLength modified\n"); \
39 START_TEST(RtlDosSearchPath_Ustr
)
42 UNICODE_STRING PathString
;
43 UNICODE_STRING FileNameString
;
44 UNICODE_STRING ExtensionString
;
45 UNICODE_STRING CallerBuffer
;
46 UNICODE_STRING DynamicString
;
47 PUNICODE_STRING FullNameOut
;
48 UNICODE_STRING EmptyString
;
53 RtlInitUnicodeString(&EmptyString
, NULL
);
57 Status
= RtlDosSearchPath_Ustr(0, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
58 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
59 EndSeh(STATUS_SUCCESS
);
61 RtlInitUnicodeString(&FileNameString
, NULL
);
63 Status
= RtlDosSearchPath_Ustr(0, NULL
, &FileNameString
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
64 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
65 EndSeh(STATUS_SUCCESS
);
67 RtlInitUnicodeString(&PathString
, NULL
);
69 Status
= RtlDosSearchPath_Ustr(0, &PathString
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
70 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
71 EndSeh(STATUS_SUCCESS
);
72 ok_eq_ustr(&PathString
, &EmptyString
);
74 /* Minimal valid set of parameters */
75 RtlInitUnicodeString(&PathString
, NULL
);
76 RtlInitUnicodeString(&FileNameString
, NULL
);
78 Status
= RtlDosSearchPath_Ustr(0, &PathString
, &FileNameString
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
79 ok_eq_hex(Status
, STATUS_NO_SUCH_FILE
);
80 EndSeh(STATUS_SUCCESS
);
81 ok_eq_ustr(&PathString
, &EmptyString
);
82 ok_eq_ustr(&FileNameString
, &EmptyString
);
84 /* Check valid flags */
85 for (i
= 0; i
< 32; i
++)
87 RtlInitUnicodeString(&PathString
, NULL
);
88 RtlInitUnicodeString(&FileNameString
, NULL
);
90 Status
= RtlDosSearchPath_Ustr(1 << i
, &PathString
, &FileNameString
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
91 ok_eq_hex(Status
, i
> 2 ? STATUS_INVALID_PARAMETER
: STATUS_NO_SUCH_FILE
);
92 EndSeh(STATUS_SUCCESS
);
93 ok_eq_ustr(&PathString
, &EmptyString
);
94 ok_eq_ustr(&FileNameString
, &EmptyString
);
97 RtlInitUnicodeString(&PathString
, NULL
);
98 RtlInitUnicodeString(&FileNameString
, NULL
);
100 Status
= RtlDosSearchPath_Ustr(7, &PathString
, &FileNameString
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
101 ok_eq_hex(Status
, STATUS_NO_SUCH_FILE
);
102 EndSeh(STATUS_SUCCESS
);
103 ok_eq_ustr(&PathString
, &EmptyString
);
104 ok_eq_ustr(&FileNameString
, &EmptyString
);
106 /* Everything except PathString */
107 RtlInitUnicodeString(&FileNameString
, NULL
);
108 RtlInitUnicodeString(&ExtensionString
, NULL
);
109 RtlInitUnicodeString(&CallerBuffer
, NULL
);
110 RtlInitUnicodeString(&DynamicString
, NULL
);
111 FullNameOut
= InvalidPointer
;
112 FilePartSize
= (SIZE_T
)-1;
113 LengthNeeded
= (SIZE_T
)-1;
115 Status
= RtlDosSearchPath_Ustr(0,
124 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
125 EndSeh(STATUS_SUCCESS
);
126 ok_eq_ustr(&FileNameString
, &EmptyString
);
127 ok_eq_ustr(&ExtensionString
, &EmptyString
);
128 ok_eq_ustr(&CallerBuffer
, &EmptyString
);
129 ok_eq_ustr(&DynamicString
, &EmptyString
);
130 ok_eq_pointer(FullNameOut
, NULL
);
131 ok_eq_ulong(FilePartSize
, 0UL);
132 ok_eq_ulong(LengthNeeded
, 0UL);
134 /* Everything except FileNameString */
135 RtlInitUnicodeString(&PathString
, NULL
);
136 RtlInitUnicodeString(&ExtensionString
, NULL
);
137 RtlInitUnicodeString(&CallerBuffer
, NULL
);
138 RtlInitUnicodeString(&DynamicString
, NULL
);
139 FullNameOut
= InvalidPointer
;
140 FilePartSize
= (SIZE_T
)-1;
141 LengthNeeded
= (SIZE_T
)-1;
143 Status
= RtlDosSearchPath_Ustr(0,
152 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
153 EndSeh(STATUS_SUCCESS
);
154 ok_eq_ustr(&PathString
, &EmptyString
);
155 ok_eq_ustr(&ExtensionString
, &EmptyString
);
156 ok_eq_ustr(&CallerBuffer
, &EmptyString
);
157 ok_eq_ustr(&DynamicString
, &EmptyString
);
158 ok_eq_pointer(FullNameOut
, NULL
);
159 ok_eq_ulong(FilePartSize
, 0UL);
160 ok_eq_ulong(LengthNeeded
, 0UL);
162 /* Passing CallerBuffer and DynamicString, but not FullNameOut is invalid */
163 RtlInitUnicodeString(&PathString
, NULL
);
164 RtlInitUnicodeString(&FileNameString
, NULL
);
165 RtlInitUnicodeString(&ExtensionString
, NULL
);
166 RtlInitUnicodeString(&CallerBuffer
, NULL
);
167 RtlInitUnicodeString(&DynamicString
, NULL
);
168 FullNameOut
= InvalidPointer
;
169 FilePartSize
= (SIZE_T
)-1;
170 LengthNeeded
= (SIZE_T
)-1;
172 Status
= RtlDosSearchPath_Ustr(0,
181 ok_eq_hex(Status
, STATUS_INVALID_PARAMETER
);
182 EndSeh(STATUS_SUCCESS
);
183 ok_eq_ustr(&PathString
, &EmptyString
);
184 ok_eq_ustr(&FileNameString
, &EmptyString
);
185 ok_eq_ustr(&ExtensionString
, &EmptyString
);
186 ok_eq_ustr(&CallerBuffer
, &EmptyString
);
187 ok_eq_ustr(&DynamicString
, &EmptyString
);
188 ok_eq_ulong(FilePartSize
, 0UL);
189 ok_eq_ulong(LengthNeeded
, 0UL);
191 /* All parameters given */
192 RtlInitUnicodeString(&PathString
, NULL
);
193 RtlInitUnicodeString(&FileNameString
, NULL
);
194 RtlInitUnicodeString(&ExtensionString
, NULL
);
195 RtlInitUnicodeString(&CallerBuffer
, NULL
);
196 RtlInitUnicodeString(&DynamicString
, NULL
);
197 FullNameOut
= InvalidPointer
;
198 FilePartSize
= (SIZE_T
)-1;
199 LengthNeeded
= (SIZE_T
)-1;
201 Status
= RtlDosSearchPath_Ustr(0,
210 ok_eq_hex(Status
, STATUS_NO_SUCH_FILE
);
211 EndSeh(STATUS_SUCCESS
);
212 ok_eq_ustr(&PathString
, &EmptyString
);
213 ok_eq_ustr(&FileNameString
, &EmptyString
);
214 ok_eq_ustr(&ExtensionString
, &EmptyString
);
215 ok_eq_ustr(&CallerBuffer
, &EmptyString
);
216 ok_eq_ustr(&DynamicString
, &EmptyString
);
217 ok_eq_pointer(FullNameOut
, NULL
);
218 ok_eq_ulong(FilePartSize
, 0UL);
219 ok_eq_ulong(LengthNeeded
, 0UL);