From 219137196e0a2de85ca536c2f808b4b9be0b37aa Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 29 Sep 2010 21:42:11 +0000 Subject: [PATCH] [KMTEST] Added a small testcase for FsRtlIsNameInExpression(). It's quite relevant for daily and simple use of the function. It shouldn't fail on ReactOS given our current implementation. svn path=/trunk/; revision=48932 --- rostests/drivers/kmtest/kmtest.c | 6 ++ rostests/drivers/kmtest/kmtest.rbuild | 1 + rostests/drivers/kmtest/ntos_fsrtl.c | 125 ++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 rostests/drivers/kmtest/ntos_fsrtl.c diff --git a/rostests/drivers/kmtest/kmtest.c b/rostests/drivers/kmtest/kmtest.c index 3164688336c..68817e33e67 100644 --- a/rostests/drivers/kmtest/kmtest.c +++ b/rostests/drivers/kmtest/kmtest.c @@ -174,6 +174,7 @@ BOOLEAN ZwUnloadTest(PDRIVER_OBJECT, PUNICODE_STRING, PWCHAR); BOOLEAN DetachDeviceTest(PDEVICE_OBJECT); BOOLEAN AttachDeviceTest(PDEVICE_OBJECT, PWCHAR); VOID LowerDeviceKernelAPITest(PDEVICE_OBJECT, BOOLEAN); +VOID NtoskrnlFsRtlTest(HANDLE KeyHandle); typedef enum { TestStageExTimer = 0, @@ -185,6 +186,7 @@ typedef enum { TestStageOb, TestStageKeStall, TestStageDrv, + TestStageFsRtl, TestStageMax } TEST_STAGE; @@ -399,6 +401,10 @@ RunKernelModeTest(PDRIVER_OBJECT DriverObject, FinishTest(KeyHandle, L"DriverTest"); break; + case TestStageFsRtl: + NtoskrnlFsRtlTest(KeyHandle); + break; + default: ASSERT(FALSE); break; diff --git a/rostests/drivers/kmtest/kmtest.rbuild b/rostests/drivers/kmtest/kmtest.rbuild index b9920797178..a569a76905e 100644 --- a/rostests/drivers/kmtest/kmtest.rbuild +++ b/rostests/drivers/kmtest/kmtest.rbuild @@ -14,5 +14,6 @@ ntos_ke.c ntos_ob.c ntos_pools.c + ntos_fsrtl.c kmtest.rc diff --git a/rostests/drivers/kmtest/ntos_fsrtl.c b/rostests/drivers/kmtest/ntos_fsrtl.c new file mode 100644 index 00000000000..2f9c29f37d8 --- /dev/null +++ b/rostests/drivers/kmtest/ntos_fsrtl.c @@ -0,0 +1,125 @@ +/* + * FsRtl Test + * + * Copyright 2010 Pierre Schweitzer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; see the file COPYING.LIB. + * If not, write to the Free Software Foundation, + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* INCLUDES *******************************************************************/ + +#include "kmtest.h" +#include + +#define NDEBUG +#include "debug.h" + +/* PRIVATE FUNCTIONS **********************************************************/ + +VOID FsRtlIsNameInExpressionTest() +{ + UNICODE_STRING Expression, Name; + + RtlInitUnicodeString(&Expression, L"ntdll.dll"); + RtlInitUnicodeString(&Name, L"."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"~1"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L".."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"ntdll.dll"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + + RtlInitUnicodeString(&Expression, L"smss.exe"); + RtlInitUnicodeString(&Name, L"."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"~1"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L".."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"ntdll.dll"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"NTDLL.dll"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"nt??krnl.???"); + RtlInitUnicodeString(&Name, L"ntoskrnl.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + + RtlInitUnicodeString(&Expression, L"he*o"); + RtlInitUnicodeString(&Name, L"hello"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"helo"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"hella"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"he*"); + RtlInitUnicodeString(&Name, L"hello"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"helo"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"hella"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + + RtlInitUnicodeString(&Expression, L"*.cpl"); + RtlInitUnicodeString(&Name, L"kdcom.dll"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"bootvid.dll"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"ntoskrnl.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"."); + RtlInitUnicodeString(&Name, L"NTDLL.DLL"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"F0_*.*"); + RtlInitUnicodeString(&Name, L"."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L".."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"SETUP.EXE"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"F0_001"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"*.TTF"); + RtlInitUnicodeString(&Name, L"."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L".."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Name, L"SETUP.INI"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"*"); + RtlInitUnicodeString(&Name, L"."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L".."); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Name, L"SETUP.INI"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID +NtoskrnlFsRtlTest(HANDLE KeyHandle) +{ + FsRtlIsNameInExpressionTest(); + + FinishTest(KeyHandle, L"FsRtlTest"); +}