import math
import time
from lib.topolog import logger
+from lib.topotest import json_cmp
from mininet.net import Mininet
global net
if op != "wait":
self.l_line += 1
+
+ if op == "jsoncmp_pass" or op == "jsoncmp_fail":
+ returnJson = True
+
self.log(
"%s (#%d) %s:%s COMMAND:%s:%s:%s:%s:%s:"
% (
)
self.log("COMMAND OUTPUT:%s:" % report)
+ # JSON comparison
+ if op == "jsoncmp_pass" or op == "jsoncmp_fail":
+ try:
+ expect = json.loads(regexp)
+ except:
+ expect = None
+ self.log(
+ "WARNING: JSON load failed -- confirm regex input is in JSON format."
+ )
+ json_diff = json_cmp(js, expect)
+ if json_diff != None:
+ if op == "jsoncmp_fail":
+ success = True
+ else:
+ success = False
+ self.log("JSON DIFF:%s:" % json_diff)
+ ret = success
+ else:
+ if op == "jsoncmp_fail":
+ success = False
+ else:
+ success = True
+ self.result(target, success, result)
+ if js != None:
+ return js
+ return ret
+
# Experiment: can we achieve the same match behavior via DOTALL
# without converting newlines to spaces?
out_nl = out