ReactOS 0.4.15-dev-7846-g8ba6c66
IoIrp.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Io Regressions KM-Test (Irp)
5 * PROGRAMMER: Aleksey Bragin <aleksey@reactos.org>
6 */
7/* Based on code Copyright 2008 Etersoft (Alexander Morozov) */
8
9#include <kmt_test.h>
10
11#define NDEBUG
12#include <debug.h>
13
15{
17 IRP *iorp;
18
19 // 1st test
20 size = sizeof(IRP) + 5 * sizeof(IO_STACK_LOCATION);
22
23 if (NULL != iorp)
24 {
25 IoInitializeIrp(iorp, size, 5);
26
27 ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
28 ok(iorp->Size == size, "Irp size should be %d, but got %d\n",
29 iorp->Size, size);
30 ok(5 == iorp->StackCount, "Irp StackCount should be 5, but got %d\n",
31 iorp->StackCount);
32 ok(6 == iorp->CurrentLocation, "Irp CurrentLocation should be 6, but got %d\n",
33 iorp->CurrentLocation);
34 ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
35 ok ((PIO_STACK_LOCATION)(iorp + 1) + 5 ==
36 iorp->Tail.Overlay.CurrentStackLocation,
37 "CurrentStackLocation mismatch\n");
38
39 ExFreePool(iorp);
40 }
41
42 // 2nd test
43 size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION);
44 iorp = IoAllocateIrp(2, FALSE);
45
46 if (NULL != iorp)
47 {
48 ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
49 ok(iorp->Size >= size,
50 "Irp size should be more or equal to %d, but got %d\n",
51 iorp->Size, size);
52 ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n",
53 iorp->StackCount);
54 ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n",
55 iorp->CurrentLocation);
56 ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
57 ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 ==
58 iorp->Tail.Overlay.CurrentStackLocation,
59 "CurrentStackLocation mismatch\n");
60 ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags),
61 "IRP Allocation flags lack fixed size attribute\n");
62 ok(!(IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags),
63 "IRP Allocation flags should not have lookaside allocation\n");
64
65 IoFreeIrp(iorp);
66 }
67
68 // 3rd test
69 size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION);
70 iorp = IoAllocateIrp(2, TRUE);
71
72 if (NULL != iorp)
73 {
74 ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
75 ok(iorp->Size >= size,
76 "Irp size should be more or equal to %d, but got %d\n",
77 iorp->Size, size);
78 ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n",
79 iorp->StackCount);
80 ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n",
81 iorp->CurrentLocation);
82 ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
83 ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 ==
84 iorp->Tail.Overlay.CurrentStackLocation,
85 "CurrentStackLocation mismatch\n");
86 ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags),
87 "IRP Allocation flags lack fixed size attribute\n");
88 ok((IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags),
89 "IRP Allocation flags lack lookaside allocation\n");
90
91 IoFreeIrp(iorp);
92 }
93}
struct _IRP IRP
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
GLsizeiptr size
Definition: glext.h:5919
VOID NTAPI IoInitializeIrp(IN PIRP Irp, IN USHORT PacketSize, IN CCHAR StackSize)
Definition: irp.c:1854
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
unsigned short USHORT
Definition: pedump.c:61
#define IRP_LOOKASIDE_ALLOCATION
#define IRP_ALLOCATED_FIXED_SIZE