Commit b0a86f8e authored by Marek Vavruša's avatar Marek Vavruša

tests: integration tests python skeleton

parent bfcd7eb2
......@@ -34,8 +34,12 @@ PKG_CHECK_MODULES([libuv], [libuv], [build_daemon=yes], [build_daemon=no])
PKG_CHECK_MODULES([cmocka], [cmocka], [build_tests=yes], [build_tests=no])
# Check for python (integration tests)
AX_PYTHON_DEVEL([>= '2.5.0'])
if test "x$PYTHON" != x ; then build_integration=yes; else build_integration=no; fi
AC_ARG_ENABLE([integration-tests],
AS_HELP_STRING([--enable-integration-tests], [enable integration tests (require Python devel), default: no]),
[build_integration=yes], [build_integration=no])
if test "x${build_integration}" == "xyes"; then
AX_PYTHON_DEVEL([>= '2.5'])
fi
# Set up conditionals
AM_CONDITIONAL([BUILD_TESTS], [test "$build_tests" == "yes"])
......
......@@ -34,8 +34,10 @@ lib/utils.h
lib/zonecut.c
lib/zonecut.h
tests/Makefile.am
tests/pydnstest/scenario.py
tests/test.h
tests/test_cache.c
tests/test_context.c
tests/test_integration.c
tests/test_integration.py
tests/test_resolve.c
......@@ -14,7 +14,7 @@ SOURCES = [
# sources
"lib/*.c", "lib/*.h", "lib/layer/*.h", "lib/layer/*.c",
"tests/*.c", "tests/*.h",
"tests/*.c", "tests/*.h", "tests/*.py",
"daemon/*.c", "daemon/*.h", "daemon/layer/*.c", "daemon/layer/*.h"
]
......
......@@ -48,6 +48,9 @@ clean-local:
@for soname in `echo | $(EGREP) "^dlname=" $(noinst_LTLIBRARIES) | $(SED) -e "s|^dlname='\(.*\)'|\1|"`; do \
test -L $(abs_builddir)/$$soname && rm -f $(abs_builddir)/$$soname || true; \
done
else
check-local-integration:
endif
......
class Query:
match_fields = []
def __init__(self):
pass
def match(self, fields):
self.match_fields = fields
def parse(self, text):
pass
class Range:
a = 0
b = 0
queries = []
def __init__(self, a, b):
self.a = a
self.b = b
def add_query(self, query):
self.queries.append(query)
class Scenario:
name = ''
ranges = []
steps = []
def __init__(self):
pass
def begin(self, explanation):
print '# %s' % explanation
def range(self, a, b):
range_new = Range(a, b)
self.ranges.append(range_new)
return range_new
def step(self, n, step_type):
pass
#!/usr/bin/env python
import sys
import sys, os, fileinput
import _test_integration
print dir(_test_integration)
print sys.argv
print _test_integration.init()
def parse_entry(line, file_in):
""" Parse entry definition. """
print line.split(' ')
for line in iter(lambda: file_in.readline(), ''):
if line.startswith('ENTRY_END'):
break
def parse_step(line, file_in):
""" Parse range definition. """
print line.split(' ')
def parse_range(line, file_in):
""" Parse range definition. """
print line.split(' ')
for line in iter(lambda: file_in.readline(), ''):
if line.startswith('ENTRY_BEGIN'):
parse_entry(line, file_in)
if line.startswith('RANGE_END'):
break
def parse_scenario(line, file_in):
""" Parse scenario definition. """
print line.split(' ')
for line in iter(lambda: file_in.readline(), ''):
if line.startswith('SCENARIO_END'):
break
if line.startswith('RANGE_BEGIN'):
parse_range(line, file_in)
if line.startswith('STEP'):
parse_step(line, file_in)
def parse_file(file_in):
""" Parse and play scenario from a file. """
try:
for line in iter(lambda: file_in.readline(), ''):
if line.startswith('SCENARIO_BEGIN'):
return parse_scenario(line, file_in)
raise Exception("IGNORE (missing scenario)")
except Exception as e:
raise Exception('line %d: %s' % (file_in.lineno(), str(e)))
def parse_object(path):
""" Recursively scan file/directory for scenarios. """
if os.path.isdir(path):
for e in os.listdir(path):
parse_object(os.path.join(path, e))
elif os.path.isfile(path):
file_in = fileinput.input(path)
try:
parse_file(file_in)
print('%s OK' % os.path.basename(path))
except Exception as e:
print('%s %s' % (os.path.basename(path), str(e)))
file_in.close()
if __name__ == '__main__':
for arg in sys.argv[1:]:
parse_object(arg)
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