Author: tfaber
Date: Sun Sep 17 08:08:39 2017
New Revision: 75861
URL:
http://svn.reactos.org/svn/reactos?rev=75861&view=rev
Log:
[KMTESTS:KERNEL32]
- Add additional file attribute tests. Based on a patch by Katayama Hirofumi MZ.
CORE-13495
Modified:
trunk/rostests/kmtests/kernel32/FileAttributes_user.c
trunk/rostests/kmtests/kernel32/kernel32_drv.c
Modified: trunk/rostests/kmtests/kernel32/FileAttributes_user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kernel32/FileAttr…
==============================================================================
--- trunk/rostests/kmtests/kernel32/FileAttributes_user.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kernel32/FileAttributes_user.c [iso-8859-1] Sun Sep 17 08:08:39
2017
@@ -1,8 +1,9 @@
/*
- * PROJECT: ReactOS kernel-mode tests
- * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
- * PURPOSE: Test for GetFileAttributes/SetFileAttributes
- * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
+ * PURPOSE: Test for GetFileAttributes/SetFileAttributes
+ * COPYRIGHT: Copyright 2017 Thomas Faber <thomas.faber(a)reactos.org>
+ * Copyright 2017 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
*/
#include <kmt_test.h>
@@ -33,6 +34,11 @@
Ret = SetFileAttributesW(FileName, 0);
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 */
KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES, FILE_ATTRIBUTE_READONLY);
Attributes = GetFileAttributesW(FileName);
@@ -53,6 +59,47 @@
Attributes = GetFileAttributesW(FileName);
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();
KmtUnloadDriver();
}
Modified: trunk/rostests/kmtests/kernel32/kernel32_drv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kernel32/kernel32…
==============================================================================
--- trunk/rostests/kmtests/kernel32/kernel32_drv.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kernel32/kernel32_drv.c [iso-8859-1] Sun Sep 17 08:08:39 2017
@@ -1,8 +1,8 @@
/*
- * PROJECT: ReactOS kernel-mode tests
- * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
- * PURPOSE: Test driver for kernel32 filesystem tests
- * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
+ * PURPOSE: Test driver for kernel32 filesystem tests
+ * COPYRIGHT: Copyright 2013-2017 Thomas Faber <thomas.faber(a)reactos.org>
*/
#include <kmt_test.h>
@@ -19,7 +19,9 @@
static UNICODE_STRING ExpectedExpression = RTL_CONSTANT_STRING(L"<not
set>");
static WCHAR ExpressionBuffer[MAX_PATH];
+static BOOLEAN ExpectingSetAttributes = FALSE;
static ULONG ExpectedSetAttributes = -1;
+static BOOLEAN ExpectingQueryAttributes = FALSE;
static ULONG ReturnQueryAttributes = -1;
NTSTATUS
@@ -92,6 +94,7 @@
return STATUS_INVALID_PARAMETER;
ReturnQueryAttributes = *(PULONG)Buffer;
+ ExpectingQueryAttributes = TRUE;
DPRINT("IOCTL_RETURN_QUERY_ATTRIBUTES: %lu\n",
ReturnQueryAttributes);
break;
}
@@ -102,6 +105,7 @@
return STATUS_INVALID_PARAMETER;
ExpectedSetAttributes = *(PULONG)Buffer;
+ ExpectingSetAttributes = TRUE;
DPRINT("IOCTL_EXPECT_SET_ATTRIBUTES: %lu\n",
ExpectedSetAttributes);
break;
}
@@ -168,7 +172,7 @@
ok_eq_ulong(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->CreationTime.QuadPart = 126011664000000000;
BasicInfo->LastAccessTime.QuadPart = 130899112800000000;
@@ -176,6 +180,7 @@
BasicInfo->ChangeTime.QuadPart = 130899112800000000;
BasicInfo->FileAttributes = ReturnQueryAttributes;
ReturnQueryAttributes = -1;
+ ExpectingQueryAttributes = FALSE;
Status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(*BasicInfo);
}
@@ -205,7 +210,7 @@
ok_eq_ulong(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;
ok_eq_longlong(BasicInfo->CreationTime.QuadPart, 0LL);
ok_eq_longlong(BasicInfo->LastAccessTime.QuadPart, 0LL);
@@ -213,6 +218,7 @@
ok_eq_longlong(BasicInfo->ChangeTime.QuadPart, 0LL);
ok_eq_ulong(BasicInfo->FileAttributes, ExpectedSetAttributes);
ExpectedSetAttributes = -1;
+ ExpectingSetAttributes = FALSE;
Status = STATUS_SUCCESS;
}