test_ofctl: Compare sent messages in json representation
Currently, test_ofctl compares the sent messages in binary, so it is difficult to figure out the differences of the sent messages and the expected messages. This patch fixes to compare the sent messages in json representation in order to make easy to debug. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
beb3353e39
commit
a40efc3a45
@ -73,11 +73,12 @@ class Test_ofctl(unittest.TestCase):
|
||||
# expected message <--> sent message
|
||||
request.serialize()
|
||||
try:
|
||||
eq_(request.buf, dp.request_msg.buf)
|
||||
eq_(request.to_jsondict(), dp.request_msg.to_jsondict())
|
||||
except AssertionError as e:
|
||||
# For debugging
|
||||
json.dump(dp.request_msg.to_jsondict(),
|
||||
open('/tmp/' + name, 'w'), indent=3, sort_keys=True)
|
||||
open('/tmp/' + name + '_request.json', 'w'),
|
||||
indent=3, sort_keys=True)
|
||||
raise e
|
||||
|
||||
# expected output <--> return of ofctl
|
||||
@ -99,7 +100,8 @@ class Test_ofctl(unittest.TestCase):
|
||||
_remove(output, ['len', 'length']))
|
||||
except AssertionError as e:
|
||||
# For debugging
|
||||
json.dump(output, open('/tmp/' + name, 'w'), indent=4)
|
||||
json.dump(output, open('/tmp/' + name + '_reply.json', 'w'),
|
||||
indent=4)
|
||||
raise e
|
||||
|
||||
|
||||
@ -314,7 +316,7 @@ def _add_tests():
|
||||
parser_json_dir = os.path.join(parser_json_root, ofp_ver)
|
||||
ofctl_json_dir = os.path.join(ofctl_json_root, ofp_ver)
|
||||
for test in tests:
|
||||
name = 'test_ofctl_' + test['request']
|
||||
name = 'test_ofctl_' + ofp_ver + '_' + test['method'].__name__
|
||||
print('adding %s ...' % name)
|
||||
args = {}
|
||||
args_json_path = os.path.join(ofctl_json_dir, test['request'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user