ReactOS  0.4.12-dev-396-g37af787
FsRtlExpression.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Test for FsRtlIsNameInExpression/FsRtlIsDbcsInExpression
5  * PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
6  * Víctor Martínez Calvo <vmartinez@reactos.org>
7  */
8 
9 #include <kmt_test.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 struct
15 { /* API parameters */
19  /* Flag for tests which shouldn't be tested in checked builds */
21  /* Expected test result */
23 } Tests[] =
24 {
25  /* TODO: reorganize AssertsInChecked. This needs to be separate for *Name* and *Dbcs* or something.
26  * We currently fail a lot of them in Windows despite AssertsInChecked.
27  * E.g. *Dbcs* asserts !islower(Expression[i]) and FsRtlDoesDbcsContainWildCards(Expression) for some reason.
28  */
29  { L"", L"", FALSE, TRUE, TRUE },
30  { L"", L"a", FALSE, TRUE, FALSE },
31  { L"*", L"a", FALSE, TRUE, TRUE },
32  { L"*", L"", FALSE, TRUE, FALSE },
33  { L"**", L"", FALSE, TRUE, FALSE },
34  { L"**", L"a", FALSE, FALSE, TRUE },
35  { L"ntdll.dll", L".", FALSE, TRUE, FALSE },
36  { L"ntdll.dll", L"~1", FALSE, TRUE, FALSE },
37  { L"ntdll.dll", L"..", FALSE, TRUE, FALSE },
38  { L"ntdll.dll", L"ntdll.dll", FALSE, TRUE, TRUE },
39  { L"smss.exe", L".", FALSE, TRUE, FALSE },
40  { L"smss.exe", L"~1", FALSE, TRUE, FALSE },
41  { L"smss.exe", L"..", FALSE, TRUE, FALSE },
42  { L"smss.exe", L"ntdll.dll", FALSE, TRUE, FALSE },
43  { L"smss.exe", L"NTDLL.DLL", FALSE, TRUE, FALSE },
44  { L"nt??krnl.???", L"ntoskrnl.exe", FALSE, FALSE, TRUE },
45  { L"he*o", L"hello", FALSE, FALSE, TRUE },
46  { L"he*o", L"helo", FALSE, FALSE, TRUE },
47  { L"he*o", L"hella", FALSE, FALSE, FALSE },
48  { L"he*", L"hello", FALSE, FALSE, TRUE },
49  { L"he*", L"helo", FALSE, FALSE, TRUE },
50  { L"he*", L"hella", FALSE, FALSE, TRUE },
51  { L"*.cpl", L"kdcom.dll", FALSE, FALSE, FALSE },
52  { L"*.cpl", L"bootvid.dll", FALSE, FALSE, FALSE },
53  { L"*.cpl", L"ntoskrnl.exe", FALSE, FALSE, FALSE },
54  { L".", L"NTDLL.DLL", FALSE, FALSE, FALSE },
55  { L"F0_*.*", L".", FALSE, FALSE, FALSE },
56  { L"F0_*.*", L"..", FALSE, FALSE, FALSE },
57  { L"F0_*.*", L"SETUP.EXE", FALSE, FALSE, FALSE },
58  { L"F0_*.*", L"f0_", FALSE, FALSE, FALSE },
59  { L"F0_*.*", L"f0_", TRUE, FALSE, FALSE },
60  { L"F0_*.*", L"F0_", FALSE, FALSE, FALSE },
61  { L"F0_*.*", L"f0_.", FALSE, FALSE, FALSE },
62  { L"F0_*.*", L"f0_.", TRUE, FALSE, TRUE },
63  { L"F0_*.*", L"F0_.", FALSE, FALSE, TRUE },
64  { L"F0_*.*", L"F0_001", FALSE, FALSE, FALSE },
65  { L"F0_*.*", L"F0_001", TRUE, FALSE, FALSE },
66  { L"F0_*.*", L"f0_001", FALSE, FALSE, FALSE },
67  { L"F0_*.*", L"f0_001", TRUE, FALSE, FALSE },
68  { L"F0_*.*", L"F0_001.", FALSE, FALSE, TRUE },
69  { L"F0_*.*", L"f0_001.txt", FALSE, FALSE, FALSE },
70  { L"F0_*.*", L"f0_001.txt", TRUE, FALSE, TRUE },
71  { L"F0_*.*", L"F0_001.txt", FALSE, FALSE, TRUE },
72  { L"F0_*.*", L"F0_001.txt", TRUE, FALSE, TRUE },
73  { L"F0_*.", L".", FALSE, FALSE, FALSE },
74  { L"F0_*.", L"..", FALSE, FALSE, FALSE },
75  { L"F0_*.", L"SETUP.EXE", FALSE, FALSE, FALSE },
76  { L"F0_*.", L"f0_", FALSE, FALSE, FALSE },
77  { L"F0_*.", L"f0_", TRUE, FALSE, FALSE },
78  { L"F0_*.", L"F0_", FALSE, FALSE, FALSE },
79  { L"F0_*.", L"f0_.", FALSE, FALSE, FALSE },
80  { L"F0_*.", L"f0_.", TRUE, FALSE, TRUE },
81  { L"F0_*.", L"F0_.", FALSE, FALSE, TRUE },
82  { L"F0_*.", L"F0_001", FALSE, FALSE, FALSE },
83  { L"F0_*.", L"F0_001", TRUE, FALSE, FALSE },
84  { L"F0_*.", L"f0_001", FALSE, FALSE, FALSE },
85  { L"F0_*.", L"f0_001", TRUE, FALSE, FALSE },
86  { L"F0_*.", L"F0_001.", FALSE, FALSE, TRUE },
87  { L"F0_*.", L"f0_001.txt", FALSE, FALSE, FALSE },
88  { L"F0_*.", L"f0_001.txt", TRUE, FALSE, FALSE },
89  { L"F0_*.", L"F0_001.txt", FALSE, FALSE, FALSE },
90  { L"F0_*.", L"F0_001.txt", TRUE, FALSE, FALSE },
91  { L"F0_<\"*", L".", FALSE, FALSE, FALSE },
92  { L"F0_<\"*", L"..", FALSE, FALSE, FALSE },
93  { L"F0_<\"*", L"SETUP.EXE", FALSE, FALSE, FALSE },
94  { L"F0_<\"*", L"f0_", TRUE, FALSE, TRUE },
95  { L"F0_<\"*", L"F0_", FALSE, FALSE, TRUE },
96  { L"F0_<\"*", L"f0_.", FALSE, FALSE, FALSE },
97  { L"F0_<\"*", L"f0_.", TRUE, FALSE, TRUE },
98  { L"F0_<\"*", L"F0_.", FALSE, FALSE, TRUE },
99  { L"F0_<\"*", L"F0_001", FALSE, FALSE, TRUE },
100  { L"F0_<\"*", L"F0_001", TRUE, FALSE, TRUE },
101  { L"F0_<\"*", L"f0_001", FALSE, FALSE, FALSE },
102  { L"F0_<\"*", L"f0_001", TRUE, FALSE, TRUE },
103  { L"F0_<\"*", L"F0_001.", FALSE, FALSE, TRUE },
104  { L"F0_<\"*", L"f0_001.txt", FALSE, FALSE, FALSE },
105  { L"F0_<\"*", L"f0_001.txt", TRUE, FALSE, TRUE },
106  { L"F0_<\"*", L"F0_001.txt", FALSE, FALSE, TRUE },
107  { L"F0_<\"*", L"F0_001.txt", TRUE, FALSE, TRUE },
108  { L"*.TTF", L".", FALSE, FALSE, FALSE },
109  { L"*.TTF", L"..", FALSE, FALSE, FALSE },
110  { L"*.TTF", L"SETUP.INI", FALSE, FALSE, FALSE },
111  { L"*", L".", FALSE, FALSE, TRUE },
112  { L"*", L"..", FALSE, FALSE, TRUE },
113  { L"*", L"SETUP.INI", FALSE, FALSE, TRUE },
114  { L".*", L"1", FALSE, FALSE, FALSE },
115  { L".*", L"01", FALSE, FALSE, FALSE },
116  { L".*", L" ", FALSE, FALSE, FALSE },
117  { L".*", L"", FALSE, TRUE, FALSE },
118  { L".*", L".", FALSE, FALSE, TRUE },
119  { L".*", L"1.txt", FALSE, FALSE, FALSE },
120  { L".*", L" .txt", FALSE, FALSE, FALSE },
121  { L".*", L".txt", FALSE, FALSE, TRUE },
122  { L"\"ntoskrnl.exe", L"ntoskrnl.exe", FALSE, FALSE, FALSE },
123  { L"ntoskrnl\"exe", L"ntoskrnl.exe", FALSE, FALSE, TRUE },
124  { L"ntoskrn\".exe", L"ntoskrnl.exe", FALSE, FALSE, FALSE },
125  { L"ntoskrn\"\"exe", L"ntoskrnl.exe", FALSE, FALSE, FALSE },
126  { L"ntoskrnl.\"exe", L"ntoskrnl.exe", FALSE, FALSE, FALSE },
127  { L"ntoskrnl.exe\"", L"ntoskrnl.exe", FALSE, FALSE, TRUE },
128  { L"ntoskrnl.exe", L"ntoskrnl.exe", FALSE, FALSE, TRUE },
129  { L"*.c.d", L"a.b.c.d", FALSE, FALSE, TRUE },
130  { L"*.?.c.d", L"a.b.c.d", FALSE, FALSE, TRUE },
131  { L"**.?.c.d", L"a.b.c.d", FALSE, FALSE, TRUE },
132  { L"a.**.c.d", L"a.b.c.d", FALSE, FALSE, TRUE },
133  { L"a.b.??.d", L"a.b.c1.d", FALSE, FALSE, TRUE },
134  { L"a.b.??.d", L"a.b.c.d", FALSE, FALSE, FALSE },
135  { L"a.b.*?.d", L"a.b.c.d", FALSE, FALSE, TRUE },
136  { L"a.b.*??.d", L"a.b.ccc.d", FALSE, FALSE, TRUE },
137  { L"a.b.*??.d", L"a.b.cc.d", FALSE, FALSE, TRUE },
138  { L"a.b.*??.d", L"a.b.c.d", FALSE, FALSE, FALSE },
139  { L"a.b.*?*.d", L"a.b.c.d", FALSE, FALSE, TRUE },
140  { L"*?", L"", FALSE, TRUE, FALSE },
141  { L"*?", L"a", FALSE, FALSE, TRUE },
142  { L"*?", L"aa", FALSE, FALSE, TRUE },
143  { L"*?", L"aaa", FALSE, FALSE, TRUE },
144  { L"?*?", L"", FALSE, TRUE, FALSE },
145  { L"?*?", L"a", FALSE, FALSE, FALSE },
146  { L"?*?", L"aa", FALSE, FALSE, TRUE },
147  { L"?*?", L"aaa", FALSE, FALSE, TRUE },
148  { L"?*?", L"aaaa", FALSE, FALSE, TRUE },
149  { L"C:\\ReactOS\\**", L"C:\\ReactOS\\dings.bmp", FALSE, FALSE, TRUE },
150  { L"C:\\ReactOS\\***", L"C:\\ReactOS\\dings.bmp", FALSE, FALSE, TRUE },
151  { L"C:\\Windows\\*a*", L"C:\\ReactOS\\dings.bmp", FALSE, FALSE, FALSE },
152  { L"C:\\ReactOS\\*.bmp", L"C:\\Windows\\explorer.exe", FALSE, FALSE, FALSE },
153  { L"*.bmp;*.dib", L"winhlp32.exe", FALSE, FALSE, FALSE },
154  { L"*.*.*.*", L"127.0.0.1", FALSE, FALSE, TRUE },
155  { L"*?*?*?*", L"1.0.0.1", FALSE, FALSE, TRUE },
156  { L"?*?*?*?", L"1.0.0.1", FALSE, FALSE, TRUE },
157  { L"?.?.?.?", L"1.0.0.1", FALSE, FALSE, TRUE },
158  { L"*a*ab*abc", L"aabaabcdadabdabc", FALSE, FALSE, TRUE },
159  { L"ab<exe", L"abcd.exe", FALSE, FALSE, TRUE },
160  { L"ab<exe", L"ab.exe", FALSE, FALSE, TRUE },
161  { L"ab<exe", L"abcdexe", FALSE, FALSE, TRUE },
162  { L"ab<exe", L"acd.exe", FALSE, FALSE, FALSE },
163  { L"a.b<exe", L"a.bcd.exe", FALSE, FALSE, TRUE },
164  { L"a<b.exe", L"a.bcd.exe", FALSE, FALSE, FALSE },
165  { L"a.b.exe", L"a.bcd.exe", FALSE, FALSE, FALSE },
166  { L"abc.exe", L"abc.exe", FALSE, FALSE, TRUE },
167  { L"abc.exe", L"abc.exe.", FALSE, FALSE, FALSE },
168  { L"abc.exe", L"abc.exe.back", FALSE, FALSE, FALSE },
169  { L"abc.exe", L"abc.exes", FALSE, FALSE, FALSE },
170  { L"a>c.exe", L"abc.exe", FALSE, FALSE, TRUE },
171  { L"a>c.exe", L"ac.exe", FALSE, FALSE, FALSE },
172  { L"a>>>exe", L"abc.exe", FALSE, FALSE, FALSE },
173  { L"a>>>exe", L"ac.exe", FALSE, FALSE, FALSE },
174  { L"<.exe", L"test.exe", FALSE, FALSE, TRUE },
175  { L"<.EXE", L"test.exe", TRUE, FALSE, TRUE },
176  { L"*_MICROSOFT.WINDOWS.COMMON-CONTROLS_6595B64144CCF1DF_6.0.*.*_*_*.MANIFEST",
177  L"X86_MICROSOFT.VC90.ATL_1FC8B3B9A1E18E3B_9.0.30729.6161_X-WW_92453BB7.CAT",
178  FALSE, FALSE, FALSE },
179 };
180 
182 {
183  ULONG i;
184  for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++)
185  {
186  BOOLEAN TestResult;
189 
192 
194 
195  ok(TestResult == Tests[i].Expected, "FsRtlIsNameInExpression(%wZ,%wZ,%s,NULL): Expected %s, got %s\n",
196  &Expression, &Name, Tests[i].IgnoreCase ? "TRUE" : "FALSE", Tests[i].Expected ? "TRUE" : "FALSE", TestResult ? "TRUE" : "FALSE");
197  }
198 
199  /* TODO: test UpcaseTable */
200 }
201 
203 {
204  ULONG i;
205  for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++)
206  {
207  BOOLEAN TestResult;
208  UNICODE_STRING UExpression;
209  UNICODE_STRING UName;
212 
213  /* Don't run Tests which are known to assert in checked builds */
215  continue;
216 
217  /* Ignore Tests flagged IgnoreCase==TRUE to avoid duplicated testing */
218  if (Tests[i].IgnoreCase)
219  continue;
220 
221  RtlInitUnicodeString(&UExpression, Tests[i].Expression);
222  RtlInitUnicodeString(&UName, Tests[i].Name);
223 
226 
227  TestResult = FsRtlIsDbcsInExpression(&Expression, &Name);
228 
229  ok(TestResult == Tests[i].Expected, "FsRtlIsDbcsInExpression(%Z,%Z): Expected %s, got %s\n",
230  &Expression, &Name, Tests[i].Expected ? "TRUE" : "FALSE", TestResult ? "TRUE" : "FALSE");
231 
234  }
235 }
236 
237 START_TEST(FsRtlExpression)
238 {
241 }
PCWSTR Expression
#define TRUE
Definition: types.h:120
struct @1559 Tests[]
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:514
START_TEST(FsRtlExpression)
BOOLEAN KmtIsCheckedBuild
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
BOOLEAN AssertsInChecked
unsigned char BOOLEAN
static VOID FsRtlIsNameInExpressionTest()
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, IN PANSI_STRING Name)
Definition: dbcsname.c:160
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define ok(value,...)
Definition: CComObject.cpp:34
PCWSTR Name
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
static const WCHAR L[]
Definition: oid.c:1087
static VOID FsRtlIsDbcsInExpressionTest()
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
const uint16_t * PCWSTR
Definition: typedefs.h:55
BOOLEAN Expected
BOOLEAN IgnoreCase