Commit c1ea0462 authored by Daniel Salzman's avatar Daniel Salzman

func-test: add default directory for zones

parent 45120880
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse, importlib, os, re, sys, tempfile, time, traceback import argparse, importlib, os, re, sys, tempfile, time, traceback
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/tools") current_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(current_dir + "/tools")
from dnstest import log, err from dnstest import log, err
import params import params
...@@ -12,6 +13,7 @@ parser.add_argument("tests", metavar="[:]test[/case]", nargs="*", \ ...@@ -12,6 +13,7 @@ parser.add_argument("tests", metavar="[:]test[/case]", nargs="*", \
help="([exclude] | run) specific (test set | [test case])") help="([exclude] | run) specific (test set | [test case])")
args = parser.parse_args() args = parser.parse_args()
params.common_data_dir = current_dir + "/tools/data/"
outs_dir = tempfile.mkdtemp(prefix="knottest-%s-" % int(time.time())) outs_dir = tempfile.mkdtemp(prefix="knottest-%s-" % int(time.time()))
tests_dir = "tests" tests_dir = "tests"
test_cnt = 0 test_cnt = 0
......
$ORIGIN example.com.
$TTL 3600
@ SOA dns1.example.com. hostmaster.example.com. (
2010111213 ; serial
6h ; refresh
1h ; retry
1w ; expire
1d ) ; minimum
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
...@@ -6,8 +6,8 @@ import dnstest ...@@ -6,8 +6,8 @@ import dnstest
t = dnstest.DnsTest() t = dnstest.DnsTest()
srv = t.server("bind") srv = t.server("knot")
zone = t.zone("example.com.", "example.com.zone") zone = t.zone("example.com.")
t.link(zone, srv, ddns=True) t.link(zone, srv, ddns=True)
......
...@@ -926,17 +926,22 @@ class DnsTest(object): ...@@ -926,17 +926,22 @@ class DnsTest(object):
for server in self.servers: for server in self.servers:
server._valgrind_check() server._valgrind_check()
def zone(self, name, filename): def zone(self, zone_name, file_name=None):
# Add trailing dot if missing.
if zone_name[-1] != ".":
zone_name += "."
try: try:
src_file = self.data_dir + filename if file_name:
dst_file = self.zones_dir + filename src_file = self.data_dir + file_name
dst_file = self.zones_dir + file_name
else:
src_file = params.common_data_dir + zone_name + "zone"
dst_file = self.zones_dir + zone_name + "zone"
shutil.copyfile(src_file, dst_file) shutil.copyfile(src_file, dst_file)
except: except:
raise Exception("Can't use zone file %s" % filename) raise Exception("Can't use zone file %s" % src_file)
zone_name = name
if zone_name[-1] != ".":
zone_name += "."
return {zone_name: dst_file} return {zone_name: dst_file}
......
...@@ -5,6 +5,8 @@ This module allows interchanging of running parameters between modules. ...@@ -5,6 +5,8 @@ This module allows interchanging of running parameters between modules.
All variables are set automatically. All variables are set automatically.
''' '''
# Common data directory.
common_data_dir = ""
# Current case relative directory. # Current case relative directory.
test_dir = "" test_dir = ""
# Current case absolute output directory. # Current case absolute output directory.
......
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