Author: pschweitzer
Date: Wed Sep 23 21:30:22 2015
New Revision: 69336
URL:
http://svn.reactos.org/svn/reactos?rev=69336&view=rev
Log:
[KMTESTS:IO]
- Properly free handles in driver (spotted by Thomas)
- Remove dead code in driver (spotted by Thomas)
- Send an IOCTL to stop on symlinks to allow more precise tests
Modified:
trunk/rostests/kmtests/ntos_io/IoCreateFile.h
trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c
trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c
Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
==============================================================================
--- trunk/rostests/kmtests/ntos_io/IoCreateFile.h [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_io/IoCreateFile.h [iso-8859-1] Wed Sep 23 21:30:22 2015
@@ -8,7 +8,7 @@
#ifndef _KMTEST_IOCREATEFILE_H_
#define _KMTEST_IOCREATEFILE_H_
-#define IOCTL_CREATE_SYMLINK 1
-#define IOCTL_CREATE_NO_SYMLINK 2
+#define IOCTL_CALL_CREATE 1
+#define IOCTL_DISABLE_SYMLINK 2
#endif /* !defined _KMTEST_IOCREATEFILE_H_ */
Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
==============================================================================
--- trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_io/IoCreateFile_drv.c [iso-8859-1] Wed Sep 23 21:30:22
2015
@@ -57,6 +57,8 @@
PAGED_CODE();
}
+static volatile long gNoLinks = FALSE;
+
static
NTSTATUS
TestIrpHandler(
@@ -80,7 +82,7 @@
if (IoStack->MajorFunction == IRP_MJ_CREATE)
{
ok((IoStack->Parameters.Create.Options & FILE_OPEN_REPARSE_POINT) == 0,
"FILE_OPEN_REPARSE_POINT set\n");
- ok((IoStack->Flags == 0) || (IoStack->Flags == SL_STOP_ON_SYMLINK),
"IoStack->Flags = %lx\n", IoStack->Flags);
+ ok((IoStack->Flags == 0 && !gNoLinks) || (IoStack->Flags ==
SL_STOP_ON_SYMLINK && gNoLinks), "IoStack->Flags = %lx\n",
IoStack->Flags);
if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR))
{
@@ -155,17 +157,8 @@
Status = STATUS_SUCCESS;
}
- if (Status == STATUS_PENDING)
- {
- IoMarkIrpPending(Irp);
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- Status = STATUS_PENDING;
- }
- else
- {
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
@@ -176,8 +169,7 @@
static
NTSTATUS
TestIoCreateFile(
- IN PUNICODE_STRING Path,
- IN BOOLEAN NoLinks)
+ IN PUNICODE_STRING Path)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
@@ -203,7 +195,7 @@
0,
CreateFileTypeNone,
NULL,
- IO_NO_PARAMETER_CHECKING | (NoLinks ? IO_STOP_ON_SYMLINK :
0));
+ IO_NO_PARAMETER_CHECKING | (gNoLinks ? IO_STOP_ON_SYMLINK :
0));
if (NT_SUCCESS(Status))
{
NTSTATUS IntStatus;
@@ -222,7 +214,9 @@
"Expected: %wZ or %wZ. Opened: %wZ\n", &FileObjectFileName,
&DocumentsAndSettings, &FileObject->FileName);
ObDereferenceObject(FileObject);
}
- NtClose(Handle);
+
+ IntStatus = ObCloseHandle(Handle, KernelMode);
+ ok_eq_hex(IntStatus, STATUS_SUCCESS);
}
return Status;
@@ -243,8 +237,16 @@
switch (ControlCode)
{
- case IOCTL_CREATE_SYMLINK:
- case IOCTL_CREATE_NO_SYMLINK:
+ case IOCTL_DISABLE_SYMLINK:
+ {
+ if (InterlockedExchange(&gNoLinks, TRUE) == TRUE)
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
+ break;
+ }
+ case IOCTL_CALL_CREATE:
{
ANSI_STRING Path;
UNICODE_STRING PathW;
@@ -256,7 +258,7 @@
Status = RtlAnsiStringToUnicodeString(&PathW, &Path, TRUE);
ok_eq_hex(Status, STATUS_SUCCESS);
- Status = TestIoCreateFile(&PathW, (ControlCode ==
IOCTL_CREATE_NO_SYMLINK));
+ Status = TestIoCreateFile(&PathW);
RtlFreeUnicodeString(&PathW);
Modified: trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_io/IoCreateF…
==============================================================================
--- trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_io/IoCreateFile_user.c [iso-8859-1] Wed Sep 23 21:30:22
2015
@@ -21,18 +21,21 @@
KmtLoadDriver(L"IoCreateFile", FALSE);
KmtOpenDriver();
- Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, NonSymlinkedFileName);
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, NonSymlinkedFileName);
ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error);
- Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, SymlinkedFileName);
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, SymlinkedFileName);
ok(Error == ERROR_CANT_ACCESS_FILE, "Expected ERROR_CANT_ACCESS_FILE, got
%lx\n", Error); /* FIXME */
- Error = KmtSendStringToDriver(IOCTL_CREATE_SYMLINK, MountedPointFileName);
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, MountedPointFileName);
ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error);
- Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, NonSymlinkedFileName);
+ Error = KmtSendToDriver(IOCTL_DISABLE_SYMLINK);
ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error);
- Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, SymlinkedFileName);
+
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, NonSymlinkedFileName);
+ ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error);
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, SymlinkedFileName);
ok(Error == ERROR_MR_MID_NOT_FOUND, "Expected ERROR_MR_MID_NOT_FOUND, got
%lx\n", Error);
- Error = KmtSendStringToDriver(IOCTL_CREATE_NO_SYMLINK, MountedPointFileName);
+ Error = KmtSendStringToDriver(IOCTL_CALL_CREATE, MountedPointFileName);
ok(Error == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lx\n", Error);
KmtCloseDriver();