[SHELL32][APITESTS] Add tests of OpenAs_RunDLL
[reactos.git] / modules / rostests / kmtests / ntos_io / IoIrp.c
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
14 START_TEST(IoIrp)
15 {
16 USHORT size;
17 IRP *iorp;
18
19 // 1st test
20 size = sizeof(IRP) + 5 * sizeof(IO_STACK_LOCATION);
21 iorp = ExAllocatePool(NonPagedPool, size);
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 }