ReactOS  0.4.14-dev-358-gbef841c
RtlSplayTree.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 RtlGenericTable
5  * PROGRAMMER: arty
6  */
7 
8 #define KMT_EMULATE_KERNEL
9 #include <kmt_test.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
15 
18 {
20  (*((PCHAR)A) > *((PCHAR)B)) ? GenericGreaterThan :
22  return Result;
23 }
24 
25 static PVOID NTAPI
27 {
29  (NonPagedPool, sizeof(LIST_ENTRY) + ByteSize);
31  return &Entry[1];
32 }
33 
34 static VOID NTAPI
36 {
40 }
41 
42 static void RtlSplayTreeTest()
43 {
44  ULONG i, del;
45  PCHAR Ch;
46  CHAR Text[] = "the quick_brown!fOx-jUmp3d/0vER+THe^lazy.D@g";
47  CHAR NewE[] = "11111111111111111111111111111111110111111111";
50  (&Table,
54  NULL);
55  for (i = 0; Text[i]; i++) {
56  BOOLEAN WasNew;
58  (&Table,
59  &Text[i],
60  sizeof(Text[i]),
61  &WasNew);
62  ok(Ch && *Ch == Text[i], "Copy character into node\n");
63  ok(WasNew == (NewE[i] == '1'),
64  "Character newness didn't match for char %u: '%c'\n",
65  i, Text[i]);
66  }
67  for (Ch = (PCHAR)RtlEnumerateGenericTable(&Table, TRUE), i = 0;
68  Ch;
70  ok(strchr(Text, *Ch) != NULL, "Nonexistent character\n");
71  }
72  ok(RtlNumberGenericTableElements(&Table) == strlen(Text) - 1, "Not the right number of elements\n");
73  ok(RtlLookupElementGenericTable(&Table, "q") != NULL, "Could not lookup q\n");
74  ok(!RtlLookupElementGenericTable(&Table, "#"), "Found a character that shouldn't appear\n");
75  ok(strlen(Text) == i + 1, "Didn't enumerate enough characters\n");
76  del = 0;
77  for (i = 0; Text[i]; i++) {
78  if (NewE[i] == '1') {
79  BOOLEAN WasDeleted;
80  WasDeleted = RtlDeleteElementGenericTable(&Table, &Text[i]);
81  del += WasDeleted;
82  }
83  }
84  ok(!RtlNumberGenericTableElements(&Table), "Not zero elements\n");
85  ok(!RtlGetElementGenericTable(&Table, 0), "Elements left when we removed them all\n");
86  ok(strlen(Text) == del + 1, "Deleted too many times\n");
87  ok(IsListEmpty(&Allocations), "Didn't free all memory\n");
88 }
89 
90 START_TEST(RtlSplayTree)
91 {
94 }
struct _LIST_ENTRY * PLIST_ENTRY
signed char * PCHAR
Definition: retypes.h:7
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(_In_ PRTL_GENERIC_TABLE Table)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void RtlSplayTreeTest()
Definition: RtlSplayTree.c:42
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ BOOLEAN Restart)
#define Ch(x, y, z)
Definition: sha2.c:141
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
ULONG CLONG
Definition: umtypes.h:126
#define A(row, col)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable(PRTL_GENERIC_TABLE Table, PVOID A, PVOID B)
Definition: RtlSplayTree.c:17
static VOID NTAPI FreeRoutine(PRTL_GENERIC_TABLE Table, PVOID Buffer)
Definition: RtlSplayTree.c:35
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
#define PCHAR
Definition: match.c:90
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ ULONG I)
Definition: ttei1.cpp:12
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: typedefs.h:117
static VOID del(LPHIST_ENTRY item)
Definition: history.c:199
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ok(value,...)
Definition: atltest.h:57
#define B(row, col)
enum _RTL_GENERIC_COMPARE_RESULTS RTL_GENERIC_COMPARE_RESULTS
char * strchr(const char *String, int ch)
Definition: utclib.c:501
START_TEST(RtlSplayTree)
Definition: RtlSplayTree.c:90
static PVOID NTAPI AllocRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
Definition: RtlSplayTree.c:26
unsigned int ULONG
Definition: retypes.h:1
#define LIST_ENTRY(type)
Definition: queue.h:175
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:389
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_reads_bytes_(BufferSize) PVOID Buffer, _In_ CLONG BufferSize, _Out_opt_ PBOOLEAN NewElement)
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
char * Text
Definition: combotst.c:136
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14