mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 07:26:47 +00:00
[KMTESTS:KERNEL32]
- Add additional file attribute tests. Based on a patch by Katayama Hirofumi MZ. CORE-13495 svn path=/trunk/; revision=75861
This commit is contained in:
parent
69f853d085
commit
fd6f688414
|
@ -1,8 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS kernel-mode tests
|
* PROJECT: ReactOS kernel-mode tests
|
||||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
|
||||||
* PURPOSE: Test for GetFileAttributes/SetFileAttributes
|
* PURPOSE: Test for GetFileAttributes/SetFileAttributes
|
||||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
* COPYRIGHT: Copyright 2017 Thomas Faber <thomas.faber@reactos.org>
|
||||||
|
* Copyright 2017 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <kmt_test.h>
|
#include <kmt_test.h>
|
||||||
|
@ -33,6 +34,11 @@ START_TEST(FileAttributes)
|
||||||
Ret = SetFileAttributesW(FileName, 0);
|
Ret = SetFileAttributesW(FileName, 0);
|
||||||
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
||||||
|
|
||||||
|
/* Set invalid attributes */
|
||||||
|
KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES, FILE_ATTRIBUTE_VALID_SET_FLAGS);
|
||||||
|
Ret = SetFileAttributesW(FileName, 0xFFFFFFFF);
|
||||||
|
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
||||||
|
|
||||||
/* Query read-only attribute */
|
/* Query read-only attribute */
|
||||||
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_READONLY);
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_READONLY);
|
||||||
Attributes = GetFileAttributesW(FileName);
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
@ -53,6 +59,47 @@ START_TEST(FileAttributes)
|
||||||
Attributes = GetFileAttributesW(FileName);
|
Attributes = GetFileAttributesW(FileName);
|
||||||
ok_eq_hex(Attributes, 0);
|
ok_eq_hex(Attributes, 0);
|
||||||
|
|
||||||
|
/* Query invalid attributes */
|
||||||
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, 0xFFFFFFFF);
|
||||||
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
ok_eq_hex(Attributes, 0xFFFFFFFF);
|
||||||
|
|
||||||
|
/** Directory attribute **/
|
||||||
|
/* Set read-only and directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_READONLY);
|
||||||
|
Ret = SetFileAttributesW(FileName, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
||||||
|
|
||||||
|
/* Set normal and directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL);
|
||||||
|
Ret = SetFileAttributesW(FileName, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
||||||
|
|
||||||
|
/* Set directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL);
|
||||||
|
Ret = SetFileAttributesW(FileName, FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
|
||||||
|
|
||||||
|
/* Query read-only and directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
ok_eq_hex(Attributes, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
|
/* Query read-only + normal + directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
ok_eq_hex(Attributes, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
|
/* Query normal and directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
ok_eq_hex(Attributes, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
|
/* Query directory attribute */
|
||||||
|
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
Attributes = GetFileAttributesW(FileName);
|
||||||
|
ok_eq_hex(Attributes, FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
KmtCloseDriver();
|
KmtCloseDriver();
|
||||||
KmtUnloadDriver();
|
KmtUnloadDriver();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS kernel-mode tests
|
* PROJECT: ReactOS kernel-mode tests
|
||||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
* LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
|
||||||
* PURPOSE: Test driver for kernel32 filesystem tests
|
* PURPOSE: Test driver for kernel32 filesystem tests
|
||||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
* COPYRIGHT: Copyright 2013-2017 Thomas Faber <thomas.faber@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <kmt_test.h>
|
#include <kmt_test.h>
|
||||||
|
@ -19,7 +19,9 @@ static KMT_IRP_HANDLER TestSetInformation;
|
||||||
|
|
||||||
static UNICODE_STRING ExpectedExpression = RTL_CONSTANT_STRING(L"<not set>");
|
static UNICODE_STRING ExpectedExpression = RTL_CONSTANT_STRING(L"<not set>");
|
||||||
static WCHAR ExpressionBuffer[MAX_PATH];
|
static WCHAR ExpressionBuffer[MAX_PATH];
|
||||||
|
static BOOLEAN ExpectingSetAttributes = FALSE;
|
||||||
static ULONG ExpectedSetAttributes = -1;
|
static ULONG ExpectedSetAttributes = -1;
|
||||||
|
static BOOLEAN ExpectingQueryAttributes = FALSE;
|
||||||
static ULONG ReturnQueryAttributes = -1;
|
static ULONG ReturnQueryAttributes = -1;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -92,6 +94,7 @@ TestMessageHandler(
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
ReturnQueryAttributes = *(PULONG)Buffer;
|
ReturnQueryAttributes = *(PULONG)Buffer;
|
||||||
|
ExpectingQueryAttributes = TRUE;
|
||||||
DPRINT("IOCTL_RETURN_QUERY_ATTRIBUTES: %lu\n", ReturnQueryAttributes);
|
DPRINT("IOCTL_RETURN_QUERY_ATTRIBUTES: %lu\n", ReturnQueryAttributes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +105,7 @@ TestMessageHandler(
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
ExpectedSetAttributes = *(PULONG)Buffer;
|
ExpectedSetAttributes = *(PULONG)Buffer;
|
||||||
|
ExpectingSetAttributes = TRUE;
|
||||||
DPRINT("IOCTL_EXPECT_SET_ATTRIBUTES: %lu\n", ExpectedSetAttributes);
|
DPRINT("IOCTL_EXPECT_SET_ATTRIBUTES: %lu\n", ExpectedSetAttributes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +172,7 @@ TestQueryInformation(
|
||||||
ok_eq_ulong(IoStackLocation->Parameters.QueryFile.FileInformationClass, FileBasicInformation);
|
ok_eq_ulong(IoStackLocation->Parameters.QueryFile.FileInformationClass, FileBasicInformation);
|
||||||
if (IoStackLocation->Parameters.QueryFile.FileInformationClass == FileBasicInformation)
|
if (IoStackLocation->Parameters.QueryFile.FileInformationClass == FileBasicInformation)
|
||||||
{
|
{
|
||||||
ok(ReturnQueryAttributes != (ULONG)-1, "Unexpected QUERY_INFORMATION call\n");
|
ok(ExpectingQueryAttributes, "Unexpected QUERY_INFORMATION call\n");
|
||||||
BasicInfo = Irp->AssociatedIrp.SystemBuffer;
|
BasicInfo = Irp->AssociatedIrp.SystemBuffer;
|
||||||
BasicInfo->CreationTime.QuadPart = 126011664000000000;
|
BasicInfo->CreationTime.QuadPart = 126011664000000000;
|
||||||
BasicInfo->LastAccessTime.QuadPart = 130899112800000000;
|
BasicInfo->LastAccessTime.QuadPart = 130899112800000000;
|
||||||
|
@ -176,6 +180,7 @@ TestQueryInformation(
|
||||||
BasicInfo->ChangeTime.QuadPart = 130899112800000000;
|
BasicInfo->ChangeTime.QuadPart = 130899112800000000;
|
||||||
BasicInfo->FileAttributes = ReturnQueryAttributes;
|
BasicInfo->FileAttributes = ReturnQueryAttributes;
|
||||||
ReturnQueryAttributes = -1;
|
ReturnQueryAttributes = -1;
|
||||||
|
ExpectingQueryAttributes = FALSE;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = sizeof(*BasicInfo);
|
Irp->IoStatus.Information = sizeof(*BasicInfo);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +210,7 @@ TestSetInformation(
|
||||||
ok_eq_ulong(IoStackLocation->Parameters.SetFile.FileInformationClass, FileBasicInformation);
|
ok_eq_ulong(IoStackLocation->Parameters.SetFile.FileInformationClass, FileBasicInformation);
|
||||||
if (IoStackLocation->Parameters.SetFile.FileInformationClass == FileBasicInformation)
|
if (IoStackLocation->Parameters.SetFile.FileInformationClass == FileBasicInformation)
|
||||||
{
|
{
|
||||||
ok(ExpectedSetAttributes != (ULONG)-1, "Unexpected SET_INFORMATION call\n");
|
ok(ExpectingSetAttributes, "Unexpected SET_INFORMATION call\n");
|
||||||
BasicInfo = Irp->AssociatedIrp.SystemBuffer;
|
BasicInfo = Irp->AssociatedIrp.SystemBuffer;
|
||||||
ok_eq_longlong(BasicInfo->CreationTime.QuadPart, 0LL);
|
ok_eq_longlong(BasicInfo->CreationTime.QuadPart, 0LL);
|
||||||
ok_eq_longlong(BasicInfo->LastAccessTime.QuadPart, 0LL);
|
ok_eq_longlong(BasicInfo->LastAccessTime.QuadPart, 0LL);
|
||||||
|
@ -213,6 +218,7 @@ TestSetInformation(
|
||||||
ok_eq_longlong(BasicInfo->ChangeTime.QuadPart, 0LL);
|
ok_eq_longlong(BasicInfo->ChangeTime.QuadPart, 0LL);
|
||||||
ok_eq_ulong(BasicInfo->FileAttributes, ExpectedSetAttributes);
|
ok_eq_ulong(BasicInfo->FileAttributes, ExpectedSetAttributes);
|
||||||
ExpectedSetAttributes = -1;
|
ExpectedSetAttributes = -1;
|
||||||
|
ExpectingSetAttributes = FALSE;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue