From 0a31dda0b688ca0fc2e1625255ccafcb04baddae Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 19 Nov 2010 21:42:52 +0100
Subject: [PATCH] Add consistency test for mcpu dispatch table

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 test/ganeti.mcpu_unittest.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/ganeti.mcpu_unittest.py b/test/ganeti.mcpu_unittest.py
index bdfd3a275..9f5687068 100755
--- a/test/ganeti.mcpu_unittest.py
+++ b/test/ganeti.mcpu_unittest.py
@@ -25,6 +25,7 @@
 import unittest
 
 from ganeti import mcpu
+from ganeti import opcodes
 
 import testutils
 
@@ -54,5 +55,14 @@ class TestLockAttemptTimeoutStrategy(unittest.TestCase):
       self.assert_(strat.NextAttempt() is None)
 
 
+class TestDispatchTable(unittest.TestCase):
+  def test(self):
+    for opcls in opcodes.OP_MAPPING.values():
+      if opcls is opcodes.OpCode or opcls is opcodes.OpTestDummy:
+        continue
+      self.assert_(opcls in mcpu.Processor.DISPATCH_TABLE,
+                   msg="%s missing handler class" % opcls)
+
+
 if __name__ == "__main__":
   testutils.GanetiTestProgram()
-- 
GitLab