From 7d2b56ccb084e57ea4b15e8b0e4031d66a0d07ad Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 13 Sep 2016 09:57:52 +0000 Subject: [PATCH] [NTDLL_APITEST] RtlGenerate8dot3Name: show that we don't deal correctly with checksums while generating short names. Dedicated to Christoph svn path=/trunk/; revision=72666 --- .../apitests/ntdll/RtlGenerate8dot3Name.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/rostests/apitests/ntdll/RtlGenerate8dot3Name.c b/rostests/apitests/ntdll/RtlGenerate8dot3Name.c index 6aed32a2b0b..f13ebb75f96 100644 --- a/rostests/apitests/ntdll/RtlGenerate8dot3Name.c +++ b/rostests/apitests/ntdll/RtlGenerate8dot3Name.c @@ -56,6 +56,19 @@ ULONG Locales[LOCALES_COUNT][2] = {1252, 775}, // Used for Estonian }; +#define LONG_NAMES_COUNT 12 +PWSTR LongNames[LONG_NAMES_COUNT] = +{ + L"Long File Name 1.txt", L"Long File Name 2.txt", L"Long File Name 3.txt", L"Long File Name 4.txt", L"Long File Name 5.txt", L"Long File Name 6.txt", + L"Very Long File Name 1.txt", L"Very Long File Name 2.txt", L"Very Long File Name 3.txt", L"Very Long File Name 4.txt", L"Very Long File Name 5.txt", L"Very Long File Name 6.txt", +}; + +PWSTR LongShortNames[LONG_NAMES_COUNT] = +{ + L"LONGFI~1.TXT", L"LONGFI~2.TXT", L"LONGFI~3.TXT", L"LONGFI~4.TXT", L"LO1796~1.TXT", L"LO1796~2.TXT", + L"VERYLO~1.TXT", L"VERYLO~2.TXT", L"VERYLO~3.TXT", L"VERYLO~4.TXT", L"VED051~1.TXT", L"VED051~2.TXT", +}; + PVOID LoadCodePageData(ULONG Code) { char filename[MAX_PATH], sysdir[MAX_PATH]; @@ -141,4 +154,25 @@ START_TEST(RtlGenerate8dot3Name) ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", j, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); } } + + { + WCHAR Buffer[12]; + GENERATE_NAME_CONTEXT Context; + UNICODE_STRING LongName, ShortName, Expected; + + ShortName.Buffer = Buffer; + ShortName.MaximumLength = sizeof(Buffer); + + for (i = 0; i < LONG_NAMES_COUNT; ++i) + { + if (i % 6 == 0) RtlZeroMemory(&Context, sizeof(GENERATE_NAME_CONTEXT)); + + RtlInitUnicodeString(&LongName, LongNames[i]); + ShortName.Length = 0; + + RtlGenerate8dot3Name(&LongName, FALSE, &Context, &ShortName); + RtlInitUnicodeString(&Expected, LongShortNames[i]); + ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", i, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + } + } }