Commit 0bff0b12 authored by Michael Hanselmann's avatar Michael Hanselmann

cmdlib: Remove opcode parameters

Remove the parameter definitions and use those from the opcode classes
instead. Small style changes are also made (empty lines, wrapping).
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 65e183af
This diff is collapsed.
......@@ -69,33 +69,12 @@ class TestOpcodeParams(testutils.GanetiTestCase):
for op in sorted(mcpu.Processor.DISPATCH_TABLE):
lu = mcpu.Processor.DISPATCH_TABLE[op]
lu_name = lu.__name__
self.failIf(hasattr(lu, "_OP_REQP"), "LU '%s' has old-style _OP_REQP" %
lu_name)
self.failIf(hasattr(lu, "_OP_DEFS"), "LU '%s' has old-style _OP_DEFS" %
lu_name)
# this needs to remain a list!
defined_params = [v[0] for v in lu._OP_PARAMS]
for row in lu._OP_PARAMS:
# this relies on there being at least one element
param_name = row[0]
self.failIf(len(row) != 3, "LU '%s' parameter %s has invalid length" %
(lu_name, param_name))
self.failIf(defined_params.count(param_name) > 1, "LU '%s' parameter"
" '%s' is defined multiple times" % (lu_name, param_name))
def testParamsDefined(self):
for op in sorted(mcpu.Processor.DISPATCH_TABLE):
lu = mcpu.Processor.DISPATCH_TABLE[op]
lu_name = lu.__name__
# TODO: this doesn't deal with recursive slots definitions
all_params = set(op.__slots__)
defined_params = set(v[0] for v in lu._OP_PARAMS)
missing = all_params.difference(defined_params)
self.failIf(missing, "Undeclared parameter types for LU '%s': %s" %
(lu_name, utils.CommaJoin(missing)))
extra = defined_params.difference(all_params)
self.failIf(extra, "Extra parameter types for LU '%s': %s" %
(lu_name, utils.CommaJoin(extra)))
self.failIf(hasattr(lu, "_OP_REQP"),
msg=("LU '%s' has old-style _OP_REQP" % lu_name))
self.failIf(hasattr(lu, "_OP_DEFS"),
msg=("LU '%s' has old-style _OP_DEFS" % lu_name))
self.failIf(hasattr(lu, "_OP_PARAMS"),
msg=("LU '%s' has old-style _OP_PARAMS" % lu_name))
class TestIAllocatorChecks(testutils.GanetiTestCase):
......
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