Author: pschweitzer
Date: Wed Aug 10 20:50:36 2016
New Revision: 72192
URL:
http://svn.reactos.org/svn/reactos?rev=72192&view=rev
Log:
[KMTESTS:FSRTL]
Add a stress test for tunnel cache implementation, where we have fun adding duplicated
entries.
It doesn't seem to go well.
These tests are also known as "Learn your English ordinals", or as "Learn
how to count in English". My pleasure.
CORE-11819
Modified:
trunk/rostests/kmtests/ntos_fsrtl/FsRtlTunnel.c
Modified: trunk/rostests/kmtests/ntos_fsrtl/FsRtlTunnel.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_fsrtl/FsRtlT…
==============================================================================
--- trunk/rostests/kmtests/ntos_fsrtl/FsRtlTunnel.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_fsrtl/FsRtlTunnel.c [iso-8859-1] Wed Aug 10 20:50:36 2016
@@ -121,6 +121,116 @@
FsRtlDeleteKeyFromTunnelCache(T, a);
}
+static
+void DuplicatesTest()
+{
+ UNICODE_STRING ShortName, LongName, OutShort, OutLong, ShortName2, LongName2;
+ ULONG First, Second, OutLength, OutData;
+ PTUNNEL Tunnel;
+ PVOID Buffer;
+
+ First = 1;
+ Second = 2;
+ RtlInitUnicodeString(&ShortName, L"LONGFI~1.TXT");
+ RtlInitUnicodeString(&LongName, L"Longfilename.txt");
+ RtlInitUnicodeString(&ShortName2, L"LONGFI~2.TXT");
+ RtlInitUnicodeString(&LongName2, L"Longfilenamr.txt");
+ Tunnel = ExAllocatePool(NonPagedPool, sizeof(TUNNEL));
+ RtlZeroMemory(Tunnel, sizeof(TUNNEL));
+ OutShort.MaximumLength = 13 * sizeof(WCHAR);
+ OutShort.Buffer = ExAllocatePool(PagedPool, OutShort.MaximumLength);
+ OutLong.MaximumLength = 17 * sizeof(WCHAR);
+ OutLong.Buffer = Buffer = ExAllocatePool(PagedPool, OutLong.MaximumLength);
+
+ FsRtlInitializeTunnelCache(Tunnel);
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&First);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "First call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+ ok_eq_pointer(OutLong.Buffer, Buffer);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&Second);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Second call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok_eq_pointer(OutLong.Buffer, Buffer);
+
+ OutLong.MaximumLength = 13 * sizeof(WCHAR);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Third call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok(OutLong.Buffer != Buffer, "Buffer didn't get reallocated!\n");
+ ok_eq_uint(OutLong.MaximumLength, 16 * sizeof(WCHAR));
+
+ FsRtlDeleteKeyFromTunnelCache(Tunnel, 1);
+ ok_bool_false(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Fourth call");
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&First);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Fifth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName2, &LongName2, TRUE,
sizeof(ULONG), &First);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Sixth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Seventh call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&Second);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Eighth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Ninth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName2, &LongName2, TRUE,
sizeof(ULONG), &Second);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Tenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Eleventh call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+
+ FsRtlDeleteKeyFromTunnelCache(Tunnel, 1);
+ ok_bool_false(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Twelfth call");
+ ok_bool_false(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Thirteenth call");
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&First);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Fourteenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName, &LongName, TRUE, sizeof(ULONG),
&Second);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Fifteenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName2, &LongName2, TRUE,
sizeof(ULONG), &First);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Sixteenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Seventeenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 1);
+
+ FsRtlAddToTunnelCache(Tunnel, 1, &ShortName2, &LongName2, TRUE,
sizeof(ULONG), &Second);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName, &OutShort,
&OutLong, &OutLength, &OutData), "Eighteenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+ ok_bool_true(FsRtlFindInTunnelCache(Tunnel, 1, &ShortName2, &OutShort,
&OutLong, &OutLength, &OutData), "Nineteenth call");
+ ok_eq_ulong(OutLength, sizeof(ULONG));
+ ok_eq_ulong(OutData, 2);
+
+ FsRtlDeleteTunnelCache(Tunnel);
+ ExFreePool(OutShort.Buffer);
+ ExFreePool(OutLong.Buffer);
+ ExFreePool(Buffer);
+ ExFreePool(Tunnel);
+}
+
START_TEST(FsRtlTunnel)
{
PUNICODE_STRING s_name;
@@ -183,4 +293,6 @@
ExFreePool(Tb);
ExFreePool(T);
-}
+
+ DuplicatesTest();
+}