From 8edd5bdaa087f959729bb41af6e1608dc879cbd1 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Jul 2008 09:23:45 +0000 Subject: [PATCH] - Add IRP tests based on a Alexander Morozov's patch to Wine ("[try 3] Add tests for IoInitializeIrp and IoAllocateIrp"). svn path=/trunk/; revision=34947 --- rostests/drivers/kmtest/kmtest.c | 8 +-- rostests/drivers/kmtest/ntos_io.c | 92 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/rostests/drivers/kmtest/kmtest.c b/rostests/drivers/kmtest/kmtest.c index 77fc9c093db..d59bcbbb4e4 100644 --- a/rostests/drivers/kmtest/kmtest.c +++ b/rostests/drivers/kmtest/kmtest.c @@ -103,8 +103,7 @@ int kmtest_ok(int condition, const char *msg, ... ) /* * Test Declarations */ -VOID NtoskrnlIoMdlTest(); -VOID NtoskrnlIoDeviceInterface(); +VOID NtoskrnlIoTests(); VOID NtoskrnlObTest(); VOID NtoskrnlExecutiveTests(); VOID NtoskrnlPoolsTest(); @@ -120,10 +119,9 @@ DriverEntry(PDRIVER_OBJECT DriverObject, DbgPrint("\n===============================================\nKernel Mode Regression Test driver starting...\n"); //NtoskrnlExecutiveTests(); //NtoskrnlIoDeviceInterface(); - //NtoskrnlIoMdlTest(); + NtoskrnlIoTests(); //NtoskrnlObTest(); - //NtoskrnlObTest(); - NtoskrnlPoolsTest(); + //NtoskrnlPoolsTest(); return STATUS_SUCCESS; } diff --git a/rostests/drivers/kmtest/ntos_io.c b/rostests/drivers/kmtest/ntos_io.c index 9a662d22992..15884da34fa 100644 --- a/rostests/drivers/kmtest/ntos_io.c +++ b/rostests/drivers/kmtest/ntos_io.c @@ -3,6 +3,7 @@ * ReactOS Kernel Mode Regression Testing framework * * Copyright 2006 Aleksey Bragin + * 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 @@ -28,6 +29,9 @@ #define NDEBUG #include "debug.h" +VOID NtoskrnlIoDeviceInterface(); + + /* PUBLIC FUNCTIONS ***********************************************************/ VOID NtoskrnlIoMdlTest() @@ -79,3 +83,91 @@ VOID NtoskrnlIoMdlTest() 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(); +}