[svn] commit: r2090 - in /experiments/python-binding: ./ src/bin/xfrin/tests/ src/bin/xfrout/ src/bin/xfrout/tests/ src/lib/dns-python/ src/lib/dns/
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 8 11:02:09 UTC 2010
Author: jelte
Date: Tue Jun 8 11:02:08 2010
New Revision: 2090
Log:
removed old dns-python example code
removed Boost.Python bindings
updated xfrin/xfrout tests for new python bindings
Removed:
experiments/python-binding/src/lib/dns-python/
experiments/python-binding/src/lib/dns/python_dns.cc
Modified:
experiments/python-binding/configure.ac
experiments/python-binding/src/bin/xfrin/tests/Makefile.am
experiments/python-binding/src/bin/xfrin/tests/xfrin_test.py
experiments/python-binding/src/bin/xfrout/tests/Makefile.am
experiments/python-binding/src/bin/xfrout/tests/xfrout_test.py
experiments/python-binding/src/bin/xfrout/xfrout.py.in
experiments/python-binding/src/lib/dns/Makefile.am
Modified: experiments/python-binding/configure.ac
==============================================================================
--- experiments/python-binding/configure.ac (original)
+++ experiments/python-binding/configure.ac Tue Jun 8 11:02:08 2010
@@ -246,52 +246,6 @@
AC_SUBST(BOOST_SYSTEM_LIB)
# Check availability of the Boost Python library
-
-AC_MSG_CHECKING([for boost::python library])
-AC_ARG_WITH([boost-python],
-AC_HELP_STRING([--with-boost-python],
- [specify whether to use the boost python library]),
- [with_boost_python="$withval"], [with_boost_python="auto"])
-if test "$with_boost_python" != "no"; then
- if test "$with_boost_python" != "auto" -a "X$PYTHON_LIB" = X; then
- AC_MSG_ERROR([Boost.Python requested but python library is not available])
- fi
- LDFLAGS_SAVED="$LDFLAGS"
- LIBS_SAVED="$LIBS"
- CPPFLAGS_SAVED="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
-
- for BOOST_TRY_LIB in boost_python boost_python-mt; do
- LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS} ${PYTHON_LDFLAGS}"
- LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB} ${PYTHON_LIB}"
- AC_TRY_LINK([#include <boost/python/module.hpp>
- using namespace boost::python;
- BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }],
- [ return 0; ],
- [ AC_MSG_RESULT(yes)
- BOOST_PYTHON_LIB="-l${BOOST_TRY_LIB}"
- ],[])
- if test "X${BOOST_PYTHON_LIB}" != X; then
- break
- fi
- done
-
- LDFLAGS="$LDFLAGS_SAVED"
- CPPFLAGS="$CPPFLAGS_SAVED"
- LIBS="$LIBS_SAVED"
-fi
-
-if test "X${BOOST_PYTHON_LIB}" = X; then
- AC_MSG_RESULT(no)
- if test "$with_boost_python" = "yes"; then
- AC_MSG_ERROR([boost python library is requested but not found])
- fi
-else
- AC_DEFINE(HAVE_BOOST_PYTHON, 1, Define to 1 if boost python library is available)
-fi
-
-AM_CONDITIONAL(HAVE_BOOST_PYTHON, test "X${BOOST_PYTHON_LIB}" != X)
-AC_SUBST(BOOST_PYTHON_LIB)
#
# Check availability of gtest, which will be used for unit tests.
@@ -408,7 +362,6 @@
src/lib/dns/tests/Makefile
src/lib/dns/python/Makefile
src/lib/dns/python/tests/Makefile
- src/lib/dns-python/Makefile
src/lib/exceptions/Makefile
src/lib/datasrc/Makefile
src/lib/datasrc/tests/Makefile
Modified: experiments/python-binding/src/bin/xfrin/tests/Makefile.am
==============================================================================
--- experiments/python-binding/src/bin/xfrin/tests/Makefile.am (original)
+++ experiments/python-binding/src/bin/xfrin/tests/Makefile.am Tue Jun 8 11:02:08 2010
@@ -1,7 +1,5 @@
PYTESTS = xfrin_test.py
EXTRA_DIST = $(PYTESTS)
-
-if HAVE_BOOST_PYTHON
# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
@@ -9,8 +7,6 @@
check-local:
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
- env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python \
+ env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
done
-
-endif
Modified: experiments/python-binding/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- experiments/python-binding/src/bin/xfrin/tests/xfrin_test.py (original)
+++ experiments/python-binding/src/bin/xfrin/tests/xfrin_test.py Tue Jun 8 11:02:08 2010
@@ -65,12 +65,12 @@
self.assertRaises(Exception, self.conn._handle_xfrin_response)
def test_response_without_end_soa(self):
- self.conn._send_query(rr_type.AXFR())
+ self.conn._send_query(RRType.AXFR())
self.conn.reply_data = self.conn.create_response_data(axfr_response1)
self.assertRaises(XfrinException, self.conn._handle_xfrin_response)
def test_response(self):
- self.conn._send_query(rr_type.AXFR())
+ self.conn._send_query(RRType.AXFR())
self.conn.reply_data = self.conn.create_response_data(axfr_response1)
self.conn.reply_data += self.conn.create_response_data(axfr_response2)
self.conn._handle_xfrin_response()
Modified: experiments/python-binding/src/bin/xfrout/tests/Makefile.am
==============================================================================
--- experiments/python-binding/src/bin/xfrout/tests/Makefile.am (original)
+++ experiments/python-binding/src/bin/xfrout/tests/Makefile.am Tue Jun 8 11:02:08 2010
@@ -1,7 +1,5 @@
PYTESTS = xfrout_test.py
EXTRA_DIST = $(PYTESTS)
-
-if HAVE_BOOST_PYTHON
# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
@@ -9,8 +7,6 @@
check-local:
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
- env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
+ env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
done
-
-endif
Modified: experiments/python-binding/src/bin/xfrout/tests/xfrout_test.py
==============================================================================
--- experiments/python-binding/src/bin/xfrout/tests/xfrout_test.py (original)
+++ experiments/python-binding/src/bin/xfrout/tests/xfrout_test.py Tue Jun 8 11:02:08 2010
@@ -19,7 +19,7 @@
import unittest
import os
from isc.cc.session import *
-from bind10_dns import *
+from libdns_python import *
from xfrout import *
# our fake socket, where we can read and insert messages
@@ -46,8 +46,8 @@
def read_msg(self):
sent_data = self.readsent()
- get_msg = message(message_mode.PARSE)
- get_msg.from_wire(input_buffer(bytes(sent_data[2:])))
+ get_msg = Message(Message.PARSE)
+ get_msg.from_wire(bytes(sent_data[2:]))
return get_msg
def clear_send(self):
@@ -69,15 +69,15 @@
class TestXfroutSession(unittest.TestCase):
def getmsg(self):
- msg = message(message_mode.PARSE)
- msg.from_wire(input_buffer(self.mdata))
+ msg = Message(Message.PARSE)
+ msg.from_wire(self.mdata)
return msg
def setUp(self):
request = MySocket(socket.AF_INET,socket.SOCK_STREAM)
self.xfrsess = MyXfroutSession(request, None, None)
self.xfrsess.server = Dbserver()
- self.mdata = b'\xd6=\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\x00\x00\xfc\x00\x01'
+ self.mdata = bytes(b'\xd6=\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\x00\x00\xfc\x00\x01')
self.sock = MySocket(socket.AF_INET,socket.SOCK_STREAM)
self.soa_record = (4, 3, 'example.com.', 'com.example.', 3600, 'SOA', None, 'master.example.com. admin.example.com. 1234 3600 1800 2419200 7200')
@@ -96,7 +96,7 @@
def test_reply_xfrout_query_with_error_rcode(self):
msg = self.getmsg()
- self.xfrsess._reply_query_with_error_rcode(msg, self.sock, rcode(3))
+ self.xfrsess._reply_query_with_error_rcode(msg, self.sock, Rcode(3))
get_msg = self.sock.read_msg()
self.assertEqual(get_msg.get_rcode().to_text(), "NXDOMAIN")
@@ -110,7 +110,7 @@
self.assertEqual(msg.get_qid(), qid)
self.assertEqual(msg.get_opcode(), opcode)
self.assertEqual(msg.get_rcode(), rcode)
- self.assertTrue(msg.get_header_flag(message_flag.AA()))
+ self.assertTrue(msg.get_header_flag(MessageFlag.AA()))
def test_reply_query_with_format_error(self):
@@ -122,11 +122,10 @@
def test_create_rrset_from_db_record(self):
rrset = self.xfrsess._create_rrset_from_db_record(self.soa_record)
self.assertEqual(rrset.get_name().to_text(), "example.com.")
- self.assertEqual(rrset.get_class(), rr_class.IN())
+ self.assertEqual(rrset.get_class(), RRClass("IN"))
self.assertEqual(rrset.get_type().to_text(), "SOA")
- rdata_iter = rrset.get_rdata_iterator()
- rdata_iter.first()
- self.assertEqual(rdata_iter.get_current().to_text(), self.soa_record[7])
+ rdata = rrset.get_rdata()
+ self.assertEqual(rdata[0].to_text(), self.soa_record[7])
def test_send_message_with_last_soa(self):
rrset_soa = self.xfrsess._create_rrset_from_db_record(self.soa_record)
@@ -136,18 +135,17 @@
self.xfrsess._send_message_with_last_soa(msg, self.sock, rrset_soa)
get_msg = self.sock.read_msg()
- self.assertEqual(get_msg.get_rr_count(section.QUESTION()), 1)
- self.assertEqual(get_msg.get_rr_count(section.ANSWER()), 1)
- self.assertEqual(get_msg.get_rr_count(section.AUTHORITY()), 0)
-
- answer_rrset_iter = section_iter(get_msg, section.ANSWER())
- answer = answer_rrset_iter.get_rrset()
+ self.assertEqual(get_msg.get_rr_count(Section.QUESTION()), 1)
+ self.assertEqual(get_msg.get_rr_count(Section.ANSWER()), 1)
+ self.assertEqual(get_msg.get_rr_count(Section.AUTHORITY()), 0)
+
+ #answer_rrset_iter = section_iter(get_msg, section.ANSWER())
+ answer = get_msg.get_section(Section.ANSWER())[0]#answer_rrset_iter.get_rrset()
self.assertEqual(answer.get_name().to_text(), "example.com.")
- self.assertEqual(answer.get_class(), rr_class.IN())
+ self.assertEqual(answer.get_class(), RRClass("IN"))
self.assertEqual(answer.get_type().to_text(), "SOA")
- rdata_iter = answer.get_rdata_iterator()
- rdata_iter.first()
- self.assertEqual(rdata_iter.get_current().to_text(), self.soa_record[7])
+ rdata = answer.get_rdata()
+ self.assertEqual(rdata[0].to_text(), self.soa_record[7])
def test_get_message_len(self):
msg = self.getmsg()
@@ -195,7 +193,7 @@
def test_dns_xfrout_start_formerror(self):
# formerror
- self.xfrsess.dns_xfrout_start(self.sock, b"\xd6=\x00\x00\x00\x01\x00")
+ self.assertRaises(MessageTooShort, self.xfrsess.dns_xfrout_start, self.sock, b"\xd6=\x00\x00\x00\x01\x00")
sent_data = self.sock.readsent()
self.assertEqual(len(sent_data), 0)
@@ -205,7 +203,7 @@
def test_dns_xfrout_start_notauth(self):
self.xfrsess._get_query_zone_name = self.default
def notauth(formpara):
- return rcode.NOTAUTH()
+ return Rcode.NOTAUTH()
self.xfrsess._check_xfrout_available = notauth
self.xfrsess.dns_xfrout_start(self.sock, self.mdata)
get_msg = self.sock.read_msg()
@@ -214,7 +212,7 @@
def test_dns_xfrout_start_noerror(self):
self.xfrsess._get_query_zone_name = self.default
def noerror(form):
- return rcode.NOERROR()
+ return Rcode.NOERROR()
self.xfrsess._check_xfrout_available = noerror
def myreply(msg, sock, zonename):
@@ -236,7 +234,7 @@
sqlite3_ds.get_zone_datas = get_zone_datas
self.xfrsess._reply_xfrout_query(self.getmsg(), self.sock, "example.com.")
reply_msg = self.sock.read_msg()
- self.assertEqual(reply_msg.get_rr_count(section.ANSWER()), 2)
+ self.assertEqual(reply_msg.get_rr_count(Section.ANSWER()), 2)
# set event
self.xfrsess.server._shutdown_event.set()
Modified: experiments/python-binding/src/bin/xfrout/xfrout.py.in
==============================================================================
--- experiments/python-binding/src/bin/xfrout/xfrout.py.in (original)
+++ experiments/python-binding/src/bin/xfrout/xfrout.py.in Tue Jun 8 11:02:08 2010
@@ -80,7 +80,7 @@
#TODO, need to add parseHeader() in case the message header is invalid
try:
msg = Message(Message.PARSE)
- msg.from_wire(mdata)
+ Message.from_wire(msg, mdata)
except TmpException as err:
if verbose_mode:
self.log_msg(str(err))
Modified: experiments/python-binding/src/lib/dns/Makefile.am
==============================================================================
--- experiments/python-binding/src/lib/dns/Makefile.am (original)
+++ experiments/python-binding/src/lib/dns/Makefile.am Tue Jun 8 11:02:08 2010
@@ -79,26 +79,26 @@
libdns_la_SOURCES += sha1.h sha1.cc
libdns_la_SOURCES += tsig.h tsig.cc
-if HAVE_BOOST_PYTHON
-# This is a loadable module for python scripts, so we use the prefix "pyexec"
-# to make sure the object files will be installed in the appropriate place
-# for this purpose.
-pyexec_LTLIBRARIES = bind10_dns.la
-bind10_dns_la_SOURCES = python_dns.cc
-bind10_dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
-if GCC_WERROR_OK
-# XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
-# we need to suppress the warnings.
-bind10_dns_la_CPPFLAGS += -fno-strict-aliasing
-endif
-bind10_dns_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
-# Python prefers .so, while some OSes (specifically MacOS) use a different
-# suffix for dynamic objects. -module is necessary to work this around.
-bind10_dns_la_LDFLAGS += -module
-bind10_dns_la_LIBADD = $(top_builddir)/src/lib/dns/libdns.la
-bind10_dns_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-bind10_dns_la_LIBADD += $(BOOST_PYTHON_LIB) $(PYTHON_LIB)
-endif
+#if HAVE_BOOST_PYTHON
+## This is a loadable module for python scripts, so we use the prefix "pyexec"
+## to make sure the object files will be installed in the appropriate place
+## for this purpose.
+#pyexec_LTLIBRARIES = bind10_dns.la
+#bind10_dns_la_SOURCES = python_dns.cc
+#bind10_dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
+#if GCC_WERROR_OK
+## XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
+## we need to suppress the warnings.
+#bind10_dns_la_CPPFLAGS += -fno-strict-aliasing
+#endif
+#bind10_dns_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
+## Python prefers .so, while some OSes (specifically MacOS) use a different
+## suffix for dynamic objects. -module is necessary to work this around.
+#bind10_dns_la_LDFLAGS += -module
+#bind10_dns_la_LIBADD = $(top_builddir)/src/lib/dns/libdns.la
+#bind10_dns_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+#bind10_dns_la_LIBADD += $(BOOST_PYTHON_LIB) $(PYTHON_LIB)
+#endif
nodist_libdns_la_SOURCES = rdataclass.cc rrclass.h rrtype.h rrparamregistry.cc
More information about the bind10-changes
mailing list