From fd80be110509dacf0c0c5eb64907814ef30aa28c Mon Sep 17 00:00:00 2001 From: Michele Tartara Date: Fri, 23 Nov 2012 14:26:46 +0100 Subject: [PATCH] Small improvements to the DRBD parser and tests * Now the parser completely consumes the input, up to the end of the text. * Name of the test suite module changed to adhere to naming conventions. * Some reformatting of the source code. Signed-off-by: Michele Tartara Reviewed-by: Iustin Pop --- htest/Test/Ganeti/Block/Drbd/Parser.hs | 11 ++++++----- htest/test.hs | 2 +- htools/Ganeti/Block/Drbd/Parser.hs | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htest/Test/Ganeti/Block/Drbd/Parser.hs b/htest/Test/Ganeti/Block/Drbd/Parser.hs index 1f969e2..a59a77c 100644 --- a/htest/Test/Ganeti/Block/Drbd/Parser.hs +++ b/htest/Test/Ganeti/Block/Drbd/Parser.hs @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -} -module Test.Ganeti.Block.Drbd.Parser (testBlock_DRBDParser) where +module Test.Ganeti.Block.Drbd.Parser (testBlock_Drbd_Parser) where import Test.QuickCheck as QuickCheck hiding (Result) import Test.HUnit @@ -344,9 +344,10 @@ prop_commaInt_max3WithoutComma = Right obtained -> obtained < 1000 .&&. getFirst3Digits i ==? obtained - where getFirst3Digits x = if x >= 1000 - then getFirst3Digits $ x `div` 10 - else x + where getFirst3Digits x = + if x >= 1000 + then getFirst3Digits $ x `div` 10 + else x -- | Test if non-triplets are handled correctly (they are assumed NOT being part -- of the number). @@ -354,7 +355,7 @@ case_commaInt_non_triplet :: Assertion case_commaInt_non_triplet = testCommaInt "61,736,12" 61736 -testSuite "Block_DRBDParser" +testSuite "Block/Drbd/Parser" [ 'case_drbd80_emptyline, 'case_drbd83_sync_krnl2_6_39, 'case_drbd83_sync, diff --git a/htest/test.hs b/htest/test.hs index ed9355f..eade8bf 100644 --- a/htest/test.hs +++ b/htest/test.hs @@ -81,7 +81,7 @@ allTests = , testCommon , testConfd_Utils , testDaemon - , testBlock_DRBDParser + , testBlock_Drbd_Parser , testErrors , testHTools_Backend_Simu , testHTools_Backend_Text diff --git a/htools/Ganeti/Block/Drbd/Parser.hs b/htools/Ganeti/Block/Drbd/Parser.hs index 5a78858..d20b615 100644 --- a/htools/Ganeti/Block/Drbd/Parser.hs +++ b/htools/Ganeti/Block/Drbd/Parser.hs @@ -64,6 +64,7 @@ drbdStatusParser :: Parser DRBDStatus drbdStatusParser = DRBDStatus <$> versionInfoParser <*> deviceParser `AC.manyTill` A.endOfInput + <* A.endOfInput -- | The parser for the version information lines. versionInfoParser :: Parser VersionInfo -- 1.7.10.4