Skip to content
Snippets Groups Projects
Commit 9b773665 authored by Iustin Pop's avatar Iustin Pop
Browse files

Enable equivalence checks of opcode list


This patch enhances the opcode list checks - instead of spawning a
Python interpreter to display the opcode list, we export it statically
in Constants.hs via a slight convert-constants change.

Furthermore, since we now have opcode parity, we enable full opcode
list checks.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 1cd563e2
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ from ganeti import compat
from ganeti import constants
from ganeti import errors
from ganeti import luxi
from ganeti import opcodes
from ganeti import qlang
......@@ -296,12 +297,23 @@ def Convert(module, prefix):
return "\n".join(lines)
def ConvertMisc():
"""Convert some extra computed-values to Haskell.
"""
lines = [""]
lines.extend(ConvertVariable("opcodes", "OP_IDS",
opcodes.OP_MAPPING.keys(), {}))
return "\n".join(lines)
def main():
print Convert(constants, "")
print Convert(luxi, "luxi")
print Convert(qlang, "qlang")
print Convert(_autoconf, "autoconf")
print Convert(errors, "errors")
print ConvertMisc()
if __name__ == "__main__":
......
......@@ -410,16 +410,12 @@ prop_serialization = testSerialisation
-- | Check that Python and Haskell defined the same opcode list.
case_AllDefined :: HUnit.Assertion
case_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
let py_ops = sort C.opcodesOpIds
hs_ops = sort 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 ("Missing OpCodes from the 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment