From 909eb635f227d99f4d6881e98146100d60561ecc Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 17 Apr 2016 21:17:49 +0000 Subject: [PATCH] [KMTESTS:FSRTL] Add more failing tests for MCB. These are pretty basics and deal with holes. They are pretty handy to show how broken the current MCB implementation is, in regard to holes management: it fails at properly counting runs when there are holes and it creates virtual runs (hence the broken count) for each hole. This shouldn't happen. CORE-11002 svn path=/trunk/; revision=71177 --- rostests/kmtests/ntos_fsrtl/FsRtlMcb.c | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/rostests/kmtests/ntos_fsrtl/FsRtlMcb.c b/rostests/kmtests/ntos_fsrtl/FsRtlMcb.c index d7574d329e1..54ead1c9893 100644 --- a/rostests/kmtests/ntos_fsrtl/FsRtlMcb.c +++ b/rostests/kmtests/ntos_fsrtl/FsRtlMcb.c @@ -318,6 +318,52 @@ static VOID FsRtlLargeMcbTest() DumpAllRuns(&LargeMcb); FsRtlUninitializeLargeMcb(&LargeMcb); + + FsRtlInitializeLargeMcb(&LargeMcb, PagedPool); + NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb); + ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns); + + ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1) == TRUE, "expected TRUE, got FALSE\n"); + NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb); + ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn); + ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + DumpAllRuns(&LargeMcb); + + + ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 10, 1) == TRUE, "expected TRUE, got FALSE\n"); + NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb); + ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn); + ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn); + ok(Lbn == 10, "Expected Lbn 10, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + DumpAllRuns(&LargeMcb); + + ok(FsRtlAddLargeMcbEntry(&LargeMcb, 2, 20, 1) == TRUE, "expected TRUE, got FALSE\n"); + NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb); + ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn); + ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn); + ok(Lbn == 10, "Expected Lbn 10, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n"); + ok(Vbn == 2, "Expected Vbn 2, got: %I64d\n", Vbn); + ok(Lbn == 20, "Expected Lbn 20, got: %I64d\n", Lbn); + ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount); + DumpAllRuns(&LargeMcb); + + FsRtlUninitializeLargeMcb(&LargeMcb); } static VOID FsRtlLargeMcbTestsExt2() -- 2.17.1