Commit 9990c068 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add test case for OpCode list equivalence



For now, we only test that we don't define extra opcodes in the
Haskell code; once we have parity, we can enable the (for now)
commented-out lines that check the reverse.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 60f7f6a4
......@@ -56,7 +56,7 @@ import qualified Test.HUnit as HUnit
import Test.QuickCheck
import Test.QuickCheck.Monadic (assert, monadicIO, run, stop)
import Text.Printf (printf)
import Data.List (intercalate, nub, isPrefixOf)
import Data.List (intercalate, nub, isPrefixOf, sort, (\\))
import Data.Maybe
import qualified Data.Set as Set
import Control.Monad
......@@ -1617,8 +1617,26 @@ prop_OpCodes_serialization op =
J.Error e -> failTest $ "Cannot deserialise: " ++ e
J.Ok op' -> op ==? op'
-- | Check that Python and Haskell defined the same opcode list.
case_OpCodes_AllDefined :: HUnit.Assertion
case_OpCodes_AllDefined = do
py_stdout <- runPython "from ganeti import opcodes\n\
\print '\\n'.join(opcodes.OP_MAPPING.keys())" "" >>=
checkPythonResult
let py_ops = sort $ lines py_stdout
hs_ops = OpCodes.allOpIDs
-- extra_py = py_ops \\ hs_ops
extra_hs = hs_ops \\ py_ops
-- FIXME: uncomment when we have parity
-- HUnit.assertBool ("OpCodes missing from Haskell code:\n" ++
-- unlines extra_py) (null extra_py)
HUnit.assertBool ("Extra OpCodes in the Haskell code code:\n" ++
unlines extra_hs) (null extra_hs)
testSuite "OpCodes"
[ 'prop_OpCodes_serialization ]
[ 'prop_OpCodes_serialization
, 'case_OpCodes_AllDefined
]
-- ** Jobs tests
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment