From 77ef29ad7928291ec4e4b8b83badbbbe706725cc Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sat, 12 Apr 2014 12:06:47 +0000 Subject: [PATCH] [KMTESTS:NPFS] Add tests for volume information query. Could be completed for size, device, full size and attributes query. This is used to validate changes made in r62663. Tested by Thomas. CORE-7451 svn path=/trunk/; revision=62717 --- rostests/kmtests/CMakeLists.txt | 1 + rostests/kmtests/kmtest_drv/testlist.c | 2 + rostests/kmtests/npfs/NpfsVolumeInfo.c | 96 ++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 rostests/kmtests/npfs/NpfsVolumeInfo.c diff --git a/rostests/kmtests/CMakeLists.txt b/rostests/kmtests/CMakeLists.txt index 11d13698407..6a6209cdca6 100644 --- a/rostests/kmtests/CMakeLists.txt +++ b/rostests/kmtests/CMakeLists.txt @@ -32,6 +32,7 @@ list(APPEND KMTEST_DRV_SOURCE npfs/NpfsCreate.c npfs/NpfsHelpers.c npfs/NpfsReadWrite.c + npfs/NpfsVolumeInfo.c ntos_ex/ExCallback.c ntos_ex/ExDoubleList.c ntos_ex/ExFastMutex.c diff --git a/rostests/kmtests/kmtest_drv/testlist.c b/rostests/kmtests/kmtest_drv/testlist.c index 8cb7c06725b..9b35bd18d13 100644 --- a/rostests/kmtests/kmtest_drv/testlist.c +++ b/rostests/kmtests/kmtest_drv/testlist.c @@ -41,6 +41,7 @@ KMT_TESTFUNC Test_MmSection; KMT_TESTFUNC Test_NpfsConnect; KMT_TESTFUNC Test_NpfsCreate; KMT_TESTFUNC Test_NpfsReadWrite; +KMT_TESTFUNC Test_NpfsVolumeInfo; KMT_TESTFUNC Test_ObReference; KMT_TESTFUNC Test_ObType; KMT_TESTFUNC Test_ObTypeClean; @@ -95,6 +96,7 @@ const KMT_TEST TestList[] = { "NpfsConnect", Test_NpfsConnect }, { "NpfsCreate", Test_NpfsCreate }, { "NpfsReadWrite", Test_NpfsReadWrite }, + { "NpfsVolumeInfo", Test_NpfsVolumeInfo }, { "ObReference", Test_ObReference }, { "ObType", Test_ObType }, { "-ObTypeClean", Test_ObTypeClean }, diff --git a/rostests/kmtests/npfs/NpfsVolumeInfo.c b/rostests/kmtests/npfs/NpfsVolumeInfo.c new file mode 100644 index 00000000000..54590d47bf0 --- /dev/null +++ b/rostests/kmtests/npfs/NpfsVolumeInfo.c @@ -0,0 +1,96 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory + * PURPOSE: Kernel-Mode Test Suite NPFS volume information test + * PROGRAMMER: Pierre Schweitzer + */ + +#include +#include "npfs.h" + +#define MAX_INSTANCES 1 +#define IN_QUOTA 4096 +#define OUT_QUOTA 4096 + +static +VOID +TestVolumeInfo( + IN HANDLE ServerHandle) +{ + NTSTATUS Status; + IO_STATUS_BLOCK IoStatusBlock; + struct { + FILE_FS_VOLUME_INFORMATION; + WCHAR PartialName[2]; + } PartialInfo; + struct { + FILE_FS_VOLUME_INFORMATION; + WCHAR PartialName[10]; + } CompleteInfo; + + Status = ZwQueryVolumeInformationFile(ServerHandle, + &IoStatusBlock, + &CompleteInfo, + sizeof(CompleteInfo), + FileFsVolumeInformation); + ok_eq_hex(Status, STATUS_SUCCESS); + ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS); + ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0); + ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0); + ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0); + ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects"); + ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18); + ok_eq_ulong(IoStatusBlock.Information, 36); + ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"NamedPipe", 18), 18); + + Status = ZwQueryVolumeInformationFile(ServerHandle, + &IoStatusBlock, + &PartialInfo, + sizeof(PartialInfo), + FileFsVolumeInformation); + ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW); + ok_eq_hex(IoStatusBlock.Status, STATUS_BUFFER_OVERFLOW); + ok_eq_long(CompleteInfo.VolumeCreationTime.LowPart, 0); + ok_eq_long(CompleteInfo.VolumeCreationTime.HighPart, 0); + ok_eq_ulong(CompleteInfo.VolumeSerialNumber, 0); + ok_bool_false(CompleteInfo.SupportsObjects, "CompleteInfo.SupportsObjects"); + ok_eq_ulong(CompleteInfo.VolumeLabelLength, 18); + ok_eq_ulong(IoStatusBlock.Information, 32); + ok_eq_ulong(RtlCompareMemory(CompleteInfo.VolumeLabel, L"Na", 4), 4); +} + +static KSTART_ROUTINE RunTest; +static +VOID +NTAPI +RunTest( + IN PVOID Context) +{ + NTSTATUS Status; + HANDLE ServerHandle; + + UNREFERENCED_PARAMETER(Context); + + ServerHandle = INVALID_HANDLE_VALUE; + Status = NpCreatePipe(&ServerHandle, + DEVICE_NAMED_PIPE L"\\KmtestNpfsVolumeInfoTestPipe", + BYTE_STREAM, QUEUE, BYTE_STREAM, DUPLEX, + MAX_INSTANCES, + IN_QUOTA, + OUT_QUOTA); + ok_eq_hex(Status, STATUS_SUCCESS); + ok(ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "ServerHandle = %p\n", ServerHandle); + if (!skip(NT_SUCCESS(Status) && ServerHandle != NULL && ServerHandle != INVALID_HANDLE_VALUE, "No pipe\n")) + { + TestVolumeInfo(ServerHandle); + ObCloseHandle(ServerHandle, KernelMode); + } +} + +START_TEST(NpfsVolumeInfo) +{ + PKTHREAD Thread; + + Thread = KmtStartThread(RunTest, NULL); + KmtFinishThread(Thread, NULL); +}