From ef6df51b5efab13f59bcc72a6471dd118cbac072 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Fri, 15 Mar 2019 14:21:17 -0700 Subject: [PATCH] tst: winfsp-tests: ea_create_test --- tst/winfsp-tests/ea-test.c | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tst/winfsp-tests/ea-test.c b/tst/winfsp-tests/ea-test.c index 9f460733..b2cad7fd 100644 --- a/tst/winfsp-tests/ea-test.c +++ b/tst/winfsp-tests/ea-test.c @@ -139,6 +139,7 @@ static void ea_check_ea(HANDLE Handle) UINT8 B[128]; } GetEa; ULONG EaLength = 0; + ULONG EaIndex; struct ea_check_ea_context Context; memset(&Context, 0, sizeof Context); @@ -190,6 +191,13 @@ static void ea_check_ea(HANDLE Handle) ASSERT(1 == Context.EaCount[1]); ASSERT(0 == Context.EaCount[2]); + memset(&Context, 0, sizeof Context); + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("bnameTwo") + 1), + FALSE, &GetEa.V, EaLength, 0, FALSE); + ASSERT(STATUS_BUFFER_OVERFLOW == Result); + ASSERT(0 == Iosb.Information); + memset(&Context, 0, sizeof Context); Result = NtQueryEaFile(Handle, &Iosb, &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("Aname1") + 1), @@ -259,6 +267,87 @@ static void ea_check_ea(HANDLE Handle) memset(&Context, 0, sizeof Context); Result = NtQueryEaFile(Handle, &Iosb, &Ea, sizeof Ea, FALSE, 0, 0, 0, FALSE); ASSERT(STATUS_NO_MORE_EAS == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 0; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, sizeof Ea, + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_NONEXISTENT_EA_ENTRY == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 1; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("Aname1") + 1), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_BUFFER_TOO_SMALL == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 1; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("Aname1") + 1 + strlen("first")), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_BUFFER_OVERFLOW == Result); + Result = FspFileSystemEnumerateEa(0, ea_check_ea_enumerate, &Context, &Ea.V, (ULONG)Iosb.Information); + ASSERT(STATUS_SUCCESS == Result); + ASSERT(1 == Context.Count); + ASSERT(1 == Context.EaCount[0]); + ASSERT(0 == Context.EaCount[1]); + ASSERT(0 == Context.EaCount[2]); + + memset(&Context, 0, sizeof Context); + EaIndex = 2; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("bnameTwo") + 1), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_BUFFER_TOO_SMALL == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 2; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("bnameTwo") + 1 + strlen("bnameTwo")), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_BUFFER_OVERFLOW == Result); + Result = FspFileSystemEnumerateEa(0, ea_check_ea_enumerate, &Context, &Ea.V, (ULONG)Iosb.Information); + ASSERT(STATUS_SUCCESS == Result); + ASSERT(1 == Context.Count); + ASSERT(0 == Context.EaCount[0]); + ASSERT(1 == Context.EaCount[1]); + ASSERT(0 == Context.EaCount[2]); + + memset(&Context, 0, sizeof Context); + EaIndex = 3; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("Cn3") + 1), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_BUFFER_TOO_SMALL == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 3; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, (ULONG)(FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName) + strlen("Cn3") + 1 + strlen("third")), + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_SUCCESS == Result); + Result = FspFileSystemEnumerateEa(0, ea_check_ea_enumerate, &Context, &Ea.V, (ULONG)Iosb.Information); + ASSERT(STATUS_SUCCESS == Result); + ASSERT(1 == Context.Count); + ASSERT(0 == Context.EaCount[0]); + ASSERT(0 == Context.EaCount[1]); + ASSERT(1 == Context.EaCount[2]); + + memset(&Context, 0, sizeof Context); + EaIndex = 4; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, sizeof Ea, + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_NO_MORE_EAS == Result); + + memset(&Context, 0, sizeof Context); + EaIndex = 5; + Result = NtQueryEaFile(Handle, &Iosb, + &Ea, sizeof Ea, + FALSE, 0, 0, &EaIndex, FALSE); + ASSERT(STATUS_NONEXISTENT_EA_ENTRY == Result); } static void ea_create_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)