Author: fireball Date: Wed Jul 30 04:23:45 2008 New Revision: 34947
URL: http://svn.reactos.org/svn/reactos?rev=34947&view=rev Log: - Add IRP tests based on a Alexander Morozov's patch to Wine ("[try 3] Add tests for IoInitializeIrp and IoAllocateIrp").
Modified: trunk/rostests/drivers/kmtest/kmtest.c trunk/rostests/drivers/kmtest/ntos_io.c
Modified: trunk/rostests/drivers/kmtest/kmtest.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/drivers/kmtest/kmtest.c?re... ============================================================================== --- trunk/rostests/drivers/kmtest/kmtest.c [iso-8859-1] (original) +++ trunk/rostests/drivers/kmtest/kmtest.c [iso-8859-1] Wed Jul 30 04:23:45 2008 @@ -103,8 +103,7 @@ /* * Test Declarations */ -VOID NtoskrnlIoMdlTest(); -VOID NtoskrnlIoDeviceInterface(); +VOID NtoskrnlIoTests(); VOID NtoskrnlObTest(); VOID NtoskrnlExecutiveTests(); VOID NtoskrnlPoolsTest(); @@ -120,10 +119,9 @@ DbgPrint("\n===============================================\nKernel Mode Regression Test driver starting...\n"); //NtoskrnlExecutiveTests(); //NtoskrnlIoDeviceInterface(); - //NtoskrnlIoMdlTest(); + NtoskrnlIoTests(); //NtoskrnlObTest(); - //NtoskrnlObTest(); - NtoskrnlPoolsTest(); + //NtoskrnlPoolsTest();
return STATUS_SUCCESS; }
Modified: trunk/rostests/drivers/kmtest/ntos_io.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/drivers/kmtest/ntos_io.c?r... ============================================================================== --- trunk/rostests/drivers/kmtest/ntos_io.c [iso-8859-1] (original) +++ trunk/rostests/drivers/kmtest/ntos_io.c [iso-8859-1] Wed Jul 30 04:23:45 2008 @@ -3,6 +3,7 @@ * ReactOS Kernel Mode Regression Testing framework * * Copyright 2006 Aleksey Bragin aleksey@reactos.org + * Copyright 2008 Etersoft (Alexander Morozov) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -27,6 +28,9 @@
#define NDEBUG #include "debug.h" + +VOID NtoskrnlIoDeviceInterface(); +
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -79,3 +83,91 @@
FinishTest("NTOSKRNL Io Mdl"); } + +VOID NtoskrnlIoIrpTest() +{ + USHORT size; + IRP *iorp; + + // 1st test + size = sizeof(IRP) + 5 * sizeof(IO_STACK_LOCATION); + iorp = ExAllocatePool(NonPagedPool, size); + + if (NULL != iorp) + { + IoInitializeIrp(iorp, size, 5); + + ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type); + ok(iorp->Size == size, "Irp size should be %d, but got %d\n", + iorp->Size, size); + ok(5 == iorp->StackCount, "Irp StackCount should be 5, but got %d\n", + iorp->StackCount); + ok(6 == iorp->CurrentLocation, "Irp CurrentLocation should be 6, but got %d\n", + iorp->CurrentLocation); + ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n"); + ok ((PIO_STACK_LOCATION)(iorp + 1) + 5 == + iorp->Tail.Overlay.CurrentStackLocation, + "CurrentStackLocation mismatch\n"); + + ExFreePool(iorp); + } + + // 2nd test + size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION); + iorp = IoAllocateIrp(2, FALSE); + + if (NULL != iorp) + { + ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type); + ok(iorp->Size >= size, + "Irp size should be more or equal to %d, but got %d\n", + iorp->Size, size); + ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n", + iorp->StackCount); + ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n", + iorp->CurrentLocation); + ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n"); + ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 == + iorp->Tail.Overlay.CurrentStackLocation, + "CurrentStackLocation mismatch\n"); + ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags), + "IRP Allocation flags lack fixed size attribute\n"); + ok(!(IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags), + "IRP Allocation flags should not have lookaside allocation\n"); + + IoFreeIrp(iorp); + } + + // 3rd test + size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION); + iorp = IoAllocateIrp(2, TRUE); + + if (NULL != iorp) + { + ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type); + ok(iorp->Size >= size, + "Irp size should be more or equal to %d, but got %d\n", + iorp->Size, size); + ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n", + iorp->StackCount); + ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n", + iorp->CurrentLocation); + ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n"); + ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 == + iorp->Tail.Overlay.CurrentStackLocation, + "CurrentStackLocation mismatch\n"); + ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags), + "IRP Allocation flags lack fixed size attribute\n"); + ok((IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags), + "IRP Allocation flags lack lookaside allocation\n"); + + IoFreeIrp(iorp); + } +} + +VOID NtoskrnlIoTests() +{ + //NtoskrnlIoMdlTest(); + //NtoskrnlIoDeviceInterface(); + NtoskrnlIoIrpTest(); +}