Commit 0b69ca3f authored by Daniel Salzman's avatar Daniel Salzman

func-test: improve summary output

parent c80cc919
......@@ -86,7 +86,7 @@ for test in sorted(included):
# Check test directory.
test_dir = "%s/%s/%s" % (current_dir, tests_dir, test)
if not os.path.isdir(test_dir):
log.error("Invalid test name \'%s\': IGNORED" % test)
log.error("Test \'%s\':\tIGNORED (invalid folder)" % test)
continue
log.info("Test \'%s\'" % test)
......@@ -117,11 +117,14 @@ for test in sorted(included):
os.makedirs(out_dir, exist_ok=True)
params.test_dir = case_dir
params.out_dir = out_dir
params.err = False
params.case_log = open(out_dir + "/case.log", mode="a")
params.test = None
params.err = False
params.err_msg = ""
except OsError:
fail_cnt += 1
log.error("Can't create output directory %s" % out_dir)
log.error(" * case \'%s\':\tEXCEPTION (no dir \'%s\')" %
(case, out_dir))
continue
try:
......@@ -132,7 +135,8 @@ for test in sorted(included):
if args.debug:
traceback.print_exc()
else:
log.error(" EXCEPTION: " + format(exc))
log.error(" * case \'%s\':\tEXCEPTION (%s)" %
(case, format(exc)))
except BaseException as exc:
save_traceback(params.out_dir)
if args.debug:
......@@ -143,6 +147,13 @@ for test in sorted(included):
if params.test:
params.test.end()
exit(1)
else:
if params.err:
msg = " (%s)" % params.err_msg if params.err_msg else ""
log.info(" * case \'%s\':\tFAILED%s" % (case, msg))
fail_cnt += 1
else:
log.info(" * case \'%s\':\tOK" % case)
# Stop servers if still running.
if params.test:
......@@ -150,12 +161,6 @@ for test in sorted(included):
params.case_log.close()
if params.err:
log.info(" * case \'%s\':\tFAILED" % case)
fail_cnt += 1
else:
log.info(" * case \'%s\':\tOK" % case)
if fail_cnt:
log.info("TEST CASES: %i, FAILED: %i" % (case_cnt, fail_cnt))
exit(1)
......
......@@ -60,11 +60,18 @@ def err(text):
detail_log(text, True)
detail_log(SEP, True)
def set_err(msg):
'''Set error state'''
params.err = True
if not params.err_msg:
params.err_msg = msg
def isset(value, name):
'''Check if value is True'''
if not value:
params.err = True
set_err("IS SET " + name)
check_log("IS SET " + name, True)
detail_log(" False", True)
detail_log(SEP, True)
......@@ -73,7 +80,7 @@ def compare(value, expected, name):
'''Compare two values'''
if value != expected:
params.err = True
set_err("COMPARE " + name)
check_log("COMPARE " + name, True)
detail_log(" (" + str(value) + ") != (" + str(expected) + ")", True)
detail_log(SEP, True)
......@@ -84,7 +91,7 @@ def compare_sections(section1, section2, name):
if section1 == section2:
return
params.err = True
set_err("COMPARE section " + name)
detail_log("COMPARE %s SECTIONS" % name, True)
for rrset in section1:
......@@ -311,7 +318,7 @@ class Response(object):
return
else:
err("RDATA (" + str(rdata) + ") not in ANSWER section")
params.err = True
set_err("CHECK rdata")
def check_edns(self, nsid=None, buff_size=None):
compare(self.resp.edns, 0, "EDNS version")
......@@ -541,9 +548,9 @@ class DnsServer(object):
f.close()
if errcount > 0 or reachable > 0 or lost > 0:
params.err = True
err("%s memcheck: lost(%i B), reachable(%i B), errcount(%i)" \
% (self.name, lost, reachable, errcount))
set_err("VALGRIND")
def stop(self):
if self.proc:
......@@ -1195,14 +1202,14 @@ class DnsTest(object):
z_keys = sorted(list(z1_keys & z2_keys))
if z1_diff:
params.err = True
set_err("XFR DIFF")
detail_log("Extra records in %s:" % server1.name, True)
for key in z1_diff:
for record in z1.nodes[key]:
detail_log(" %s %s" % (key, str(record)), True)
if z2_diff:
params.err = True
set_err("XFR DIFF")
detail_log("Extra records in %s:" % server2.name, True)
for key in z2_diff:
for record in z2.nodes[key]:
......@@ -1213,7 +1220,7 @@ class DnsTest(object):
for key in z_keys:
if z1.nodes[key] != z2.nodes[key]:
params.err = True
set_err("XFR DIFF")
detail_log("Different nodes:", True)
detail_log("%s:" % server1.name, True)
for record in z1.nodes[key]:
......
......@@ -61,4 +61,4 @@ test = None
# Indication for failed test.
err = False
# What is wrong.
err_culprit = ""
err_msg = ""
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