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

func-test: initial commit

parent 9ab7f4c8
$ORIGIN .
$TTL 3601 ; 1 hour
example.com IN SOA dns1.example.com. hostmaster.example.com. (
2010111217 ; serial
21600 ; refresh (6 hours)
3600 ; retry (1 hour)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns1.example.com.
NS dns2.example.com.
MX 10 mail.example.com.
$ORIGIN example.com.
12345 A 1.2.3.5
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
$ORIGIN example2.com.
$TTL 3600
@ SOA dns1.example2.com. hostmaster.example2.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
#!/usr/bin/env python3
import os, sys
test_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(test_dir + "/../../tools")
from dnstest import *
################################################################################
t = DnsTest(test_dir, sys.argv[1])
master1 = t.server("knot", nsid="nsid", ident=True, version="Knot XXX")
master2 = t.server("knot", ident="ahoj")
slave = t.server("knot", ident="0xabcd")
#z1 = t.zone_rnd(10)
z1 = t.zone("example.com.", "example.com.zone")
z2 = t.zone("example2.com.", "example2.com.zone")
t.link(z1, master1, slave, ddns=True)
t.link(z2, master2, slave)
t.start()
t.stop()
'''
t.link(z2, master, slave2)
t.link(z2, master, slave1)
t.dig()
t.stop()
t.end()
'''
#!/usr/bin/env python3
import os, sys, tempfile, time
import subprocess
def run_test(test_file, out_dir):
return subprocess.call([test_file, out_dir])
test_cnt = 0
fail_cnt = 0
tests_dir = "./cases"
outs_dir = tempfile.mkdtemp(prefix="knottest-%s-" % int(time.time()))
print("Starting Knot test suite %s" % outs_dir)
for test in sorted(os.listdir(tests_dir)):
test_dir = tests_dir + "/" + test
if not os.path.isdir(test_dir):
continue
test_file = test_dir + "/test.py"
if not os.path.isfile(test_file):
print("Missing test file %s" % test_file)
continue
try:
out_dir = outs_dir + "/" + test
os.mkdir(out_dir)
print("Test %s: " % test, end="")
test_cnt = test_cnt + 1
if run_test(test_file, out_dir):
print("failed")
fail_cnt = fail_cnt + 1
else:
print("ok")
except (OSError, Exception) as err:
print(format(err))
exit(1)
except:
print("Unexpected error:", sys.exc_info()[0])
if fail_cnt:
print("Failed tests: %i/%i" % (fail_cnt, test_cnt))
exit(1)
else:
print("All tests passed")
exit(0)
This diff is collapsed.
This diff is collapsed.
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