Author: pschweitzer Date: Fri Mar 25 18:53:43 2016 New Revision: 71046
URL: http://svn.reactos.org/svn/reactos?rev=71046&view=rev Log: [KMTESTS] - Define a new macro function KmtGetSystemOrEmbeddedRoutineAddress() which is to be used to get a function address from Mm if it exists system-wide or to fallback to embedded function if it doesn't exist - Use this mechanism to add tests for the newly implemented FsRtlRemoveDotsFromPath() which is Vista+.
That allows, with a single build (and thus, same binaries), testing a function in ReactOS and in Windows.
Added: trunk/rostests/kmtests/novp_fsrtl/ trunk/rostests/kmtests/novp_fsrtl/FsRtlRemoveDotsFromPath.c (with props) Modified: trunk/rostests/kmtests/CMakeLists.txt trunk/rostests/kmtests/include/kmt_test.h trunk/rostests/kmtests/kmtest_drv/testlist.c
Modified: trunk/rostests/kmtests/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?rev... ============================================================================== --- trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] Fri Mar 25 18:53:43 2016 @@ -36,6 +36,7 @@ npfs/NpfsHelpers.c npfs/NpfsReadWrite.c npfs/NpfsVolumeInfo.c + novp_fsrtl/FsRtlRemoveDotsFromPath.c ntos_cm/CmSecurity.c ntos_ex/ExCallback.c ntos_ex/ExDoubleList.c @@ -90,7 +91,7 @@
add_library(kmtest_drv SHARED ${KMTEST_DRV_SOURCE}) set_module_type(kmtest_drv kernelmodedriver) -target_link_libraries(kmtest_drv kmtest_printf chkstk memcmp ${PSEH_LIB}) +target_link_libraries(kmtest_drv kmtest_printf chkstk memcmp ntoskrnl_vista ${PSEH_LIB}) add_importlibs(kmtest_drv ntoskrnl hal) add_dependencies(kmtest_drv bugcodes xdk) add_target_compile_definitions(kmtest_drv KMT_KERNEL_MODE NTDDI_VERSION=NTDDI_WS03SP1)
Modified: trunk/rostests/kmtests/include/kmt_test.h URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/include/kmt_test.h... ============================================================================== --- trunk/rostests/kmtests/include/kmt_test.h [iso-8859-1] (original) +++ trunk/rostests/kmtests/include/kmt_test.h [iso-8859-1] Fri Mar 25 18:53:43 2016 @@ -244,6 +244,16 @@ ok_eq_hex(ExceptionStatus, (ExpectedStatus)); \ }
+#define KmtGetSystemOrEmbeddedRoutineAddress(RoutineName) \ + p##RoutineName = KmtGetSystemRoutineAddress(L ## #RoutineName); \ + if (!p##RoutineName) \ + { \ + p##RoutineName = RoutineName; \ + trace("Using embedded routine for " #RoutineName "\n"); \ + } \ + else \ + trace("Using system routine for " #RoutineName "\n"); + #if defined KMT_DEFINE_TEST_FUNCTIONS
#if defined KMT_KERNEL_MODE
Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testlis... ============================================================================== --- trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] Fri Mar 25 18:53:43 2016 @@ -24,6 +24,7 @@ KMT_TESTFUNC Test_FsRtlExpression; KMT_TESTFUNC Test_FsRtlLegal; KMT_TESTFUNC Test_FsRtlMcb; +KMT_TESTFUNC Test_FsRtlRemoveDotsFromPath; KMT_TESTFUNC Test_FsRtlTunnel; KMT_TESTFUNC Test_IoCreateFile; KMT_TESTFUNC Test_IoDeviceInterface; @@ -91,6 +92,7 @@ { "FsRtlExpression", Test_FsRtlExpression }, { "FsRtlLegal", Test_FsRtlLegal }, { "FsRtlMcb", Test_FsRtlMcb }, + { "FsRtlRemoveDotsFromPath", Test_FsRtlRemoveDotsFromPath }, { "FsRtlTunnel", Test_FsRtlTunnel }, { "IoCreateFile", Test_IoCreateFile }, { "IoDeviceInterface", Test_IoDeviceInterface },
Added: trunk/rostests/kmtests/novp_fsrtl/FsRtlRemoveDotsFromPath.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/novp_fsrtl/FsRtlRe... ============================================================================== --- trunk/rostests/kmtests/novp_fsrtl/FsRtlRemoveDotsFromPath.c (added) +++ trunk/rostests/kmtests/novp_fsrtl/FsRtlRemoveDotsFromPath.c [iso-8859-1] Fri Mar 25 18:53:43 2016 @@ -0,0 +1,59 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Tests for FsRtlRemoveDotsFromPath + * PROGRAMMER: Pierre Schweitzer pierre@reactos.org + */ + +#include <kmt_test.h> + +#define NDEBUG +#include <debug.h> + +#define InitConstString(s, c) \ + wcscpy(s.Buffer, c); \ + s.Buffer[sizeof(c) / sizeof(WCHAR) - 1] = 0; \ + s.Length = sizeof(c) - sizeof(UNICODE_NULL) + +NTSTATUS NTAPI FsRtlRemoveDotsFromPath(PWSTR OriginalString, + USHORT PathLength, USHORT *NewLength); + +static +NTSTATUS +(NTAPI *pFsRtlRemoveDotsFromPath)(PWSTR OriginalString, + USHORT PathLength, USHORT *NewLength); + +START_TEST(FsRtlRemoveDotsFromPath) +{ + WCHAR Buf[255]; + UNICODE_STRING TestString; + NTSTATUS Status; + + TestString.Buffer = Buf; + TestString.MaximumLength = sizeof(Buf); + KmtGetSystemOrEmbeddedRoutineAddress(FsRtlRemoveDotsFromPath); + ASSERT(pFsRtlRemoveDotsFromPath); + + InitConstString(TestString, L"\.."); + Status = pFsRtlRemoveDotsFromPath(TestString.Buffer, TestString.Length, &TestString.Length); + ok_eq_hex(Status, STATUS_IO_REPARSE_DATA_INVALID); + + InitConstString(TestString, L".."); + Status = pFsRtlRemoveDotsFromPath(TestString.Buffer, TestString.Length, &TestString.Length); + ok_eq_hex(Status, STATUS_IO_REPARSE_DATA_INVALID); + + InitConstString(TestString, L"..\anyOtherContent"); + Status = pFsRtlRemoveDotsFromPath(TestString.Buffer, TestString.Length, &TestString.Length); + ok_eq_hex(Status, STATUS_IO_REPARSE_DATA_INVALID); + + InitConstString(TestString, L"\\.."); + Status = pFsRtlRemoveDotsFromPath(TestString.Buffer, TestString.Length, &TestString.Length); + ok_eq_hex(Status, STATUS_SUCCESS); + ok_eq_wstr(TestString.Buffer, L"\"); + + InitConstString(TestString, L"\dir1\dir2\..\dir3\.\file.txt"); + Status = pFsRtlRemoveDotsFromPath(TestString.Buffer, TestString.Length, &TestString.Length); + ok_eq_hex(Status, STATUS_SUCCESS); + ok_eq_wstr(TestString.Buffer, L"\dir1\dir3\file.txt"); +} +
Propchange: trunk/rostests/kmtests/novp_fsrtl/FsRtlRemoveDotsFromPath.c ------------------------------------------------------------------------------ svn:eol-style = native