Commit 6e202aa5 authored by Daniel Salzman's avatar Daniel Salzman

func-test: add case skipping if empty server

parent 92c556c2
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import argparse, importlib, logging, os, re, sys, tempfile, time, traceback import argparse, importlib, logging, os, re, sys, tempfile, time, traceback
current_dir = os.path.dirname(os.path.realpath(__file__)) current_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(current_dir + "/tools") sys.path.append(current_dir + "/tools")
import params import params, dnstest
# Parse command line arguments. # Parse command line arguments.
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
...@@ -78,6 +78,7 @@ log.info("Working directory %s" % outs_dir) ...@@ -78,6 +78,7 @@ log.info("Working directory %s" % outs_dir)
case_cnt = 0 case_cnt = 0
fail_cnt = 0 fail_cnt = 0
skip_cnt = 0
for test in sorted(included): for test in sorted(included):
# Skip excluded test set. # Skip excluded test set.
if test in excluded and not excluded[test]: if test in excluded and not excluded[test]:
...@@ -129,6 +130,9 @@ for test in sorted(included): ...@@ -129,6 +130,9 @@ for test in sorted(included):
try: try:
importlib.import_module("%s.%s.%s.test" % (tests_dir, test, case)) importlib.import_module("%s.%s.%s.test" % (tests_dir, test, case))
except dnstest.Skip as exc:
log.error(" * case \'%s\':\tSKIPPED (%s)" % (case, format(exc)))
skip_cnt += 1
except Exception as exc: except Exception as exc:
save_traceback(params.out_dir) save_traceback(params.out_dir)
if args.debug: if args.debug:
...@@ -161,10 +165,12 @@ for test in sorted(included): ...@@ -161,10 +165,12 @@ for test in sorted(included):
params.case_log.close() params.case_log.close()
msg_cases = "TEST CASES: %i" % case_cnt
msg_skips = ", SKIPPED: %i" % skip_cnt if skip_cnt > 0 else ""
msg_res = ", FAILED: %i" % fail_cnt if fail_cnt > 0 else ", SUCCESS"
log.info(msg_cases + msg_skips + msg_res)
if fail_cnt: if fail_cnt:
log.info("TEST CASES: %i, FAILED: %i" % (case_cnt, fail_cnt))
exit(1) exit(1)
else: else:
log.info("TEST CASES: %i, SUCCESS" % (case_cnt))
exit(0) exit(0)
...@@ -21,6 +21,10 @@ import zone_generate, params ...@@ -21,6 +21,10 @@ import zone_generate, params
SEP = "------------------------------------" SEP = "------------------------------------"
class Skip(Exception):
"""Exception for skipping current case."""
pass
def test_info(): def test_info():
'''Get current test case name''' '''Get current test case name'''
...@@ -691,6 +695,8 @@ class Bind(DnsServer): ...@@ -691,6 +695,8 @@ class Bind(DnsServer):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
if not params.bind_bin:
raise Skip("No Bind")
self.daemon_bin = params.bind_bin self.daemon_bin = params.bind_bin
self.control_bin = params.bind_ctl self.control_bin = params.bind_ctl
self.ctlkey = Tsig(alg="hmac-md5") self.ctlkey = Tsig(alg="hmac-md5")
...@@ -828,6 +834,8 @@ class Knot(DnsServer): ...@@ -828,6 +834,8 @@ class Knot(DnsServer):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
if not params.knot_bin:
raise Skip("No Knot")
self.daemon_bin = params.knot_bin self.daemon_bin = params.knot_bin
self.control_bin = params.knot_ctl self.control_bin = params.knot_ctl
...@@ -969,6 +977,8 @@ class Nsd(DnsServer): ...@@ -969,6 +977,8 @@ class Nsd(DnsServer):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
if not params.nsd_bin:
raise Skip("No NSD")
self.daemon_bin = params.nsd_bin self.daemon_bin = params.nsd_bin
self.control_bin = params.nsd_ctl self.control_bin = params.nsd_ctl
......
...@@ -15,7 +15,8 @@ def get_binary(env_name, default): ...@@ -15,7 +15,8 @@ def get_binary(env_name, default):
name = env if env else default name = env if env else default
path = shutil.which(name) path = shutil.which(name)
if not path: if not path:
raise Exception("Binary %s not found" % name) print("Binary \'%s\' not found" % name)
exit(1)
return path return path
def get_param(env_name, default): def get_param(env_name, default):
......
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