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 */ 16 PCWSTR Expression; 17 PCWSTR Name; 18 BOOLEAN IgnoreCase; 19 /* Flag for tests which shouldn't be tested in checked builds */ 20 BOOLEAN AssertsInChecked; 21 /* Expected test result */ 22 BOOLEAN Expected; 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 { L"FI<<<<<<<<", L"FILE", FALSE, FALSE, TRUE }, 180 { L"<<<<<<<<<.<", L".", FALSE, FALSE, TRUE }, 181 { L"F<", L"FILE.TXT", FALSE, FALSE, FALSE }, 182 }; 183 184 static VOID FsRtlIsNameInExpressionTest() 185 { 186 ULONG i; 187 for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++) 188 { 189 BOOLEAN TestResult; 190 UNICODE_STRING Expression; 191 UNICODE_STRING Name; 192 193 RtlInitUnicodeString(&Expression, Tests[i].Expression); 194 RtlInitUnicodeString(&Name, Tests[i].Name); 195 196 TestResult = FsRtlIsNameInExpression(&Expression, &Name, Tests[i].IgnoreCase, NULL); 197 198 ok(TestResult == Tests[i].Expected, "FsRtlIsNameInExpression(%wZ,%wZ,%s,NULL): Expected %s, got %s\n", 199 &Expression, &Name, Tests[i].IgnoreCase ? "TRUE" : "FALSE", Tests[i].Expected ? "TRUE" : "FALSE", TestResult ? "TRUE" : "FALSE"); 200 } 201 202 /* TODO: test UpcaseTable */ 203 } 204 205 static VOID FsRtlIsDbcsInExpressionTest() 206 { 207 ULONG i; 208 for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++) 209 { 210 BOOLEAN TestResult; 211 UNICODE_STRING UExpression; 212 UNICODE_STRING UName; 213 ANSI_STRING Expression; 214 ANSI_STRING Name; 215 216 /* Don't run Tests which are known to assert in checked builds */ 217 if (KmtIsCheckedBuild && Tests[i].AssertsInChecked) 218 continue; 219 220 /* Ignore Tests flagged IgnoreCase==TRUE to avoid duplicated testing */ 221 if (Tests[i].IgnoreCase) 222 continue; 223 224 RtlInitUnicodeString(&UExpression, Tests[i].Expression); 225 RtlInitUnicodeString(&UName, Tests[i].Name); 226 227 RtlUnicodeStringToAnsiString(&Expression, &UExpression, TRUE); 228 RtlUnicodeStringToAnsiString(&Name, &UName, TRUE); 229 230 TestResult = FsRtlIsDbcsInExpression(&Expression, &Name); 231 232 ok(TestResult == Tests[i].Expected, "FsRtlIsDbcsInExpression(%Z,%Z): Expected %s, got %s\n", 233 &Expression, &Name, Tests[i].Expected ? "TRUE" : "FALSE", TestResult ? "TRUE" : "FALSE"); 234 235 RtlFreeAnsiString(&Expression); 236 RtlFreeAnsiString(&Name); 237 } 238 } 239 240 START_TEST(FsRtlExpression) 241 { 242 FsRtlIsNameInExpressionTest(); 243 FsRtlIsDbcsInExpressionTest(); 244 } 245