Small improvements to the DRBD parser and tests
authorMichele Tartara <mtartara@google.com>
Fri, 23 Nov 2012 13:26:46 +0000 (14:26 +0100)
committerMichele Tartara <mtartara@google.com>
Tue, 27 Nov 2012 10:06:35 +0000 (11:06 +0100)
* 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 <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

htest/Test/Ganeti/Block/Drbd/Parser.hs
htest/test.hs
htools/Ganeti/Block/Drbd/Parser.hs

index 1f969e2..a59a77c 100644 (file)
@@ -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,
index ed9355f..eade8bf 100644 (file)
@@ -81,7 +81,7 @@ allTests =
   , testCommon
   , testConfd_Utils
   , testDaemon
-  , testBlock_DRBDParser
+  , testBlock_Drbd_Parser
   , testErrors
   , testHTools_Backend_Simu
   , testHTools_Backend_Text
index 5a78858..d20b615 100644 (file)
@@ -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