Merge remote-tracking branch 'origin/master' into loxi-ir

Conflicts:
	Makefile
diff --git a/Makefile b/Makefile
index d455ad4..ab834be 100644
--- a/Makefile
+++ b/Makefile
@@ -80,13 +80,14 @@
 check:
 	PYTHONPATH=. ./utest/test_parser.py
 	PYTHONPATH=. ./utest/test_frontend.py
+	PYTHONPATH=. ./utest/test_test_data.py
 
 check-py: python
-	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/generic_util.py
-	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of10.py
-	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of11.py
-	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of12.py
-	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi python py_gen/tests/of13.py
+	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/generic_util.py
+	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of10.py
+	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of11.py
+	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of12.py
+	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of13.py
 
 pylint:
 	pylint -E ${LOXI_PY_FILES}
diff --git a/loxigen.py b/loxigen.py
index c6c344d..bfa4909 100755
--- a/loxigen.py
+++ b/loxigen.py
@@ -418,6 +418,9 @@
     ofinputs_by_version = collections.defaultdict(lambda: [])
     filenames = sorted(glob.glob("%s/openflow_input/*" % root_dir))
 
+    # Ignore emacs backup files
+    filenames = [x for x in filenames if not x.endswith('~')]
+
     for filename in filenames:
         log("Processing struct file: " + filename)
         ofinput = process_input_file(filename)
diff --git a/py_gen/tests/of10.py b/py_gen/tests/of10.py
index 79049a5..e593e0f 100644
--- a/py_gen/tests/of10.py
+++ b/py_gen/tests/of10.py
@@ -26,6 +26,8 @@
 # EPL for the specific language governing permissions and limitations
 # under the EPL.
 import unittest
+import test_data
+from testutil import add_datafiles_tests
 
 try:
     import loxi.of10 as ofp
@@ -56,23 +58,6 @@
         self.assertTrue(hasattr(loxi.of10, "message"))
 
 class TestActions(unittest.TestCase):
-    def test_output_pack(self):
-        expected = "\x00\x00\x00\x08\xff\xf8\xff\xff"
-        action = ofp.action.output(port=ofp.OFPP_IN_PORT, max_len=0xffff)
-        self.assertEquals(expected, action.pack())
-
-    def test_output_unpack(self):
-        # Normal case
-        buf = "\x00\x00\x00\x08\xff\xf8\xff\xff"
-        action = ofp.action.output.unpack(buf)
-        self.assertEqual(action.port, ofp.OFPP_IN_PORT)
-        self.assertEqual(action.max_len, 0xffff)
-
-        # Invalid length
-        #buf = "\x00\x00\x00\x09\xff\xf8\xff\xff\x00"
-        #with self.assertRaises(ofp.ProtocolError):
-        #    ofp.action.output.unpack(buf)
-
     def test_output_equality(self):
         action = ofp.action.output(port=1, max_len=0x1234)
         action2 = ofp.action.output(port=1, max_len=0x1234)
@@ -86,32 +71,6 @@
         self.assertNotEquals(action, action2)
         action2.max_len = 0x1234
 
-    def test_output_show(self):
-        action = ofp.action.output(port=1, max_len=0x1234)
-        expected = "output { port = 1, max_len = 0x1234 }"
-        self.assertEquals(expected, action.show())
-
-    def test_bsn_set_tunnel_dst_pack(self):
-        expected = ''.join([
-            "\xff\xff", "\x00\x10", # type/length
-            "\x00\x5c\x16\xc7", # experimenter
-            "\x00\x00\x00\x02", # subtype
-            "\x12\x34\x56\x78" # dst
-        ])
-        action = ofp.action.bsn_set_tunnel_dst(dst=0x12345678)
-        self.assertEquals(expected, action.pack())
-
-    def test_bsn_set_tunnel_dst_unpack(self):
-        buf = ''.join([
-            "\xff\xff", "\x00\x10", # type/length
-            "\x00\x5c\x16\xc7", # experimenter
-            "\x00\x00\x00\x02", # subtype
-            "\x12\x34\x56\x78" # dst
-        ])
-        action = ofp.action.bsn_set_tunnel_dst.unpack(buf)
-        self.assertEqual(action.subtype, 2)
-        self.assertEqual(action.dst, 0x12345678)
-
 # Assumes action serialization/deserialization works
 class TestActionList(unittest.TestCase):
     def test_normal(self):
@@ -165,153 +124,6 @@
         self.assertEquals(0xfc000, ofp.OFPFW_NW_DST_MASK)
 
 class TestCommon(unittest.TestCase):
-    def test_port_desc_pack(self):
-        obj = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
-                            hw_addr=[1,2,3,4,5,6],
-                            name="foo",
-                            config=ofp.OFPPC_NO_FLOOD,
-                            state=ofp.OFPPS_STP_FORWARD,
-                            curr=ofp.OFPPF_10MB_HD,
-                            advertised=ofp.OFPPF_1GB_FD,
-                            supported=ofp.OFPPF_AUTONEG,
-                            peer=ofp.OFPPF_PAUSE_ASYM)
-        expected = ''.join([
-            '\xff\xfd', # port_no
-            '\x01\x02\x03\x04\x05\x06', # hw_addr
-            'foo'.ljust(16, '\x00'), # name
-            '\x00\x00\x00\x10', # config
-            '\x00\x00\x02\x00', # state
-            '\x00\x00\x00\x01', # curr
-            '\x00\x00\x00\x20', # advertised
-            '\x00\x00\x02\x00', # supported
-            '\x00\x00\x08\x00', # peer
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_port_desc_unpack(self):
-        buf = ''.join([
-            '\xff\xfd', # port_no
-            '\x01\x02\x03\x04\x05\x06', # hw_addr
-            'foo'.ljust(16, '\x00'), # name
-            '\x00\x00\x00\x10', # config
-            '\x00\x00\x02\x00', # state
-            '\x00\x00\x00\x01', # curr
-            '\x00\x00\x00\x20', # advertised
-            '\x00\x00\x02\x00', # supported
-            '\x00\x00\x08\x00', # peer
-        ])
-        obj = ofp.port_desc.unpack(buf)
-        self.assertEquals(ofp.OFPP_CONTROLLER, obj.port_no)
-        self.assertEquals('foo', obj.name)
-        self.assertEquals(ofp.OFPPF_PAUSE_ASYM, obj.peer)
-
-    def test_table_stats_entry_pack(self):
-        obj = ofp.table_stats_entry(table_id=3,
-                                    name="foo",
-                                    wildcards=ofp.OFPFW_ALL,
-                                    max_entries=5,
-                                    active_count=2,
-                                    lookup_count=1099511627775,
-                                    matched_count=9300233470495232273L)
-        expected = ''.join([
-            '\x03', # table_id
-            '\x00\x00\x00', # pad
-            'foo'.ljust(32, '\x00'), # name
-            '\x00\x3f\xFF\xFF', # wildcards
-            '\x00\x00\x00\x05', # max_entries
-            '\x00\x00\x00\x02', # active_count
-            '\x00\x00\x00\xff\xff\xff\xff\xff', # lookup_count
-            '\x81\x11\x11\x11\x11\x11\x11\x11', # matched_count
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_table_stats_entry_unpack(self):
-        buf = ''.join([
-            '\x03', # table_id
-            '\x00\x00\x00', # pad
-            'foo'.ljust(32, '\x00'), # name
-            '\x00\x3f\xFF\xFF', # wildcards
-            '\x00\x00\x00\x05', # max_entries
-            '\x00\x00\x00\x02', # active_count
-            '\x00\x00\x00\xff\xff\xff\xff\xff', # lookup_count
-            '\x81\x11\x11\x11\x11\x11\x11\x11', # matched_count
-        ])
-        obj = ofp.table_stats_entry.unpack(buf)
-        self.assertEquals(3, obj.table_id)
-        self.assertEquals('foo', obj.name)
-        self.assertEquals(9300233470495232273L, obj.matched_count)
-
-    def test_flow_stats_entry_pack(self):
-        obj = ofp.flow_stats_entry(table_id=3,
-                                   match=ofp.match(),
-                                   duration_sec=1,
-                                   duration_nsec=2,
-                                   priority=100,
-                                   idle_timeout=5,
-                                   hard_timeout=10,
-                                   cookie=0x0123456789abcdef,
-                                   packet_count=10,
-                                   byte_count=1000,
-                                   actions=[ofp.action.output(port=1),
-                                            ofp.action.output(port=2)])
-        expected = ''.join([
-            '\x00\x68', # length
-            '\x03', # table_id
-            '\x00', # pad
-            '\x00\x3f\xff\xff', # match.wildcards
-            '\x00' * 36, # remaining match fields
-            '\x00\x00\x00\x01', # duration_sec
-            '\x00\x00\x00\x02', # duration_nsec
-            '\x00\x64', # priority
-            '\x00\x05', # idle_timeout
-            '\x00\x0a', # hard_timeout
-            '\x00' * 6, # pad2
-            '\x01\x23\x45\x67\x89\xab\xcd\xef', # cookie
-            '\x00\x00\x00\x00\x00\x00\x00\x0a', # packet_count
-            '\x00\x00\x00\x00\x00\x00\x03\xe8', # byte_count
-            '\x00\x00', # actions[0].type
-            '\x00\x08', # actions[0].len
-            '\x00\x01', # actions[0].port
-            '\x00\x00', # actions[0].max_len
-            '\x00\x00', # actions[1].type
-            '\x00\x08', # actions[1].len
-            '\x00\x02', # actions[1].port
-            '\x00\x00', # actions[1].max_len
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_flow_stats_entry_unpack(self):
-        buf = ''.join([
-            '\x00\x68', # length
-            '\x03', # table_id
-            '\x00', # pad
-            '\x00\x3f\xff\xff', # match.wildcards
-            '\x00' * 36, # remaining match fields
-            '\x00\x00\x00\x01', # duration_sec
-            '\x00\x00\x00\x02', # duration_nsec
-            '\x00\x64', # priority
-            '\x00\x05', # idle_timeout
-            '\x00\x0a', # hard_timeout
-            '\x00' * 6, # pad2
-            '\x01\x23\x45\x67\x89\xab\xcd\xef', # cookie
-            '\x00\x00\x00\x00\x00\x00\x00\x0a', # packet_count
-            '\x00\x00\x00\x00\x00\x00\x03\xe8', # byte_count
-            '\x00\x00', # actions[0].type
-            '\x00\x08', # actions[0].len
-            '\x00\x01', # actions[0].port
-            '\x00\x00', # actions[0].max_len
-            '\x00\x00', # actions[1].type
-            '\x00\x08', # actions[1].len
-            '\x00\x02', # actions[1].port
-            '\x00\x00', # actions[1].max_len
-        ])
-        obj = ofp.flow_stats_entry.unpack(buf)
-        self.assertEquals(3, obj.table_id)
-        self.assertEquals(ofp.OFPFW_ALL, obj.match.wildcards)
-        self.assertEquals(2, len(obj.actions))
-        self.assertEquals(1, obj.actions[0].port)
-        self.assertEquals(2, obj.actions[1].port)
-
     def test_match(self):
         match = ofp.match()
         self.assertEquals(match.wildcards, ofp.OFPFW_ALL)
@@ -334,36 +146,11 @@
         msg = ofp.message.hello(xid=0)
         self.assertEquals(msg.xid, 0)
 
-    def test_hello_unpack(self):
-        # Normal case
-        buf = "\x01\x00\x00\x08\x12\x34\x56\x78"
-        msg = ofp.message.hello(xid=0x12345678)
-        self.assertEquals(buf, msg.pack())
-
-        # Invalid length
-        #buf = "\x01\x00\x00\x09\x12\x34\x56\x78\x9a"
-        #with self.assertRaisesRegexp(ofp.ProtocolError, "should be 8"):
-        #    ofp.message.hello.unpack(buf)
-
     def test_echo_request_construction(self):
         msg = ofp.message.echo_request(data="abc")
         self.assertEquals(msg.data, "abc")
 
-    def test_echo_request_pack(self):
-        msg = ofp.message.echo_request(xid=0x12345678, data="abc")
-        buf = msg.pack()
-        self.assertEquals(buf, "\x01\x02\x00\x0b\x12\x34\x56\x78\x61\x62\x63")
-
-        msg2 = ofp.message.echo_request.unpack(buf)
-        self.assertEquals(msg, msg2)
-
-    def test_echo_request_unpack(self):
-        # Normal case
-        buf = "\x01\x02\x00\x0b\x12\x34\x56\x78\x61\x62\x63"
-        msg = ofp.message.echo_request(xid=0x12345678, data="abc")
-        self.assertEquals(buf, msg.pack())
-
-        # Invalid length
+    def test_echo_request_invalid_length(self):
         buf = "\x01\x02\x00\x07\x12\x34\x56"
         with self.assertRaisesRegexp(ofp.ProtocolError, "buffer too short"):
             ofp.message.echo_request.unpack(buf)
@@ -371,7 +158,6 @@
     def test_echo_request_equality(self):
         msg = ofp.message.echo_request(xid=0x12345678, data="abc")
         msg2 = ofp.message.echo_request(xid=0x12345678, data="abc")
-        #msg2 = ofp.message.echo_request.unpack(msg.pack())
         self.assertEquals(msg, msg2)
 
         msg2.xid = 1
@@ -382,469 +168,11 @@
         self.assertNotEquals(msg, msg2)
         msg2.data = msg.data
 
-    def test_echo_request_show(self):
-        expected = "echo_request { xid = 0x12345678, data = 'ab\\x01' }"
-        msg = ofp.message.echo_request(xid=0x12345678, data="ab\x01")
-        self.assertEquals(msg.show(), expected)
-
-    def test_flow_add(self):
-        match = ofp.match()
-        msg = ofp.message.flow_add(xid=1,
-                                   match=match,
-                                   cookie=1,
-                                   idle_timeout=5,
-                                   flags=ofp.OFPFF_CHECK_OVERLAP,
-                                   actions=[
-                                       ofp.action.output(port=1),
-                                       ofp.action.output(port=2),
-                                       ofp.action.output(port=ofp.OFPP_CONTROLLER,
-                                                         max_len=1024)])
-        buf = msg.pack()
-        msg2 = ofp.message.flow_add.unpack(buf)
-        self.assertEquals(msg, msg2)
-
-    def test_port_mod_pack(self):
-        msg = ofp.message.port_mod(xid=2,
-                                   port_no=ofp.OFPP_CONTROLLER,
-                                   hw_addr=[1,2,3,4,5,6],
-                                   config=0x90ABCDEF,
-                                   mask=0xFF11FF11,
-                                   advertise=0xCAFE6789)
-        expected = "\x01\x0f\x00\x20\x00\x00\x00\x02\xff\xfd\x01\x02\x03\x04\x05\x06\x90\xab\xcd\xef\xff\x11\xff\x11\xca\xfe\x67\x89\x00\x00\x00\x00"
-        self.assertEquals(expected, msg.pack())
-
-    def test_desc_stats_reply_pack(self):
-        msg = ofp.message.desc_stats_reply(xid=3,
-                                           flags=ofp.OFPSF_REPLY_MORE,
-                                           mfr_desc="The Indigo-2 Community",
-                                           hw_desc="Unknown server",
-                                           sw_desc="Indigo-2 LRI pre-release",
-                                           serial_num="11235813213455",
-                                           dp_desc="Indigo-2 LRI forwarding module")
-        expected = ''.join([
-            '\x01', '\x11', # version/type
-            '\x04\x2c', # length
-            '\x00\x00\x00\x03', # xid
-            '\x00\x00', # stats_type
-            '\x00\x01', # flags
-            'The Indigo-2 Community'.ljust(256, '\x00'), # mfr_desc
-            'Unknown server'.ljust(256, '\x00'), # hw_desc
-            'Indigo-2 LRI pre-release'.ljust(256, '\x00'), # sw_desc
-            '11235813213455'.ljust(32, '\x00'), # serial_num
-            'Indigo-2 LRI forwarding module'.ljust(256, '\x00'), # dp_desc
-        ])
-        self.assertEquals(expected, msg.pack())
-
-    def test_desc_stats_reply_unpack(self):
-        buf = ''.join([
-            '\x01', '\x11', # version/type
-            '\x04\x2c', # length
-            '\x00\x00\x00\x03', # xid
-            '\x00\x00', # stats_type
-            '\x00\x01', # flags
-            'The Indigo-2 Community'.ljust(256, '\x00'), # mfr_desc
-            'Unknown server'.ljust(256, '\x00'), # hw_desc
-            'Indigo-2 LRI pre-release'.ljust(256, '\x00'), # sw_desc
-            '11235813213455'.ljust(32, '\x00'), # serial_num
-            'Indigo-2 LRI forwarding module'.ljust(256, '\x00'), # dp_desc
-        ])
-        msg = ofp.message.desc_stats_reply.unpack(buf)
-        self.assertEquals('Indigo-2 LRI forwarding module', msg.dp_desc)
-        self.assertEquals('11235813213455', msg.serial_num)
-        self.assertEquals(ofp.OFPST_DESC, msg.stats_type)
-        self.assertEquals(ofp.OFPSF_REPLY_MORE, msg.flags)
-
-    def test_port_status_pack(self):
-        desc = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
-                             hw_addr=[1,2,3,4,5,6],
-                             name="foo",
-                             config=ofp.OFPPC_NO_FLOOD,
-                             state=ofp.OFPPS_STP_FORWARD,
-                             curr=ofp.OFPPF_10MB_HD,
-                             advertised=ofp.OFPPF_1GB_FD,
-                             supported=ofp.OFPPF_AUTONEG,
-                             peer=ofp.OFPPF_PAUSE_ASYM)
-
-        msg = ofp.message.port_status(xid=4,
-                                      reason=ofp.OFPPR_DELETE,
-                                      desc=desc)
-        expected = ''.join([
-            '\x01', '\x0c', # version/type
-            '\x00\x40', # length
-            '\x00\x00\x00\x04', # xid
-            '\x01', # reason
-            '\x00\x00\x00\x00\x00\x00\x00' # pad
-            '\xff\xfd', # desc.port_no
-            '\x01\x02\x03\x04\x05\x06', # desc.hw_addr
-            'foo'.ljust(16, '\x00'), # desc.name
-            '\x00\x00\x00\x10', # desc.config
-            '\x00\x00\x02\x00', # desc.state
-            '\x00\x00\x00\x01', # desc.curr
-            '\x00\x00\x00\x20', # desc.advertised
-            '\x00\x00\x02\x00', # desc.supported
-            '\x00\x00\x08\x00', # desc.peer
-        ])
-        self.assertEquals(expected, msg.pack())
-
-    def test_port_status_unpack(self):
-        buf = ''.join([
-            '\x01', '\x0c', # version/type
-            '\x00\x40', # length
-            '\x00\x00\x00\x04', # xid
-            '\x01', # reason
-            '\x00\x00\x00\x00\x00\x00\x00' # pad
-            '\xff\xfd', # desc.port_no
-            '\x01\x02\x03\x04\x05\x06', # desc.hw_addr
-            'foo'.ljust(16, '\x00'), # desc.name
-            '\x00\x00\x00\x10', # desc.config
-            '\x00\x00\x02\x00', # desc.state
-            '\x00\x00\x00\x01', # desc.curr
-            '\x00\x00\x00\x20', # desc.advertised
-            '\x00\x00\x02\x00', # desc.supported
-            '\x00\x00\x08\x00', # desc.peer
-        ])
-        msg = ofp.message.port_status.unpack(buf)
-        self.assertEquals('foo', msg.desc.name)
-        self.assertEquals(ofp.OFPPF_PAUSE_ASYM, msg.desc.peer)
-
-    def test_port_stats_reply_pack(self):
-        msg = ofp.message.port_stats_reply(xid=5, flags=0, entries=[
-            ofp.port_stats_entry(port_no=1, rx_packets=56, collisions=5),
-            ofp.port_stats_entry(port_no=ofp.OFPP_LOCAL, rx_packets=1, collisions=1)])
-        expected = ''.join([
-            '\x01', '\x11', # version/type
-            '\x00\xdc', # length
-            '\x00\x00\x00\x05', # xid
-            '\x00\x04', # stats_type
-            '\x00\x00', # flags
-            '\x00\x01', # entries[0].port_no
-            '\x00\x00\x00\x00\x00\x00' # entries[0].pad
-            '\x00\x00\x00\x00\x00\x00\x00\x38', # entries[0].rx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_frame_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_over_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_crc_err
-            '\x00\x00\x00\x00\x00\x00\x00\x05', # entries[0].collisions
-            '\xff\xfe', # entries[1].port_no
-            '\x00\x00\x00\x00\x00\x00' # entries[1].pad
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[1].rx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_frame_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_over_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_crc_err
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[1].collisions
-        ])
-        self.assertEquals(expected, msg.pack())
-
-    def test_port_stats_reply_unpack(self):
-        buf = ''.join([
-            '\x01', '\x11', # version/type
-            '\x00\xdc', # length
-            '\x00\x00\x00\x05', # xid
-            '\x00\x04', # stats_type
-            '\x00\x00', # flags
-            '\x00\x01', # entries[0].port_no
-            '\x00\x00\x00\x00\x00\x00' # entries[0].pad
-            '\x00\x00\x00\x00\x00\x00\x00\x38', # entries[0].rx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].tx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_frame_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_over_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[0].rx_crc_err
-            '\x00\x00\x00\x00\x00\x00\x00\x05', # entries[0].collisions
-            '\xff\xfe', # entries[1].port_no
-            '\x00\x00\x00\x00\x00\x00' # entries[1].pad
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[1].rx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_packets
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_bytes
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_dropped
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].tx_errors
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_frame_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_over_err
-            '\x00\x00\x00\x00\x00\x00\x00\x00', # entries[1].rx_crc_err
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[1].collisions
-        ])
-        msg = ofp.message.port_stats_reply.unpack(buf)
-        self.assertEquals(ofp.OFPST_PORT, msg.stats_type)
-        self.assertEquals(2, len(msg.entries))
-
-    sample_flow_stats_reply_buf = ''.join([
-        '\x01', '\x11', # version/type
-        '\x00\xe4', # length
-        '\x00\x00\x00\x06', # xid
-        '\x00\x01', # stats_type
-        '\x00\x00', # flags
-        '\x00\x68', # entries[0].length
-        '\x03', # entries[0].table_id
-        '\x00', # entries[0].pad
-        '\x00\x3f\xff\xff', # entries[0].match.wildcards
-        '\x00' * 36, # remaining match fields
-        '\x00\x00\x00\x01', # entries[0].duration_sec
-        '\x00\x00\x00\x02', # entries[0].duration_nsec
-        '\x00\x64', # entries[0].priority
-        '\x00\x05', # entries[0].idle_timeout
-        '\x00\x0a', # entries[0].hard_timeout
-        '\x00' * 6, # entries[0].pad2
-        '\x01\x23\x45\x67\x89\xab\xcd\xef', # entries[0].cookie
-        '\x00\x00\x00\x00\x00\x00\x00\x0a', # entries[0].packet_count
-        '\x00\x00\x00\x00\x00\x00\x03\xe8', # entries[0].byte_count
-        '\x00\x00', # entries[0].actions[0].type
-        '\x00\x08', # entries[0].actions[0].len
-        '\x00\x01', # entries[0].actions[0].port
-        '\x00\x00', # entries[0].actions[0].max_len
-        '\x00\x00', # entries[0].actions[1].type
-        '\x00\x08', # entries[0].actions[1].len
-        '\x00\x02', # entries[0].actions[1].port
-        '\x00\x00', # entries[0].actions[1].max_len
-        '\x00\x70', # entries[1].length
-        '\x04', # entries[1].table_id
-        '\x00', # entries[1].pad
-        '\x00\x3f\xff\xff', # entries[1].match.wildcards
-        '\x00' * 36, # remaining match fields
-        '\x00\x00\x00\x01', # entries[1].duration_sec
-        '\x00\x00\x00\x02', # entries[1].duration_nsec
-        '\x00\x64', # entries[1].priority
-        '\x00\x05', # entries[1].idle_timeout
-        '\x00\x0a', # entries[1].hard_timeout
-        '\x00' * 6, # entries[1].pad2
-        '\x01\x23\x45\x67\x89\xab\xcd\xef', # entries[1].cookie
-        '\x00\x00\x00\x00\x00\x00\x00\x0a', # entries[1].packet_count
-        '\x00\x00\x00\x00\x00\x00\x03\xe8', # entries[1].byte_count
-        '\x00\x00', # entries[1].actions[0].type
-        '\x00\x08', # entries[1].actions[0].len
-        '\x00\x01', # entries[1].actions[0].port
-        '\x00\x00', # entries[1].actions[0].max_len
-        '\x00\x00', # entries[1].actions[1].type
-        '\x00\x08', # entries[1].actions[1].len
-        '\x00\x02', # entries[1].actions[1].port
-        '\x00\x00', # entries[1].actions[1].max_len
-        '\x00\x00', # entries[1].actions[2].type
-        '\x00\x08', # entries[1].actions[2].len
-        '\x00\x03', # entries[1].actions[2].port
-        '\x00\x00', # entries[1].actions[2].max_len
-    ])
-
-    def test_flow_stats_reply_pack(self):
-        msg = ofp.message.flow_stats_reply(xid=6, flags=0, entries=[
-            ofp.flow_stats_entry(table_id=3,
-                                 match=ofp.match(),
-                                 duration_sec=1,
-                                 duration_nsec=2,
-                                 priority=100,
-                                 idle_timeout=5,
-                                 hard_timeout=10,
-                                 cookie=0x0123456789abcdef,
-                                 packet_count=10,
-                                 byte_count=1000,
-                                 actions=[ofp.action.output(port=1),
-                                          ofp.action.output(port=2)]),
-            ofp.flow_stats_entry(table_id=4,
-                                 match=ofp.match(),
-                                 duration_sec=1,
-                                 duration_nsec=2,
-                                 priority=100,
-                                 idle_timeout=5,
-                                 hard_timeout=10,
-                                 cookie=0x0123456789abcdef,
-                                 packet_count=10,
-                                 byte_count=1000,
-                                 actions=[ofp.action.output(port=1),
-                                          ofp.action.output(port=2),
-                                          ofp.action.output(port=3)])])
-        self.assertEquals(self.sample_flow_stats_reply_buf, msg.pack())
-
-    def test_flow_stats_reply_unpack(self):
-        msg = ofp.message.flow_stats_reply.unpack(self.sample_flow_stats_reply_buf)
-        self.assertEquals(ofp.OFPST_FLOW, msg.stats_type)
-        self.assertEquals(2, len(msg.entries))
-        self.assertEquals(2, len(msg.entries[0].actions))
-        self.assertEquals(3, len(msg.entries[1].actions))
-
-    def test_flow_add_show(self):
-        expected = """\
-flow_add {
-  xid = None,
-  match = match_v1 {
-    wildcards = OFPFW_DL_SRC|OFPFW_DL_DST,
-    in_port = 3,
-    eth_src = 01:23:45:67:89:ab,
-    eth_dst = cd:ef:01:23:45:67,
-    vlan_vid = 0x0,
-    vlan_pcp = 0x0,
-    eth_type = 0x0,
-    ip_dscp = 0x0,
-    ip_proto = 0x0,
-    ipv4_src = 192.168.3.127,
-    ipv4_dst = 255.255.255.255,
-    tcp_src = 0x0,
-    tcp_dst = 0x0
-  },
-  cookie = 0x0,
-  idle_timeout = 0x0,
-  hard_timeout = 0x0,
-  priority = 0x0,
-  buffer_id = 0x0,
-  out_port = 0,
-  flags = 0x0,
-  actions = [
-    output { port = OFPP_FLOOD, max_len = 0x0 },
-    nicira_dec_ttl {  },
-    bsn_set_tunnel_dst { dst = 0x0 }
-  ]
-}"""
-        msg = ofp.message.flow_add(
-            match=ofp.match(
-                wildcards=ofp.OFPFW_DL_SRC|ofp.OFPFW_DL_DST,
-                in_port=3,
-                ipv4_src=0xc0a8037f,
-                ipv4_dst=0xffffffff,
-                eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
-                eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
-            actions=[
-                ofp.action.output(port=ofp.OFPP_FLOOD),
-                ofp.action.nicira_dec_ttl(),
-                ofp.action.bsn_set_tunnel_dst()])
-        self.assertEquals(msg.show(), expected)
-
-    sample_packet_out_buf = ''.join([
-        '\x01', '\x0d', # version/type
-        '\x00\x23', # length
-        '\x12\x34\x56\x78', # xid
-        '\xab\xcd\xef\x01', # buffer_id
-        '\xff\xfe', # in_port
-        '\x00\x10', # actions_len
-        '\x00\x00', # actions[0].type
-        '\x00\x08', # actions[0].len
-        '\x00\x01', # actions[0].port
-        '\x00\x00', # actions[0].max_len
-        '\x00\x00', # actions[1].type
-        '\x00\x08', # actions[1].len
-        '\x00\x02', # actions[1].port
-        '\x00\x00', # actions[1].max_len
-        'abc' # data
-    ])
-
-    def test_packet_out_pack(self):
-        msg = ofp.message.packet_out(
-            xid=0x12345678,
-            buffer_id=0xabcdef01,
-            in_port=ofp.OFPP_LOCAL,
-            actions=[
-                ofp.action.output(port=1),
-                ofp.action.output(port=2)],
-            data='abc')
-        self.assertEquals(self.sample_packet_out_buf, msg.pack())
-
-    def test_packet_out_unpack(self):
-        msg = ofp.message.packet_out.unpack(self.sample_packet_out_buf)
-        self.assertEquals(0x12345678, msg.xid)
-        self.assertEquals(0xabcdef01, msg.buffer_id)
-        self.assertEquals(ofp.OFPP_LOCAL, msg.in_port)
-        self.assertEquals(2, len(msg.actions))
-        self.assertEquals(1, msg.actions[0].port)
-        self.assertEquals(2, msg.actions[1].port)
-        self.assertEquals('abc', msg.data)
-
-    sample_packet_in_buf = ''.join([
-        '\x01', '\x0a', # version/type
-        '\x00\x15', # length
-        '\x12\x34\x56\x78', # xid
-        '\xab\xcd\xef\x01', # buffer_id
-        '\x00\x09', # total_len
-        '\xff\xfe', # in_port
-        '\x01', # reason
-        '\x00', # pad
-        'abc', # data
-    ])
-
-    def test_packet_in_pack(self):
-        msg = ofp.message.packet_in(
-            xid=0x12345678,
-            buffer_id=0xabcdef01,
-            total_len=9,
-            in_port=ofp.OFPP_LOCAL,
-            reason=ofp.OFPR_ACTION,
-            data='abc')
-        self.assertEquals(self.sample_packet_in_buf, msg.pack())
-
-    def test_packet_in_unpack(self):
-        msg = ofp.message.packet_in.unpack(self.sample_packet_in_buf)
-        self.assertEquals(0x12345678, msg.xid)
-        self.assertEquals(0xabcdef01, msg.buffer_id)
-        self.assertEquals(9, msg.total_len)
-        self.assertEquals(ofp.OFPP_LOCAL, msg.in_port)
-        self.assertEquals(ofp.OFPR_ACTION, msg.reason)
-        self.assertEquals('abc', msg.data)
-
-    sample_queue_get_config_reply_buf = ''.join([
-        '\x01', '\x15', # version/type
-        '\x00\x50', # length
-        '\x12\x34\x56\x78', # xid
-        '\xff\xfe', # port
-        '\x00\x00\x00\x00\x00\x00', # pad
-        '\x00\x00\x00\x01', # queues[0].queue_id
-        '\x00\x18', # queues[0].len
-        '\x00\x00', # queues[0].pad
-        '\x00\x01', # queues[0].properties[0].type
-        '\x00\x10', # queues[0].properties[0].length
-        '\x00\x00\x00\x00', # queues[0].properties[0].pad
-        '\x00\x05', # queues[0].properties[0].rate
-        '\x00\x00\x00\x00\x00\x00', # queues[0].properties[0].pad2
-        '\x00\x00\x00\x02', # queues[1].queue_id
-        '\x00\x28', # queues[1].len
-        '\x00\x00', # queues[1].pad
-        '\x00\x01', # queues[1].properties[0].type
-        '\x00\x10', # queues[1].properties[0].length
-        '\x00\x00\x00\x00', # queues[1].properties[0].pad
-        '\x00\x06', # queues[1].properties[0].rate
-        '\x00\x00\x00\x00\x00\x00', # queues[1].properties[0].pad2
-        '\x00\x01', # queues[1].properties[1].type
-        '\x00\x10', # queues[1].properties[1].length
-        '\x00\x00\x00\x00', # queues[1].properties[1].pad
-        '\x00\x07', # queues[1].properties[1].rate
-        '\x00\x00\x00\x00\x00\x00', # queues[1].properties[1].pad2
-    ])
-
-    def test_queue_get_config_reply_pack(self):
-        msg = ofp.message.queue_get_config_reply(
-            xid=0x12345678,
-            port=ofp.OFPP_LOCAL,
-            queues=[
-                ofp.packet_queue(queue_id=1, properties=[
-                    ofp.queue_prop_min_rate(rate=5)]),
-                ofp.packet_queue(queue_id=2, properties=[
-                    ofp.queue_prop_min_rate(rate=6),
-                    ofp.queue_prop_min_rate(rate=7)])])
-        self.assertEquals(self.sample_queue_get_config_reply_buf, msg.pack())
-
-    def test_queue_get_config_reply_unpack(self):
-        msg = ofp.message.queue_get_config_reply.unpack(self.sample_queue_get_config_reply_buf)
-        self.assertEquals(ofp.OFPP_LOCAL, msg.port)
-        self.assertEquals(msg.queues[0].queue_id, 1)
-        self.assertEquals(msg.queues[0].properties[0].rate, 5)
-        self.assertEquals(msg.queues[1].queue_id, 2)
-        self.assertEquals(msg.queues[1].properties[0].rate, 6)
-        self.assertEquals(msg.queues[1].properties[1].rate, 7)
+# The majority of the serialization tests are created here using the files in
+# the test_data directory.
+class TestDataFiles(unittest.TestCase):
+    pass
+add_datafiles_tests(TestDataFiles, 'of10/', ofp)
 
 class TestParse(unittest.TestCase):
     def test_parse_header(self):
diff --git a/py_gen/tests/of12.py b/py_gen/tests/of12.py
index b557730..6926382 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -26,6 +26,7 @@
 # EPL for the specific language governing permissions and limitations
 # under the EPL.
 import unittest
+from testutil import add_datafiles_tests
 
 try:
     import loxi.of12 as ofp
@@ -56,91 +57,11 @@
         self.assertTrue(hasattr(loxi.of12, "message"))
         self.assertTrue(hasattr(loxi.of12, "oxm"))
 
-class TestCommon(unittest.TestCase):
-    sample_empty_match_buf = ''.join([
-        '\x00\x01', # type
-        '\x00\x04', # length
-        '\x00\x00\x00\x00', # padding
-    ])
-
-    def test_empty_match_pack(self):
-        obj = ofp.match()
-        self.assertEquals(self.sample_empty_match_buf, obj.pack())
-
-    def test_empty_match_unpack(self):
-        obj = ofp.match.unpack(self.sample_empty_match_buf)
-        self.assertEquals(len(obj.oxm_list), 0)
-
-    sample_match_buf = ''.join([
-        '\x00\x01', # type
-        '\x00\x3C', # length
-        '\x80\x00', # oxm_list[0].class
-        '\x20\x02', # oxm_list[0].type_len
-        '\x00\x35', # oxm_list[0].value
-        '\x80\x00', # oxm_list[1].class
-        '\x05\x10', # oxm_list[1].type_len
-        '\xFE\xDC\xBA\x98\x76\x54\x32\x10', # oxm_list[1].value
-        '\xFF\xFF\xFF\xFF\x12\x34\x56\x78', # oxm_list[1].mask
-        '\x80\x00', # oxm_list[2].class
-        '\x08\x06', # oxm_list[2].type_len
-        '\x01\x02\x03\x04\x05\x06', # oxm_list[2].value
-        '\x80\x00', # oxm_list[3].class
-        '\x36\x10', # oxm_list[3].type_len
-        '\x12' * 16, # oxm_list[3].value
-        '\x00' * 4, # padding
-    ])
-
-    def test_match_pack(self):
-        obj = ofp.match([
-            ofp.oxm.udp_dst(53),
-            ofp.oxm.metadata_masked(0xFEDCBA9876543210, 0xFFFFFFFF12345678),
-            ofp.oxm.eth_src([1,2,3,4,5,6]),
-            ofp.oxm.ipv6_dst("\x12" * 16),
-        ])
-        self.assertEquals(self.sample_match_buf, obj.pack())
-
-    def test_match_unpack(self):
-        obj = ofp.match.unpack(self.sample_match_buf)
-        self.assertEquals(len(obj.oxm_list), 4)
-        self.assertEquals(obj.oxm_list[0], ofp.oxm.udp_dst(53))
-        self.assertEquals(obj.oxm_list[1], ofp.oxm.metadata_masked(0xFEDCBA9876543210, 0xFFFFFFFF12345678))
-        self.assertEquals(obj.oxm_list[2], ofp.oxm.eth_src([1,2,3,4,5,6]))
-        self.assertEquals(obj.oxm_list[3], ofp.oxm.ipv6_dst("\x12" * 16))
-
-class TestOXM(unittest.TestCase):
-    def test_oxm_in_phy_port_pack(self):
-        import loxi.of12 as ofp
-        obj = ofp.oxm.in_phy_port(value=42)
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x02', # type/masked
-            '\x04', # length
-            '\x00\x00\x00\x2a' # value
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_oxm_in_phy_port_masked_pack(self):
-        import loxi.of12 as ofp
-        obj = ofp.oxm.in_phy_port_masked(value=42, value_mask=0xaabbccdd)
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x03', # type/masked
-            '\x08', # length
-            '\x00\x00\x00\x2a', # value
-            '\xaa\xbb\xcc\xdd' # mask
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_oxm_ipv6_dst_pack(self):
-        import loxi.of12 as ofp
-        obj = ofp.oxm.ipv6_dst(value='\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f')
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x36', # type/masked
-            '\x10', # length
-            '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f', # value
-        ])
-        self.assertEquals(expected, obj.pack())
+# The majority of the serialization tests are created here using the files in
+# the test_data directory.
+class TestDataFiles(unittest.TestCase):
+    pass
+add_datafiles_tests(TestDataFiles, 'of12/', ofp)
 
 class TestAllOF12(unittest.TestCase):
     """
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 3c9772f..9e6be97 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -26,7 +26,8 @@
 # EPL for the specific language governing permissions and limitations
 # under the EPL.
 import unittest
-import difflib
+from testutil import test_serialization
+from testutil import add_datafiles_tests
 
 try:
     import loxi.of13 as ofp
@@ -34,35 +35,6 @@
 except ImportError:
     exit("loxi package not found. Try setting PYTHONPATH.")
 
-# Human-friendly format for binary strings. 8 bytes per line.
-def format_binary(buf):
-    byts = map(ord, buf)
-    lines = [[]]
-    for byt in byts:
-        if len(lines[-1]) == 8:
-            lines.append([])
-        lines[-1].append(byt)
-    return '\n'.join([' '.join(['%02x' % y for y in x]) for x in lines])
-
-def diff(a, b):
-    return '\n'.join(difflib.ndiff(a.splitlines(), b.splitlines()))
-
-# Test serialization / deserialization of a sample object.
-# Depends on the __eq__ method being correct.
-def test_serialization(obj, buf):
-    packed = obj.pack()
-    if packed != buf:
-        a = format_binary(buf)
-        b = format_binary(packed)
-        raise AssertionError("Serialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
-            (type(obj).__name__, a, b, diff(a, b)))
-    unpacked = type(obj).unpack(buf)
-    if obj != unpacked:
-        a = obj.show()
-        b = unpacked.show()
-        raise AssertionError("Deserialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
-            (type(obj).__name__, a, b, diff(a, b)))
-
 class TestImports(unittest.TestCase):
     def test_toplevel(self):
         import loxi
@@ -88,23 +60,6 @@
         self.assertTrue(hasattr(loxi.of13, "oxm"))
 
 class TestCommon(unittest.TestCase):
-    sample_hello_elem_buf = ''.join([
-        '\x00\x01', # type
-        '\x00\x0c', # length
-        '\x01\x23\x45\x67', # bitmaps[0]
-        '\x89\xab\xcd\xef', # bitmaps[1]
-    ])
-
-    def test_hello_elem_versionbitmap_pack(self):
-        obj = ofp.hello_elem_versionbitmap(bitmaps=[ofp.uint32(0x01234567),ofp.uint32(0x89abcdef)])
-        self.assertEquals(self.sample_hello_elem_buf, obj.pack())
-
-    def test_hello_elem_versionbitmap_unpack(self):
-        obj = ofp.hello_elem_versionbitmap.unpack(self.sample_hello_elem_buf)
-        self.assertEquals(len(obj.bitmaps), 2)
-        self.assertEquals(obj.bitmaps[0], ofp.uint32(0x01234567))
-        self.assertEquals(obj.bitmaps[1], ofp.uint32(0x89abcdef))
-
     def test_list_hello_elem_unpack(self):
         buf = ''.join([
             '\x00\x01\x00\x04', # versionbitmap
@@ -116,858 +71,11 @@
         self.assertTrue(isinstance(l[0], ofp.hello_elem_versionbitmap))
         self.assertTrue(isinstance(l[1], ofp.hello_elem_versionbitmap))
 
-class TestMessages(unittest.TestCase):
-    def test_hello(self):
-        obj = ofp.message.hello(
-            xid=0x12345678,
-            elements=[
-                ofp.hello_elem_versionbitmap(
-                    bitmaps=[ofp.uint32(1), ofp.uint32(2)]),
-                ofp.hello_elem_versionbitmap(
-                    bitmaps=[ofp.uint32(3), ofp.uint32(4)])])
-        buf = ''.join([
-            '\x04', '\x00', # version, type
-            '\x00\x20', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x01', # elements[0].type
-            '\x00\x0c', # elements[0].length
-            '\x00\x00\x00\x01', # elements[0].bitmaps[0]
-            '\x00\x00\x00\x02', # elements[0].bitmaps[1]
-            '\x00\x01', # elements[1].type
-            '\x00\x0c', # elements[1].length
-            '\x00\x00\x00\x03', # elements[1].bitmaps[0]
-            '\x00\x00\x00\x04', # elements[1].bitmaps[1]
-        ])
-        test_serialization(obj, buf)
-
-    def test_error(self):
-        obj = ofp.message.error_msg(
-            xid=0x12345678,
-            err_type=ofp.OFPET_BAD_MATCH,
-            code=ofp.OFPBMC_BAD_MASK,
-            data="abc")
-        buf = ''.join([
-            '\x04', '\x01', # version, type
-            '\x00\x0f', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x04', # err_type
-            '\x00\x08', # code
-            'abc', # data
-        ])
-        test_serialization(obj, buf)
-
-    def test_echo_request(self):
-        obj = ofp.message.echo_request(
-            xid=0x12345678,
-            data="abc")
-        buf = ''.join([
-            '\x04', '\x02', # version, type
-            '\x00\x0b', # length
-            '\x12\x34\x56\x78', # xid
-            'abc', # data
-        ])
-        test_serialization(obj, buf)
-
-    def test_echo_reply(self):
-        obj = ofp.message.echo_reply(
-            xid=0x12345678,
-            data="abc")
-        buf = ''.join([
-            '\x04', '\x03', # version, type
-            '\x00\x0b', # length
-            '\x12\x34\x56\x78', # xid
-            'abc', # data
-        ])
-        test_serialization(obj, buf)
-
-    def test_features_request(self):
-        obj = ofp.message.features_request(xid=0x12345678)
-        buf = ''.join([
-            '\x04', '\x05', # version, type
-            '\x00\x08', # length
-            '\x12\x34\x56\x78', # xid
-        ])
-        test_serialization(obj, buf)
-
-    def test_features_reply(self):
-        obj = ofp.message.features_reply(
-            xid=0x12345678,
-            datapath_id=0xFEDCBA9876543210,
-            n_buffers=64,
-            n_tables=200,
-            auxiliary_id=5,
-            capabilities=ofp.OFPC_FLOW_STATS|ofp.OFPC_PORT_BLOCKED,
-            reserved=0)
-        buf = ''.join([
-            '\x04', '\x06', # version, type
-            '\x00\x20', # length
-            '\x12\x34\x56\x78', # xid
-            '\xfe\xdc\xba\x98\x76\x54\x32\x10', # datapath_id
-            '\x00\x00\x00\x40', # n_buffers
-            '\xc8', # n_tables
-            '\x05', # auxiliary_id
-            '\x00\x00', # pad
-            '\x00\x00\x01\x01', # capabilities
-            '\x00\x00\x00\x00', # reserved
-        ])
-        test_serialization(obj, buf)
-
-    def test_get_config_request(self):
-        obj = ofp.message.get_config_request(xid=0x12345678)
-        buf = ''.join([
-            '\x04', '\x07', # version, type
-            '\x00\x08', # length
-            '\x12\x34\x56\x78', # xid
-        ])
-        test_serialization(obj, buf)
-
-    def test_get_config_reply(self):
-        obj = ofp.message.get_config_reply(
-            xid=0x12345678,
-            flags=ofp.OFPC_FRAG_REASM,
-            miss_send_len=0xffff)
-        buf = ''.join([
-            '\x04', '\x08', # version, type
-            '\x00\x0c', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x02', # flags
-            '\xff\xff', # miss_send_len
-        ])
-        test_serialization(obj, buf)
-
-    def test_set_config(self):
-        obj = ofp.message.set_config(
-            xid=0x12345678,
-            flags=ofp.OFPC_FRAG_REASM,
-            miss_send_len=0xffff)
-        buf = ''.join([
-            '\x04', '\x09', # version, type
-            '\x00\x0c', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x02', # flags
-            '\xff\xff', # miss_send_len
-        ])
-        test_serialization(obj, buf)
-
-    def test_packet_in(self):
-        obj = ofp.message.packet_in(
-            xid=0x12345678,
-            buffer_id=100,
-            total_len=17000,
-            reason=ofp.OFPR_ACTION,
-            table_id=20,
-            cookie=0xFEDCBA9876543210,
-            match=ofp.match(oxm_list=[
-                ofp.oxm.arp_op(value=1),
-                ofp.oxm.in_port_masked(value=4, value_mask=5)]),
-            data="abc")
-        buf = ''.join([
-            '\x04', '\x0a', # version, type
-            '\x00\x35', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x00\x00\x64', # buffer_id
-            '\x42\x68', # total_len
-            '\x01', # reason
-            '\x14', # table_id
-            '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
-            '\x00\x01', # match.type
-            '\x00\x16', # match.length
-            '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
-            '\x00\x01', # match.oxm_list[0].value
-            '\x80\x00\x01\x08', # match.oxm_list[1].type_len
-            '\x00\x00\x00\x04', # match.oxm_list[1].value
-            '\x00\x00\x00\x05', # match.oxm_list[1].mask
-            '\x00\x00', # match.pad
-            '\x00\x00', # pad
-            'abc', # data
-        ])
-        test_serialization(obj, buf)
-
-    def test_flow_removed(self):
-        obj = ofp.message.flow_removed(
-            xid=0x12345678,
-            cookie=0xFEDCBA9876543210,
-            priority=17000,
-            reason=ofp.OFPRR_DELETE,
-            table_id=20,
-            duration_sec=10,
-            duration_nsec=1000,
-            idle_timeout=5,
-            hard_timeout=30,
-            packet_count=1,
-            byte_count=2,
-            match=ofp.match(oxm_list=[
-                ofp.oxm.arp_op(value=1),
-                ofp.oxm.in_port_masked(value=4, value_mask=5)]))
-        buf = ''.join([
-            '\x04', '\x0b', # version, type
-            '\x00\x48', # length
-            '\x12\x34\x56\x78', # xid
-            '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
-            '\x42\x68', # priority
-            '\x02', # reason
-            '\x14', # table_id
-            '\x00\x00\x00\x0a', # duration_sec
-            '\x00\x00\x03\xe8', # duration_nsec
-            '\x00\x05', # idle_timeout
-            '\x00\x1e', # hard_timeout
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # packet_count
-            '\x00\x00\x00\x00\x00\x00\x00\x02', # byte_count
-            '\x00\x01', # match.type
-            '\x00\x16', # match.length
-            '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
-            '\x00\x01', # match.oxm_list[0].value
-            '\x80\x00\x01\x08', # match.oxm_list[1].type_len
-            '\x00\x00\x00\x04', # match.oxm_list[1].value
-            '\x00\x00\x00\x05', # match.oxm_list[1].mask
-            '\x00\x00', # match.pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_port_status(self):
-        obj = ofp.message.port_status(
-            xid=0x12345678,
-            reason=ofp.OFPPR_MODIFY,
-            desc=ofp.port_desc(
-                port_no=4,
-                hw_addr=[1,2,3,4,5,6],
-                name="foo",
-                config=ofp.OFPPC_NO_FWD|ofp.OFPPC_NO_RECV,
-                state=ofp.OFPPS_BLOCKED,
-                curr=ofp.OFPPF_10MB_HD,
-                advertised=ofp.OFPPF_10MB_FD,
-                supported=ofp.OFPPF_100MB_HD,
-                peer=ofp.OFPPF_100MB_FD,
-                curr_speed=10,
-                max_speed=20))
-        buf = ''.join([
-            '\x04', '\x0c', # version, type
-            '\x00\x50', # length
-            '\x12\x34\x56\x78', # xid
-            '\x02', # reason
-            '\x00' * 7, # pad
-            '\x00\x00\x00\x04', # port_no
-            '\x00' * 4, # pad
-            '\x01\x02\x03\x04\x05\x06', # hw_addr
-            '\x00' * 2, # pad
-            'foo' + '\x00' * 13, # name
-            '\x00\x00\x00\x24', # config
-            '\x00\x00\x00\x02', # state
-            '\x00\x00\x00\x01', # curr
-            '\x00\x00\x00\x02', # advertised
-            '\x00\x00\x00\x04', # supported
-            '\x00\x00\x00\x08', # peer
-            '\x00\x00\x00\x0a', # curr_speed
-            '\x00\x00\x00\x14', # max_speed
-        ])
-        test_serialization(obj, buf)
-
-    def test_packet_out(self):
-        obj = ofp.message.packet_out(
-            xid=0x12345678,
-            buffer_id=100,
-            in_port=4,
-            actions=[
-                ofp.action.output(port=2, max_len=0xffff),
-                ofp.action.dec_nw_ttl()],
-            data="abc")
-        buf = ''.join([
-            '\x04', '\x0d', # version, type
-            '\x00\x33', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x00\x00\x64', # buffer_id
-            '\x00\x00\x00\x04', # in_port
-            '\x00\x18', # actions_len
-            '\x00' * 6, # pad
-            '\x00\x00', # actions[0].type
-            '\x00\x10', # actions[0].length
-            '\x00\x00\x00\x02', # actions[0].port
-            '\xff\xff', # actions[0].max_len
-            '\x00' * 6, # pad
-            '\x00\x18', # actions[1].type
-            '\x00\x08', # actions[1].length
-            '\x00' * 4, # pad
-            'abc', # data
-        ])
-        test_serialization(obj, buf)
-
-
-    ## Flow-mods
-
-    def test_flow_add(self):
-        obj = ofp.message.flow_add(
-            xid=0x12345678,
-            cookie=0xFEDCBA9876543210,
-            cookie_mask=0xFF00FF00FF00FF00,
-            table_id=3,
-            idle_timeout=5,
-            hard_timeout=10,
-            priority=6000,
-            buffer_id=50,
-            out_port=6,
-            out_group=8,
-            flags=0,
-            match=ofp.match(oxm_list=[]),
-            instructions=[
-                ofp.instruction.goto_table(table_id=4),
-                ofp.instruction.goto_table(table_id=7)])
-        buf = ''.join([
-            '\x04', '\x0e', # version, type
-            '\x00\x48', # length
-            '\x12\x34\x56\x78', # xid
-
-            '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
-
-            '\xff\x00\xff\x00\xff\x00\xff\x00', # cookie_mask
-
-            '\x03', # table_id
-            '\x00', # _command
-            '\x00\x05', # idle_timeout
-            '\x00\x0a', # hard_timeout
-            '\x17\x70', # priority
-
-            '\x00\x00\x00\x32', # buffer_id
-            '\x00\x00\x00\x06', # out_port
-
-            '\x00\x00\x00\x08', # out_group
-            '\x00\x00', # flags
-            '\x00' * 2, # pad
-
-            '\x00\x01', # match.type
-            '\x00\x04', # match.length
-            '\x00' * 4, # pad
-
-            '\x00\x01', # instructions[0].type
-            '\x00\x08', # instructions[0].length
-            '\x04', # instructions[0].table_id
-            '\x00' * 3, # pad
-
-            '\x00\x01', # instructions[1].type
-            '\x00\x08', # instructions[1].length
-            '\x07', # instructions[1].table_id
-            '\x00' * 3, # pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_flow_modify(self):
-        # TODO
-        pass
-
-    def test_flow_modify_strict(self):
-        # TODO
-        pass
-
-    def test_flow_delete(self):
-        # TODO
-        pass
-
-    def test_flow_delete_strict(self):
-        # TODO
-        pass
-
-
-    def test_group_mod(self):
-        obj = ofp.message.group_mod(
-            xid=0x12345678,
-            command=ofp.OFPGC_MODIFY,
-            group_type=ofp.OFPGT_FF,
-            group_id=5,
-            buckets=[
-                ofp.bucket(
-                    weight=1,
-                    watch_port=5,
-                    watch_group=0xffffffff,
-                    actions=[
-                        ofp.action.output(port=5, max_len=0),
-                        ofp.action.output(port=6, max_len=0)]),
-                ofp.bucket(
-                    weight=1,
-                    watch_port=6,
-                    watch_group=0xffffffff,
-                    actions=[
-                        ofp.action.output(port=5, max_len=0),
-                        ofp.action.output(port=6, max_len=0)])])
-        buf = ''.join([
-            '\x04', '\x0f', # version, type
-            '\x00\x70', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x01', # command
-            '\x03', # group_type
-            '\x00', # pad
-            '\x00\x00\x00\x05', # group_id
-            '\x00\x30', # buckets[0].len
-            '\x00\x01', # buckets[0].weight
-            '\x00\x00\x00\x05', # buckets[0].watch_port
-            '\xff\xff\xff\xff', # buckets[0].watch_group
-            '\x00' * 4, # pad
-            '\x00\x00', # buckets[0].actions[0].type
-            '\x00\x10', # buckets[0].actions[0].len
-            '\x00\x00\x00\x05', # buckets[0].actions[0].port
-            '\x00\x00', # buckets[0].actions[0].max_len
-            '\x00' * 6, # pad
-            '\x00\x00', # buckets[0].actions[1].type
-            '\x00\x10', # buckets[0].actions[1].len
-            '\x00\x00\x00\x06', # buckets[0].actions[1].port
-            '\x00\x00', # buckets[0].actions[1].max_len
-            '\x00' * 6, # pad
-            '\x00\x30', # buckets[1].len
-            '\x00\x01', # buckets[1].weight
-            '\x00\x00\x00\x06', # buckets[1].watch_port
-            '\xff\xff\xff\xff', # buckets[1].watch_group
-            '\x00' * 4, # pad
-            '\x00\x00', # buckets[1].actions[0].type
-            '\x00\x10', # buckets[1].actions[0].len
-            '\x00\x00\x00\x05', # buckets[1].actions[0].port
-            '\x00\x00', # buckets[1].actions[0].max_len
-            '\x00' * 6, # pad
-            '\x00\x00', # buckets[1].actions[1].type
-            '\x00\x10', # buckets[1].actions[1].len
-            '\x00\x00\x00\x06', # buckets[1].actions[1].port
-            '\x00\x00', # buckets[1].actions[1].max_len
-            '\x00' * 6, # pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_port_mod(self):
-        # TODO
-        pass
-
-    def test_table_mod(self):
-        # TODO
-        pass
-
-
-    ## Multipart messages
-
-    def test_desc_stats_request(self):
-        # TODO
-        pass
-
-    def test_desc_stats_reply(self):
-        # TODO
-        pass
-
-    def test_flow_stats_request(self):
-        # TODO
-        pass
-
-    def test_flow_stats_reply(self):
-        # TODO
-        pass
-
-    def test_aggregate_stats_request(self):
-        # TODO
-        pass
-
-    def test_aggregate_stats_reply(self):
-        # TODO
-        pass
-
-    def test_port_stats_request(self):
-        # TODO
-        pass
-
-    def test_port_stats_reply(self):
-        # TODO
-        pass
-
-    def test_queue_stats_request(self):
-        # TODO
-        pass
-
-    def test_queue_stats_reply(self):
-        # TODO
-        pass
-
-    def test_group_stats_request(self):
-        # TODO
-        pass
-
-    def test_group_stats_reply(self):
-        obj = ofp.message.group_stats_reply(
-            xid=0x12345678,
-            flags=0,
-            entries=[
-                ofp.group_stats_entry(
-                    group_id=1,
-                    ref_count=8,
-                    packet_count=16,
-                    byte_count=32,
-                    duration_sec=20,
-                    duration_nsec=100,
-                    bucket_stats=[
-                        ofp.bucket_counter(packet_count=1, byte_count=2),
-                        ofp.bucket_counter(packet_count=3, byte_count=4)]),
-                ofp.group_stats_entry(
-                    group_id=1,
-                    ref_count=8,
-                    packet_count=16,
-                    byte_count=32,
-                    duration_sec=20,
-                    duration_nsec=100,
-                    bucket_stats=[])])
-        buf = ''.join([
-            '\x04', '\x13', # version, type
-            '\x00\x80', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x06', # stats_type
-            '\x00\x00', # flags
-            '\x00' * 4, # pad
-            '\x00\x48', # entries[0].length
-            '\x00' * 2, # pad
-            '\x00\x00\x00\x01', # entries[0].group_id
-            '\x00\x00\x00\x08', # entries[0].ref_count
-            '\x00' * 4, # pad
-            '\x00\x00\x00\x00\x00\x00\x00\x10', # entries[0].packet_count
-            '\x00\x00\x00\x00\x00\x00\x00\x20', # entries[0].byte_count
-            '\x00\x00\x00\x14', # entries[0].duration_sec
-            '\x00\x00\x00\x64', # entries[0].duration_nsec
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[0].bucket_stats[0].packet_count
-            '\x00\x00\x00\x00\x00\x00\x00\x02', # entries[0].bucket_stats[0].byte_count
-            '\x00\x00\x00\x00\x00\x00\x00\x03', # entries[0].bucket_stats[1].packet_count
-            '\x00\x00\x00\x00\x00\x00\x00\x04', # entries[0].bucket_stats[1].byte_count
-            '\x00\x28', # entries[0].length
-            '\x00' * 2, # pad
-            '\x00\x00\x00\x01', # entries[0].group_id
-            '\x00\x00\x00\x08', # entries[0].ref_count
-            '\x00' * 4, # pad
-            '\x00\x00\x00\x00\x00\x00\x00\x10', # entries[0].packet_count
-            '\x00\x00\x00\x00\x00\x00\x00\x20', # entries[0].byte_count
-            '\x00\x00\x00\x14', # entries[0].duration_sec
-            '\x00\x00\x00\x64', # entries[0].duration_nsec
-        ])
-        test_serialization(obj, buf)
-
-    def test_group_desc_stats_request(self):
-        # TODO
-        pass
-
-    def test_group_desc_stats_reply(self):
-        obj = ofp.message.group_desc_stats_reply(
-            xid=0x12345678,
-            flags=0,
-            entries=[
-                ofp.group_desc_stats_entry(
-                    type=ofp.OFPGT_FF,
-                    group_id=1,
-                    buckets=[
-                        ofp.bucket(
-                            weight=1,
-                            watch_port=5,
-                            watch_group=0xffffffff,
-                            actions=[
-                                ofp.action.output(port=5, max_len=0),
-                                ofp.action.output(port=6, max_len=0)]),
-                        ofp.bucket(
-                            weight=1,
-                            watch_port=6,
-                            watch_group=0xffffffff,
-                            actions=[
-                                ofp.action.output(port=5, max_len=0),
-                                ofp.action.output(port=6, max_len=0)])]),
-                ofp.group_desc_stats_entry(type=ofp.OFPGT_FF, group_id=2, buckets=[])])
-        buf = ''.join([
-            '\x04', '\x13', # version, type
-            '\x00\x80', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x07', # stats_type
-            '\x00\x00', # flags
-            '\x00' * 4, # pad
-            '\x00\x68', # entries[0].length
-            '\x03', # entries[0].group_type
-            '\x00', # entries[0].pad
-            '\x00\x00\x00\x01', # entries[0].group_id
-            '\x00\x30', # entries[0].buckets[0].len
-            '\x00\x01', # entries[0].buckets[0].weight
-            '\x00\x00\x00\x05', # entries[0].buckets[0].watch_port
-            '\xff\xff\xff\xff', # entries[0].buckets[0].watch_group
-            '\x00' * 4, # entries[0].pad
-            '\x00\x00', # entries[0].buckets[0].actions[0].type
-            '\x00\x10', # entries[0].buckets[0].actions[0].len
-            '\x00\x00\x00\x05', # entries[0].buckets[0].actions[0].port
-            '\x00\x00', # entries[0].buckets[0].actions[0].max_len
-            '\x00' * 6, # entries[0].pad
-            '\x00\x00', # entries[0].buckets[0].actions[1].type
-            '\x00\x10', # entries[0].buckets[0].actions[1].len
-            '\x00\x00\x00\x06', # entries[0].buckets[0].actions[1].port
-            '\x00\x00', # entries[0].buckets[0].actions[1].max_len
-            '\x00' * 6, # entries[0].pad
-            '\x00\x30', # entries[0].buckets[1].len
-            '\x00\x01', # entries[0].buckets[1].weight
-            '\x00\x00\x00\x06', # entries[0].buckets[1].watch_port
-            '\xff\xff\xff\xff', # entries[0].buckets[1].watch_group
-            '\x00' * 4, # entries[0].pad
-            '\x00\x00', # entries[0].buckets[1].actions[0].type
-            '\x00\x10', # entries[0].buckets[1].actions[0].len
-            '\x00\x00\x00\x05', # entries[0].buckets[1].actions[0].port
-            '\x00\x00', # entries[0].buckets[1].actions[0].max_len
-            '\x00' * 6, # entries[0].pad
-            '\x00\x00', # entries[0].buckets[1].actions[1].type
-            '\x00\x10', # entries[0].buckets[1].actions[1].len
-            '\x00\x00\x00\x06', # entries[0].buckets[1].actions[1].port
-            '\x00\x00', # entries[0].buckets[1].actions[1].max_len
-            '\x00' * 6, # entries[0].pad
-            '\x00\x08', # entries[1].length
-            '\x03', # entries[1].group_type
-            '\x00', # entries[1].pad
-            '\x00\x00\x00\x02', # entries[1].group_id
-        ])
-        test_serialization(obj, buf)
-
-    def test_group_features_stats_request(self):
-        # TODO
-        pass
-
-    def test_group_features_stats_reply(self):
-        # TODO
-        pass
-
-    def test_meter_stats_request(self):
-        # TODO
-        pass
-
-    def test_meter_stats_reply(self):
-        obj = ofp.message.meter_stats_reply(
-            xid=0x12345678,
-            flags=0,
-            entries=[
-                ofp.meter_stats(
-                    meter_id=1,
-                    flow_count=8,
-                    packet_in_count=16,
-                    byte_in_count=32,
-                    duration_sec=20,
-                    duration_nsec=100,
-                    band_stats=[
-                        ofp.meter_band_stats(packet_band_count=1, byte_band_count=2),
-                        ofp.meter_band_stats(packet_band_count=3, byte_band_count=4)]),
-                ofp.meter_stats(
-                    meter_id=2,
-                    flow_count=8,
-                    packet_in_count=16,
-                    byte_in_count=32,
-                    duration_sec=20,
-                    duration_nsec=100,
-                    band_stats=[])])
-        buf = ''.join([
-            '\x04', '\x13', # version, type
-            '\x00\x80', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x09', # stats_type
-            '\x00\x00', # flags
-            '\x00' * 4, # pad
-            '\x00\x00\x00\x01', # entries[0].meter_id
-            '\x00\x48', # entries[0].len
-            '\x00' * 6, # pad
-            '\x00\x00\x00\x08', # entries[0].flow_count
-            '\x00\x00\x00\x00\x00\x00\x00\x10', # entries[0].packet_in_count
-            '\x00\x00\x00\x00\x00\x00\x00\x20', # entries[0].byte_in_count
-            '\x00\x00\x00\x14', # entries[0].duration_sec
-            '\x00\x00\x00\x64', # entries[0].duration_nsec
-            '\x00\x00\x00\x00\x00\x00\x00\x01', # entries[0].band_stats[0].packet_band_count
-            '\x00\x00\x00\x00\x00\x00\x00\x02', # entries[0].band_stats[0].byte_band_count
-            '\x00\x00\x00\x00\x00\x00\x00\x03', # entries[0].band_stats[1].packet_band_count
-            '\x00\x00\x00\x00\x00\x00\x00\x04', # entries[0].band_stats[1].byte_band_count
-            '\x00\x00\x00\x02', # entries[1].meter_id
-            '\x00\x28', # entries[1].len
-            '\x00' * 6, # pad
-            '\x00\x00\x00\x08', # entries[1].flow_count
-            '\x00\x00\x00\x00\x00\x00\x00\x10', # entries[1].packet_in_count
-            '\x00\x00\x00\x00\x00\x00\x00\x20', # entries[1].byte_in_count
-            '\x00\x00\x00\x14', # entries[1].duration_sec
-            '\x00\x00\x00\x64', # entries[1].duration_nsec
-        ])
-        test_serialization(obj, buf)
-
-    def test_meter_config_stats_request(self):
-        # TODO
-        pass
-
-    def test_meter_config_stats_reply(self):
-        obj = ofp.message.meter_config_stats_reply(
-            xid=0x12345678,
-            flags=0,
-            entries=[
-                ofp.meter_band.drop(rate=1, burst_size=2),
-                ofp.meter_band.dscp_remark(rate=3, burst_size=4, prec_level=5)])
-        buf = ''.join([
-            '\x04', '\x13', # version, type
-            '\x00\x30', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x0a', # stats_type
-            '\x00\x00', # flags
-            '\x00' * 4, # pad
-            '\x00\x01', # entries[0].type
-            '\x00\x10', # entries[0].length
-            '\x00\x00\x00\x01', # entries[0].rate
-            '\x00\x00\x00\x02', # entries[0].burst_size
-            '\x00' * 4, # pad
-            '\x00\x02', # entries[1].type
-            '\x00\x10', # entries[1].length
-            '\x00\x00\x00\x03', # entries[1].rate
-            '\x00\x00\x00\x04', # entries[1].burst_size
-            '\x05', # entries[1].prec_level
-            '\x00' * 3, # pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_meter_features_stats_request(self):
-        # TODO
-        pass
-
-    def test_meter_features_stats_reply(self):
-        obj = ofp.message.meter_features_stats_reply(
-            xid=0x12345678,
-            flags=0,
-            features=ofp.meter_features(
-                max_meter=5,
-                band_types=ofp.OFPMBT_DROP|ofp.OFPMBT_DSCP_REMARK,
-                capabilities=ofp.OFPMF_KBPS|ofp.OFPMF_STATS,
-                max_bands=10,
-                max_color=7))
-        buf = ''.join([
-            '\x04', '\x13', # version, type
-            '\x00\x20', # length
-            '\x12\x34\x56\x78', # xid
-            '\x00\x0b', # stats_type
-            '\x00\x00', # flags
-            '\x00' * 4, # pad
-            '\x00\x00\x00\x05', # max_meter
-            '\x00\x00\x00\x03', # band_types
-            '\x00\x00\x00\x09', # capabilities
-            '\x0a', # max_bands
-            '\x07', # max_color
-            '\x00' * 2, # pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_table_features_stats_request(self):
-        # TODO
-        pass
-
-    def test_table_features_stats_reply(self):
-        # TODO
-        pass
-
-    def test_port_desc_stats_request(self):
-        # TODO
-        pass
-
-    def test_port_desc_stats_reply(self):
-        # TODO
-        pass
-
-
-    def test_barrier_request(self):
-        # TODO
-        pass
-
-    def test_barrier_reply(self):
-        # TODO
-        pass
-
-    def test_queue_get_config_request(self):
-        # TODO
-        pass
-
-    def test_queue_get_config_reply(self):
-        # TODO
-        pass
-
-    def test_role_request(self):
-        # TODO
-        pass
-
-    def test_role_reply(self):
-        # TODO
-        pass
-
-    def test_get_async_request(self):
-        # TODO
-        pass
-
-    def test_get_async_reply(self):
-        # TODO
-        pass
-
-    def test_set_async(self):
-        # TODO
-        pass
-
-    def test_meter_mod(self):
-        # TODO
-        pass
-
-    # TODO test experimenter messages
-
-
-class TestOXM(unittest.TestCase):
-    def test_oxm_in_phy_port_pack(self):
-        import loxi.of13 as ofp
-        obj = ofp.oxm.in_phy_port(value=42)
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x02', # type/masked
-            '\x04', # length
-            '\x00\x00\x00\x2a' # value
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_oxm_in_phy_port_masked_pack(self):
-        import loxi.of13 as ofp
-        obj = ofp.oxm.in_phy_port_masked(value=42, value_mask=0xaabbccdd)
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x03', # type/masked
-            '\x08', # length
-            '\x00\x00\x00\x2a', # value
-            '\xaa\xbb\xcc\xdd' # mask
-        ])
-        self.assertEquals(expected, obj.pack())
-
-    def test_oxm_ipv6_dst_pack(self):
-        import loxi.of13 as ofp
-        obj = ofp.oxm.ipv6_dst(value='\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f')
-        expected = ''.join([
-            '\x80\x00', # class
-            '\x36', # type/masked
-            '\x10', # length
-            '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0d\x0f', # value
-        ])
-        self.assertEquals(expected, obj.pack())
-
-class TestInstructions(unittest.TestCase):
-    def test_goto_table(self):
-        obj = ofp.instruction.goto_table(table_id=5)
-        buf = ''.join([
-            '\x00\x01', # type
-            '\x00\x08', # length
-            '\x05', # table_id
-            '\x00' * 3, # pad
-        ])
-        test_serialization(obj, buf)
-
-    def test_write_metadata(self):
-        # TODO
-        pass
-
-    def test_write_actions(self):
-        # TODO
-        pass
-
-    def test_apply_actions(self):
-        # TODO
-        pass
-
-    def test_clear_actions(self):
-        # TODO
-        pass
-
-    def test_meter(self):
-        # TODO
-        pass
-
-    # TODO test experimenter instructions
+# The majority of the serialization tests are created here using the files in
+# the test_data directory.
+class TestDataFiles(unittest.TestCase):
+    pass
+add_datafiles_tests(TestDataFiles, 'of13/', ofp)
 
 class TestAllOF13(unittest.TestCase):
     """
diff --git a/py_gen/tests/testutil.py b/py_gen/tests/testutil.py
new file mode 100644
index 0000000..ea30902
--- /dev/null
+++ b/py_gen/tests/testutil.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+import sys
+import difflib
+import re
+import os
+import unittest
+import test_data
+
+# Human-friendly format for binary strings. 8 bytes per line.
+def format_binary(buf):
+    byts = map(ord, buf)
+    lines = [[]]
+    for byt in byts:
+        if len(lines[-1]) == 8:
+            lines.append([])
+        lines[-1].append(byt)
+    return '\n'.join([' '.join(['%02x' % y for y in x]) for x in lines])
+
+def diff(a, b):
+    return '\n'.join(difflib.ndiff(a.splitlines(), b.splitlines()))
+
+# Test serialization / deserialization / reserialization of a sample object.
+# Depends in part on the __eq__ method being correct.
+def test_serialization(obj, buf):
+    packed = obj.pack()
+    if packed != buf:
+        a = format_binary(buf)
+        b = format_binary(packed)
+        raise AssertionError("Serialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+            (type(obj).__name__, a, b, diff(a, b)))
+    unpacked = type(obj).unpack(buf)
+    if obj != unpacked:
+        a = obj.show()
+        b = unpacked.show()
+        raise AssertionError("Deserialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+            (type(obj).__name__, a, b, diff(a, b)))
+    packed = unpacked.pack()
+    if packed != buf:
+        a = format_binary(buf)
+        b = format_binary(packed)
+        raise AssertionError("Reserialization of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+            (type(obj).__name__, a, b, diff(a, b)))
+
+def test_pretty(obj, expected):
+    pretty = obj.show()
+    if expected != pretty:
+        raise AssertionError("Pretty printing of %s failed\nExpected:\n%s\nActual:\n%s\nDiff:\n%s" % \
+            (type(obj).__name__, expected, pretty, diff(expected, pretty)))
+
+# Run test_serialization and possibly test_pretty against the named data file
+def test_datafile(name, ofp):
+    data = test_data.read(name)
+    if not 'python' in data:
+        raise unittest.SkipTest("no python section in datafile")
+    binary = data['binary']
+    python = data['python']
+    obj = eval(python, { 'ofp': ofp })
+    test_serialization(obj, binary)
+    if 'python pretty-printer' in data:
+        test_pretty(obj, data['python pretty-printer'])
+
+# Add test_datafile tests for each datafile matching the given regex
+# The argument 'klass' should be a subclass of TestCase which will have the
+# test_* methods added to it.
+#
+# It would be cleaner to do this by constructing a TestSuite instance and
+# adding individual TestCase objects, but the TestLoader wouldn't pick it
+# up. We could use the load_tests protocol but that isn't available before
+# Python 2.7.
+def add_datafiles_tests(klass, regex, ofp):
+    for filename in test_data.list_files():
+        match = re.match(regex, filename)
+        if not match:
+            continue
+        def make_test(filename):
+            def fn(self):
+                test_datafile(filename, ofp)
+            return fn
+        setattr(klass, 'test_' + os.path.splitext(filename)[0], make_test(filename))
diff --git a/test_data/__init__.py b/test_data/__init__.py
new file mode 100644
index 0000000..f21770b
--- /dev/null
+++ b/test_data/__init__.py
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+import os
+
+_test_data_dir = os.path.dirname(os.path.realpath(__file__))
+
+def list_files():
+    """
+    Return a list of the data files in this directory
+
+    These strings are suitable to be passed to read().
+    """
+
+    result = []
+    for dirname, dirnames, filenames in os.walk(_test_data_dir):
+        dirname = os.path.relpath(dirname, _test_data_dir)
+        for filename in filenames:
+            if filename.endswith('.data') and not filename.startswith('.'):
+                result.append(dirname + '/' + filename)
+    return sorted(result)
+
+def read(name):
+    """
+    Read, parse, and return a test data file
+
+    @param name Filename relative to the test_data directory
+    @returns A hash from section to the string contents
+
+    A section named "binary" is treated specially: it's treated
+    as a hex dump and parsed into a binary string.
+    """
+
+    section_lines = {}
+    cur_section = None
+
+    with open(os.path.join(_test_data_dir, name)) as f:
+        for line in f:
+            line = line.rstrip().partition('#')[0].rstrip()
+            if line == '':
+                continue
+            elif line.startswith('--'):
+                cur_section = line[2:].strip()
+                if cur_section in section_lines:
+                    raise Exception("section %s already exists in the test data file")
+                section_lines[cur_section] = []
+            elif cur_section:
+                section_lines[cur_section].append(line)
+    data = { section: '\n'.join(lines) for (section, lines) in section_lines.items() }
+
+    # Special case: convert 'binary' section into binary
+    # The string '00 11\n22 33' results in "\x00\x11\x22\x33"
+    if 'binary' in data:
+        hex_strs = data['binary'].split()
+        data['binary'] = ''.join(map(lambda x: chr(int(x, 16)), hex_strs))
+
+    return data
diff --git a/test_data/action_output.data b/test_data/action_output.data
new file mode 100644
index 0000000..3afb525
--- /dev/null
+++ b/test_data/action_output.data
@@ -0,0 +1,9 @@
+-- binary
+00 00 # type
+00 08 # len
+ff f8 # in_port
+ff ff # max_len
+-- python
+ofp.action.output(port=ofp.OFPP_IN_PORT, max_len=0xffff)
+-- python pretty-printer
+output { port = OFPP_IN_PORT, max_len = 0xffff }
diff --git a/test_data/example.data b/test_data/example.data
new file mode 100644
index 0000000..d6186e8
--- /dev/null
+++ b/test_data/example.data
@@ -0,0 +1,17 @@
+# Comment outside section
+# Another comment
+
+# That was a blank line
+This is not a blank line
+-- section1
+ abc def
+ghi
+-- section2
+123
+456 # comment
+# comment inside a section
+789
+-- binary
+00 01 02 03 04 05 06 07 # comment
+77 66 55 44 33 22 11 00
+ # comment in binary
diff --git a/test_data/of10/action_bsn_set_tunnel_dst.data b/test_data/of10/action_bsn_set_tunnel_dst.data
new file mode 100644
index 0000000..7e1f43d
--- /dev/null
+++ b/test_data/of10/action_bsn_set_tunnel_dst.data
@@ -0,0 +1,10 @@
+-- binary
+ff ff # type
+00 10 # len
+00 5c 16 c7 # experimenter
+00 00 00 02 # subtype
+12 34 56 78 # dst
+-- python
+ofp.action.bsn_set_tunnel_dst(dst=0x12345678)
+-- python pretty-printer
+bsn_set_tunnel_dst { dst = 0x12345678 }
diff --git a/test_data/of10/desc_stats_reply.data b/test_data/of10/desc_stats_reply.data
new file mode 100644
index 0000000..b4b3eb1
--- /dev/null
+++ b/test_data/of10/desc_stats_reply.data
@@ -0,0 +1,147 @@
+-- binary
+01 11 # version / type
+04 2c # length
+00 00 00 03 # xid
+00 00 # stats_type
+00 01 # flags
+54 68 65 20 49 6e 64 69 # mfr_desc
+67 6f 2d 32 20 43 6f 6d # ...
+6d 75 6e 69 74 79 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+55 6e 6b 6e 6f 77 6e 20 # hw_desc
+73 65 72 76 65 72 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+49 6e 64 69 67 6f 2d 32 # sw_desc
+20 4c 52 49 20 70 72 65 # ...
+2d 72 65 6c 65 61 73 65 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+31 31 32 33 35 38 31 33 # serial_num
+32 31 33 34 35 35 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+49 6e 64 69 67 6f 2d 32 # dp_desc
+20 4c 52 49 20 66 6f 72 # ...
+77 61 72 64 69 6e 67 20 # ...
+6d 6f 64 75 6c 65 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+-- python
+ofp.message.desc_stats_reply(
+    xid=3,
+    flags=ofp.OFPSF_REPLY_MORE,
+    mfr_desc="The Indigo-2 Community",
+    hw_desc="Unknown server",
+    sw_desc="Indigo-2 LRI pre-release",
+    serial_num="11235813213455",
+    dp_desc="Indigo-2 LRI forwarding module")
diff --git a/test_data/of10/echo_request.data b/test_data/of10/echo_request.data
new file mode 100644
index 0000000..abe06fc
--- /dev/null
+++ b/test_data/of10/echo_request.data
@@ -0,0 +1,9 @@
+-- binary
+01 02 # version / type
+00 0b # length
+12 34 56 78 # xid
+61 62 01 # data
+-- python
+ofp.message.echo_request(xid=0x12345678, data="ab\x01")
+-- python pretty-printer
+echo_request { xid = 0x12345678, data = 'ab\x01' }
diff --git a/test_data/of10/flow_add.data b/test_data/of10/flow_add.data
new file mode 100644
index 0000000..9801a36
--- /dev/null
+++ b/test_data/of10/flow_add.data
@@ -0,0 +1,62 @@
+-- binary
+01 0e 00 70 12 34 56 78
+00 00 00 0c 00 03 01 23
+45 67 89 ab cd ef 01 23
+45 67 00 00 00 00 00 00
+00 00 00 00 c0 a8 03 7f
+ff ff ff ff 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 05 00 00 00 00
+00 00 00 00 00 00 00 02
+00 00 00 08 ff fb 00 00
+ff ff 00 10 00 00 23 20
+00 12 00 00 00 00 00 00
+ff ff 00 10 00 5c 16 c7
+00 00 00 02 00 00 00 00
+-- python
+ofp.message.flow_add(
+    xid=0x12345678,
+    match=ofp.match(
+        wildcards=ofp.OFPFW_DL_SRC|ofp.OFPFW_DL_DST,
+        in_port=3,
+        ipv4_src=0xc0a8037f,
+        ipv4_dst=0xffffffff,
+        eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
+        eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
+    idle_timeout=5,
+    flags=ofp.OFPFF_CHECK_OVERLAP,
+    actions=[
+        ofp.action.output(port=ofp.OFPP_FLOOD),
+        ofp.action.nicira_dec_ttl(),
+        ofp.action.bsn_set_tunnel_dst()])
+-- python pretty-printer
+flow_add {
+  xid = 0x12345678,
+  match = match_v1 {
+    wildcards = OFPFW_DL_SRC|OFPFW_DL_DST,
+    in_port = 3,
+    eth_src = 01:23:45:67:89:ab,
+    eth_dst = cd:ef:01:23:45:67,
+    vlan_vid = 0x0,
+    vlan_pcp = 0x0,
+    eth_type = 0x0,
+    ip_dscp = 0x0,
+    ip_proto = 0x0,
+    ipv4_src = 192.168.3.127,
+    ipv4_dst = 255.255.255.255,
+    tcp_src = 0x0,
+    tcp_dst = 0x0
+  },
+  cookie = 0x0,
+  idle_timeout = 0x5,
+  hard_timeout = 0x0,
+  priority = 0x0,
+  buffer_id = 0x0,
+  out_port = 0,
+  flags = 0x2,
+  actions = [
+    output { port = OFPP_FLOOD, max_len = 0x0 },
+    nicira_dec_ttl {  },
+    bsn_set_tunnel_dst { dst = 0x0 }
+  ]
+}
diff --git a/test_data/of10/flow_stats_entry.data b/test_data/of10/flow_stats_entry.data
new file mode 100644
index 0000000..45c6569
--- /dev/null
+++ b/test_data/of10/flow_stats_entry.data
@@ -0,0 +1,42 @@
+-- binary
+00 68 # length
+03 # table_id
+00 # pad
+00 3f ff ff # match.wildcards
+00 00 00 00 # remaining match fields
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 01 # duration_sec
+00 00 00 02 # duration_nsec
+00 64 # priority
+00 05 # idle_timeout
+00 0a # hard_timeout
+00 00 00 00 00 00 # pad
+01 23 45 67 89 ab cd ef # cookie
+00 00 00 00 00 00 00 0a # packet_count
+00 00 00 00 00 00 03 e8 # byte_count
+00 00 # actions[0].type
+00 08 # actions[0].len
+00 01 # actions[0].port
+00 00 # actions[0].max_len
+00 00 # actions[1].type
+00 08 # actions[1].len
+00 02 # actions[1].port
+00 00 # actions[1].max_len
+-- python
+ofp.flow_stats_entry(
+    table_id=3,
+    match=ofp.match(),
+    duration_sec=1,
+    duration_nsec=2,
+    priority=100,
+    idle_timeout=5,
+    hard_timeout=10,
+    cookie=0x0123456789abcdef,
+    packet_count=10,
+    byte_count=1000,
+    actions=[
+        ofp.action.output(port=1),
+        ofp.action.output(port=2)])
diff --git a/test_data/of10/flow_stats_reply.data b/test_data/of10/flow_stats_reply.data
new file mode 100644
index 0000000..38db4d5
--- /dev/null
+++ b/test_data/of10/flow_stats_reply.data
@@ -0,0 +1,92 @@
+-- binary
+01 11 # version/type
+00 e4 # length
+00 00 00 06 # xid
+00 01 # stats_type
+00 00 # flags
+00 68 # entries[0].length
+03 # entries[0].table_id
+00 # entries[0].pad
+00 3f ff ff # entries[0].match.wildcards
+00 00 00 00 # remaining match fields
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 01 # entries[0].duration_sec
+00 00 00 02 # entries[0].duration_nsec
+00 64 # entries[0].priority
+00 05 # entries[0].idle_timeout
+00 0a # entries[0].hard_timeout
+00 00 00 00 00 00 # pad
+01 23 45 67 89 ab cd ef # entries[0].cookie
+00 00 00 00 00 00 00 0a # entries[0].packet_count
+00 00 00 00 00 00 03 e8 # entries[0].byte_count
+00 00 # entries[0].actions[0].type
+00 08 # entries[0].actions[0].len
+00 01 # entries[0].actions[0].port
+00 00 # entries[0].actions[0].max_len
+00 00 # entries[0].actions[1].type
+00 08 # entries[0].actions[1].len
+00 02 # entries[0].actions[1].port
+00 00 # entries[0].actions[1].max_len
+00 70 # entries[1].length
+04 # entries[1].table_id
+00 # entries[1].pad
+00 3f ff ff # entries[1].match.wildcards
+00 00 00 00 # remaining match fields
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 00 00 00 00 00 # ...
+00 00 00 01 # entries[1].duration_sec
+00 00 00 02 # entries[1].duration_nsec
+00 64 # entries[1].priority
+00 05 # entries[1].idle_timeout
+00 0a # entries[1].hard_timeout
+00 00 00 00 00 00 # pad
+01 23 45 67 89 ab cd ef # entries[1].cookie
+00 00 00 00 00 00 00 0a # entries[1].packet_count
+00 00 00 00 00 00 03 e8 # entries[1].byte_count
+00 00 # entries[1].actions[0].type
+00 08 # entries[1].actions[0].len
+00 01 # entries[1].actions[0].port
+00 00 # entries[1].actions[0].max_len
+00 00 # entries[1].actions[1].type
+00 08 # entries[1].actions[1].len
+00 02 # entries[1].actions[1].port
+00 00 # entries[1].actions[1].max_len
+00 00 # entries[1].actions[2].type
+00 08 # entries[1].actions[2].len
+00 03 # entries[1].actions[2].port
+00 00 # entries[1].actions[2].max_len
+-- python
+ofp.message.flow_stats_reply(
+    xid=6,
+    flags=0,
+    entries=[
+        ofp.flow_stats_entry(table_id=3,
+            match=ofp.match(),
+            duration_sec=1,
+            duration_nsec=2,
+            priority=100,
+            idle_timeout=5,
+            hard_timeout=10,
+            cookie=0x0123456789abcdef,
+            packet_count=10,
+            byte_count=1000,
+            actions=[ofp.action.output(port=1),
+            ofp.action.output(port=2)]),
+        ofp.flow_stats_entry(table_id=4,
+            match=ofp.match(),
+            duration_sec=1,
+            duration_nsec=2,
+            priority=100,
+            idle_timeout=5,
+            hard_timeout=10,
+            cookie=0x0123456789abcdef,
+            packet_count=10,
+            byte_count=1000,
+            actions=[ofp.action.output(port=1),
+            ofp.action.output(port=2),
+            ofp.action.output(port=3)])])
diff --git a/test_data/of10/hello.data b/test_data/of10/hello.data
new file mode 100644
index 0000000..2603365
--- /dev/null
+++ b/test_data/of10/hello.data
@@ -0,0 +1,6 @@
+-- binary
+01 00 # version / type
+00 08 # length
+12 34 56 78 # xid
+-- python
+ofp.message.hello(xid=0x12345678)
diff --git a/test_data/of10/packet_in.data b/test_data/of10/packet_in.data
new file mode 100644
index 0000000..f8d026b
--- /dev/null
+++ b/test_data/of10/packet_in.data
@@ -0,0 +1,18 @@
+-- binary
+01 0a # version / type
+00 15 # length
+12 34 56 78 # xid
+ab cd ef 01 # buffer_id
+00 09 # total_len
+ff fe # in_port
+01 # reason
+00 # pad
+61 62 63 # data
+-- python
+ofp.message.packet_in(
+    xid=0x12345678,
+    buffer_id=0xabcdef01,
+    total_len=9,
+    in_port=ofp.OFPP_LOCAL,
+    reason=ofp.OFPR_ACTION,
+    data='abc')
diff --git a/test_data/of10/packet_out.data b/test_data/of10/packet_out.data
new file mode 100644
index 0000000..a3892f6
--- /dev/null
+++ b/test_data/of10/packet_out.data
@@ -0,0 +1,25 @@
+-- binary
+01 0d # version/type
+00 23 # length
+12 34 56 78 # xid
+ab cd ef 01 # buffer_id
+ff fe # in_port
+00 10 # actions_len
+00 00 # actions[0].type
+00 08 # actions[0].len
+00 01 # actions[0].port
+00 00 # actions[0].max_len
+00 00 # actions[1].type
+00 08 # actions[1].len
+00 02 # actions[1].port
+00 00 # actions[1].max_len
+61 62 63 # data
+-- python
+ofp.message.packet_out(
+    xid=0x12345678,
+    buffer_id=0xabcdef01,
+    in_port=ofp.OFPP_LOCAL,
+    actions=[
+        ofp.action.output(port=1),
+        ofp.action.output(port=2)],
+    data='abc')
diff --git a/test_data/of10/port_desc.data b/test_data/of10/port_desc.data
new file mode 100644
index 0000000..c3c2e38
--- /dev/null
+++ b/test_data/of10/port_desc.data
@@ -0,0 +1,21 @@
+-- binary
+ff fd # port_no
+01 02 03 04 05 06 # hw_addr
+66 6f 6f 00 00 00 00 00 00 00 00 00 00 00 00 00 # name
+00 00 00 10 # config
+00 00 02 00 # state
+00 00 00 01 # curr
+00 00 00 20 # advertised
+00 00 02 00 # supported
+00 00 08 00 # peer
+-- python
+ofp.port_desc(
+    port_no=ofp.OFPP_CONTROLLER,
+    hw_addr=[1,2,3,4,5,6],
+    name="foo",
+    config=ofp.OFPPC_NO_FLOOD,
+    state=ofp.OFPPS_STP_FORWARD,
+    curr=ofp.OFPPF_10MB_HD,
+    advertised=ofp.OFPPF_1GB_FD,
+    supported=ofp.OFPPF_AUTONEG,
+    peer=ofp.OFPPF_PAUSE_ASYM)
diff --git a/test_data/of10/port_mod.data b/test_data/of10/port_mod.data
new file mode 100644
index 0000000..972a4e8
--- /dev/null
+++ b/test_data/of10/port_mod.data
@@ -0,0 +1,18 @@
+-- binary
+01 0f # version/type
+00 20 # length
+00 00 00 02 # xid
+ff fd # port_no
+01 02 03 04 05 06 # hw_addr
+90 ab cd ef # config
+ff 11 ff 11 # mask
+ca fe 67 89 # advertise
+00 00 00 00 # pad
+-- python
+ofp.message.port_mod(
+    xid=2,
+    port_no=ofp.OFPP_CONTROLLER,
+    hw_addr=[1,2,3,4,5,6],
+    config=0x90ABCDEF,
+    mask=0xFF11FF11,
+    advertise=0xCAFE6789)
diff --git a/test_data/of10/port_stats_reply.data b/test_data/of10/port_stats_reply.data
new file mode 100644
index 0000000..45a3532
--- /dev/null
+++ b/test_data/of10/port_stats_reply.data
@@ -0,0 +1,39 @@
+-- binary
+01 11 # version/type
+00 dc # length
+00 00 00 05 # xid
+00 04 # stats_type
+00 00 # flags
+00 01 # entries[0].port_no
+00 00 00 00 00 00 # entries[0].pad
+00 00 00 00 00 00 00 38 # entries[0].rx_packets
+00 00 00 00 00 00 00 00 # entries[0].tx_packets
+00 00 00 00 00 00 00 00 # entries[0].rx_bytes
+00 00 00 00 00 00 00 00 # entries[0].tx_bytes
+00 00 00 00 00 00 00 00 # entries[0].rx_dropped
+00 00 00 00 00 00 00 00 # entries[0].tx_dropped
+00 00 00 00 00 00 00 00 # entries[0].rx_errors
+00 00 00 00 00 00 00 00 # entries[0].tx_errors
+00 00 00 00 00 00 00 00 # entries[0].rx_frame_err
+00 00 00 00 00 00 00 00 # entries[0].rx_over_err
+00 00 00 00 00 00 00 00 # entries[0].rx_crc_err
+00 00 00 00 00 00 00 05 # entries[0].collisions
+ff fe # entries[1].port_no
+00 00 00 00 00 00 # entries[1].pad
+00 00 00 00 00 00 00 01 # entries[1].rx_packets
+00 00 00 00 00 00 00 00 # entries[1].tx_packets
+00 00 00 00 00 00 00 00 # entries[1].rx_bytes
+00 00 00 00 00 00 00 00 # entries[1].tx_bytes
+00 00 00 00 00 00 00 00 # entries[1].rx_dropped
+00 00 00 00 00 00 00 00 # entries[1].tx_dropped
+00 00 00 00 00 00 00 00 # entries[1].rx_errors
+00 00 00 00 00 00 00 00 # entries[1].tx_errors
+00 00 00 00 00 00 00 00 # entries[1].rx_frame_err
+00 00 00 00 00 00 00 00 # entries[1].rx_over_err
+00 00 00 00 00 00 00 00 # entries[1].rx_crc_err
+00 00 00 00 00 00 00 01 # entries[1].collisions
+-- python
+ofp.message.port_stats_reply(
+    xid=5, flags=0, entries=[
+        ofp.port_stats_entry(port_no=1, rx_packets=56, collisions=5),
+        ofp.port_stats_entry(port_no=ofp.OFPP_LOCAL, rx_packets=1, collisions=1)])
diff --git a/test_data/of10/port_status.data b/test_data/of10/port_status.data
new file mode 100644
index 0000000..04da9fd
--- /dev/null
+++ b/test_data/of10/port_status.data
@@ -0,0 +1,30 @@
+-- binary
+01 0c # version / type
+00 40 # length
+00 00 00 04 # xid
+01 # reason
+00 00 00 00 00 00 00 # pad
+ff fd # desc.port_no
+01 02 03 04 05 06 # desc.hw_addr
+66 6f 6f 00 00 00 00 00 # desc.name
+00 00 00 00 00 00 00 00 # ...
+00 00 00 10 # desc.config
+00 00 02 00 # desc.state
+00 00 00 01 # desc.curr
+00 00 00 20 # desc.advertised
+00 00 02 00 # desc.supported
+00 00 08 00 # desc.peer
+-- python
+ofp.message.port_status(
+    xid=4,
+    reason=ofp.OFPPR_DELETE,
+    desc=ofp.port_desc(
+        port_no=ofp.OFPP_CONTROLLER,
+        hw_addr=[1,2,3,4,5,6],
+        name="foo",
+        config=ofp.OFPPC_NO_FLOOD,
+        state=ofp.OFPPS_STP_FORWARD,
+        curr=ofp.OFPPF_10MB_HD,
+        advertised=ofp.OFPPF_1GB_FD,
+        supported=ofp.OFPPF_AUTONEG,
+        peer=ofp.OFPPF_PAUSE_ASYM))
diff --git a/test_data/of10/queue_get_config_reply.data b/test_data/of10/queue_get_config_reply.data
new file mode 100644
index 0000000..5e3453d
--- /dev/null
+++ b/test_data/of10/queue_get_config_reply.data
@@ -0,0 +1,37 @@
+-- binary
+01 15 # version / type
+00 50 # length
+12 34 56 78 # xid
+ff fe # port
+00 00 00 00 00 00 # pad
+00 00 00 01 # queues[0].queue_id
+00 18 # queues[0].len
+00 00 # queues[0].pad
+00 01 # queues[0].properties[0].type
+00 10 # queues[0].properties[0].length
+00 00 00 00 # queues[0].properties[0].pad
+00 05 # queues[0].properties[0].rate
+00 00 00 00 00 00 # queues[0].properties[0].pad2
+00 00 00 02 # queues[1].queue_id
+00 28 # queues[1].len
+00 00 # queues[1].pad
+00 01 # queues[1].properties[0].type
+00 10 # queues[1].properties[0].length
+00 00 00 00 # queues[1].properties[0].pad
+00 06 # queues[1].properties[0].rate
+00 00 00 00 00 00 # queues[1].properties[0].pad2
+00 01 # queues[1].properties[1].type
+00 10 # queues[1].properties[1].length
+00 00 00 00 # queues[1].properties[1].pad
+00 07 # queues[1].properties[1].rate
+00 00 00 00 00 00 # queues[1].properties[1].pad2
+-- python
+ofp.message.queue_get_config_reply(
+    xid=0x12345678,
+    port=ofp.OFPP_LOCAL,
+    queues=[
+        ofp.packet_queue(queue_id=1, properties=[
+            ofp.queue_prop_min_rate(rate=5)]),
+        ofp.packet_queue(queue_id=2, properties=[
+            ofp.queue_prop_min_rate(rate=6),
+            ofp.queue_prop_min_rate(rate=7)])])
diff --git a/test_data/of10/table_stats_entry.data b/test_data/of10/table_stats_entry.data
new file mode 100644
index 0000000..1a99237
--- /dev/null
+++ b/test_data/of10/table_stats_entry.data
@@ -0,0 +1,21 @@
+-- binary
+03 # table_id
+00 00 00 # pad
+66 6f 6f 00 00 00 00 00 # name
+00 00 00 00 00 00 00 00 # name
+00 00 00 00 00 00 00 00 # name
+00 00 00 00 00 00 00 00 # name
+00 3f ff ff # wildcards
+00 00 00 05 # max_entries
+00 00 00 02 # active_count
+00 00 00 ff ff ff ff ff # lookup_count
+81 11 11 11 11 11 11 11 # matched_count
+-- python
+ofp.table_stats_entry(
+    table_id=3,
+    name="foo",
+    wildcards=ofp.OFPFW_ALL,
+    max_entries=5,
+    active_count=2,
+    lookup_count=1099511627775,
+    matched_count=9300233470495232273L)
diff --git a/test_data/of12/empty_match.data b/test_data/of12/empty_match.data
new file mode 100644
index 0000000..6e65a47
--- /dev/null
+++ b/test_data/of12/empty_match.data
@@ -0,0 +1,6 @@
+-- binary
+00 01 # type
+00 04 # length
+00 00 00 00 # padding
+-- python
+ofp.match()
diff --git a/test_data/of12/match.data b/test_data/of12/match.data
new file mode 100644
index 0000000..3b1e3c2
--- /dev/null
+++ b/test_data/of12/match.data
@@ -0,0 +1,25 @@
+-- binary
+00 01 # type
+00 3C # length
+80 00 # oxm_list[0].class
+20 02 # oxm_list[0].type_len
+00 35 # oxm_list[0].value
+80 00 # oxm_list[1].class
+05 10 # oxm_list[1].type_len
+FE DC BA 98 76 54 32 10 # oxm_list[1].value
+FF FF FF FF 12 34 56 78 # oxm_list[1].mask
+80 00 # oxm_list[2].class
+08 06 # oxm_list[2].type_len
+01 02 03 04 05 06 # oxm_list[2].value
+80 00 # oxm_list[3].class
+36 10 # oxm_list[3].type_len
+12 12 12 12 12 12 12 12 # oxm_list[3].value
+12 12 12 12 12 12 12 12 # ...
+00 00 00 00 # pad
+-- python
+ofp.match([
+    ofp.oxm.udp_dst(53),
+    ofp.oxm.metadata_masked(0xFEDCBA9876543210, 0xFFFFFFFF12345678),
+    ofp.oxm.eth_src([1,2,3,4,5,6]),
+    ofp.oxm.ipv6_dst("\x12" * 16),
+])
diff --git a/test_data/of12/oxm_in_phy_port.data b/test_data/of12/oxm_in_phy_port.data
new file mode 100644
index 0000000..32ac1ea
--- /dev/null
+++ b/test_data/of12/oxm_in_phy_port.data
@@ -0,0 +1,7 @@
+-- binary
+80 00 # class
+02 # type/masked
+04 # length
+00 00 00 2a # value
+-- python
+ofp.oxm.in_phy_port(value=42)
diff --git a/test_data/of12/oxm_in_phy_port_masked.data b/test_data/of12/oxm_in_phy_port_masked.data
new file mode 100644
index 0000000..99b0ad3
--- /dev/null
+++ b/test_data/of12/oxm_in_phy_port_masked.data
@@ -0,0 +1,8 @@
+-- binary
+80 00 # class
+03 # type/masked
+08 # length
+00 00 00 2a # value
+aa bb cc dd # mask
+-- python
+ofp.oxm.in_phy_port_masked(value=42, value_mask=0xaabbccdd)
diff --git a/test_data/of12/oxm_ipv6_dst.data b/test_data/of12/oxm_ipv6_dst.data
new file mode 100644
index 0000000..23c8fb5
--- /dev/null
+++ b/test_data/of12/oxm_ipv6_dst.data
@@ -0,0 +1,8 @@
+-- binary
+80 00 # class
+36 # type/masked
+10 # length
+00 01 02 03 04 05 06 07 # value
+08 09 0a 0b 0c 0d 0e 0f # ...
+-- python
+ofp.oxm.ipv6_dst('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
diff --git a/test_data/of13/TODO b/test_data/of13/TODO
new file mode 100644
index 0000000..a232b54
--- /dev/null
+++ b/test_data/of13/TODO
@@ -0,0 +1,52 @@
+# This list is not complete.
+
+flow_modify
+flow_modify_strict
+flow_delete
+flow_delete_strict
+
+port_mod
+table_mod
+
+desc_stats_request
+desc_stats_reply
+flow_stats_request
+flow_stats_reply
+aggregate_stats_request
+aggregate_stats_reply
+port_stats_request
+port_stats_reply
+queue_stats_request
+queue_stats_reply
+group_stats_request
+group_desc_stats_request
+group_features_stats_request
+group_features_stats_reply
+meter_stats_request
+meter_config_stats_request
+meter_features_stats_request
+table_features_stats_request
+table_features_stats_reply
+port_desc_stats_request
+port_desc_stats_reply
+
+barrier_request
+barrier_reply
+queue_get_config_request
+queue_get_config_reply
+role_request
+role_reply
+get_async_request
+get_async_reply
+set_async
+meter_mod
+
+# TODO test experimenter messages
+
+instruction_write_metadata
+instruction_write_actions
+instruction_apply_actions
+instruction_clear_actions
+instruction_meter
+
+# TODO test experimenter instructions
diff --git a/test_data/of13/echo_reply.data b/test_data/of13/echo_reply.data
new file mode 100644
index 0000000..4d9156d
--- /dev/null
+++ b/test_data/of13/echo_reply.data
@@ -0,0 +1,9 @@
+-- binary
+04 03 # version, type
+00 0b # length
+12 34 56 78 # xid
+61 62 63 # data
+-- python
+ofp.message.echo_reply(
+    xid=0x12345678,
+    data="abc")
diff --git a/test_data/of13/echo_request.data b/test_data/of13/echo_request.data
new file mode 100644
index 0000000..4cedbc7
--- /dev/null
+++ b/test_data/of13/echo_request.data
@@ -0,0 +1,9 @@
+-- binary
+04 02 # version, type
+00 0b # length
+12 34 56 78 # xid
+61 62 63 # data
+-- python
+ofp.message.echo_request(
+    xid=0x12345678,
+    data="abc")
diff --git a/test_data/of13/error.data b/test_data/of13/error.data
new file mode 100644
index 0000000..fcb0c1c
--- /dev/null
+++ b/test_data/of13/error.data
@@ -0,0 +1,13 @@
+-- binary
+04 01 # version / type
+00 0f # length
+12 34 56 78 # xid
+00 04 # err_type
+00 08 # code
+61 62 63 # data
+-- python
+ofp.message.error_msg(
+    xid=0x12345678,
+    err_type=ofp.OFPET_BAD_MATCH,
+    code=ofp.OFPBMC_BAD_MASK,
+    data="abc")
diff --git a/test_data/of13/features_reply.data b/test_data/of13/features_reply.data
new file mode 100644
index 0000000..6daf046
--- /dev/null
+++ b/test_data/of13/features_reply.data
@@ -0,0 +1,20 @@
+-- binary
+04 06 # version, type
+00 20 # length
+12 34 56 78 # xid
+fe dc ba 98 76 54 32 10 # datapath_id
+00 00 00 40 # n_buffers
+c8 # n_tables
+05 # auxiliary_id
+00 00 # pad
+00 00 01 01 # capabilities
+00 00 00 00 # reserved
+-- python
+ofp.message.features_reply(
+    xid=0x12345678,
+    datapath_id=0xFEDCBA9876543210,
+    n_buffers=64,
+    n_tables=200,
+    auxiliary_id=5,
+    capabilities=ofp.OFPC_FLOW_STATS|ofp.OFPC_PORT_BLOCKED,
+    reserved=0)
diff --git a/test_data/of13/features_request.data b/test_data/of13/features_request.data
new file mode 100644
index 0000000..2f85f16
--- /dev/null
+++ b/test_data/of13/features_request.data
@@ -0,0 +1,6 @@
+-- binary
+04 05 # version, type
+00 08 # length
+12 34 56 78 # xid
+-- python
+ofp.message.features_request(xid=0x12345678)
diff --git a/test_data/of13/flow_add.data b/test_data/of13/flow_add.data
new file mode 100644
index 0000000..c66518f
--- /dev/null
+++ b/test_data/of13/flow_add.data
@@ -0,0 +1,52 @@
+-- binary
+04 0e # version, type
+00 48 # length
+12 34 56 78 # xid
+
+fe dc ba 98 76 54 32 10 # cookie
+
+ff 00 ff 00 ff 00 ff 00 # cookie_mask
+
+03 # table_id
+00 # _command
+00 05 # idle_timeout
+00 0a # hard_timeout
+17 70 # priority
+
+00 00 00 32 # buffer_id
+00 00 00 06 # out_port
+
+00 00 00 08 # out_group
+00 00 # flags
+00 00 # pad
+
+00 01 # match.type
+00 04 # match.length
+00 00 00 00 # pad
+
+00 01 # instructions[0].type
+00 08 # instructions[0].length
+04 # instructions[0].table_id
+00 00 00 # pad
+
+00 01 # instructions[1].type
+00 08 # instructions[1].length
+07 # instructions[1].table_id
+00 00 00 # pad
+-- python
+ofp.message.flow_add(
+    xid=0x12345678,
+    cookie=0xFEDCBA9876543210,
+    cookie_mask=0xFF00FF00FF00FF00,
+    table_id=3,
+    idle_timeout=5,
+    hard_timeout=10,
+    priority=6000,
+    buffer_id=50,
+    out_port=6,
+    out_group=8,
+    flags=0,
+    match=ofp.match(oxm_list=[]),
+    instructions=[
+        ofp.instruction.goto_table(table_id=4),
+        ofp.instruction.goto_table(table_id=7)])
diff --git a/test_data/of13/flow_removed.data b/test_data/of13/flow_removed.data
new file mode 100644
index 0000000..0a24993
--- /dev/null
+++ b/test_data/of13/flow_removed.data
@@ -0,0 +1,38 @@
+-- binary
+04 0b # version, type
+00 48 # length
+12 34 56 78 # xid
+fe dc ba 98 76 54 32 10 # cookie
+42 68 # priority
+02 # reason
+14 # table_id
+00 00 00 0a # duration_sec
+00 00 03 e8 # duration_nsec
+00 05 # idle_timeout
+00 1e # hard_timeout
+00 00 00 00 00 00 00 01 # packet_count
+00 00 00 00 00 00 00 02 # byte_count
+00 01 # match.type
+00 16 # match.length
+80 00 2A 02 # match.oxm_list[0].type_len
+00 01 # match.oxm_list[0].value
+80 00 01 08 # match.oxm_list[1].type_len
+00 00 00 04 # match.oxm_list[1].value
+00 00 00 05 # match.oxm_list[1].mask
+00 00 # match.pad
+-- python
+ofp.message.flow_removed(
+    xid=0x12345678,
+    cookie=0xFEDCBA9876543210,
+    priority=17000,
+    reason=ofp.OFPRR_DELETE,
+    table_id=20,
+    duration_sec=10,
+    duration_nsec=1000,
+    idle_timeout=5,
+    hard_timeout=30,
+    packet_count=1,
+    byte_count=2,
+    match=ofp.match(oxm_list=[
+        ofp.oxm.arp_op(value=1),
+        ofp.oxm.in_port_masked(value=4, value_mask=5)]))
diff --git a/test_data/of13/get_config_reply.data b/test_data/of13/get_config_reply.data
new file mode 100644
index 0000000..111ac61
--- /dev/null
+++ b/test_data/of13/get_config_reply.data
@@ -0,0 +1,11 @@
+-- binary
+04 08 # version, type
+00 0c # length
+12 34 56 78 # xid
+00 02 # flags
+ff ff # miss_send_len
+-- python
+ofp.message.get_config_reply(
+    xid=0x12345678,
+    flags=ofp.OFPC_FRAG_REASM,
+    miss_send_len=0xffff)
diff --git a/test_data/of13/get_config_request.data b/test_data/of13/get_config_request.data
new file mode 100644
index 0000000..8361a6b
--- /dev/null
+++ b/test_data/of13/get_config_request.data
@@ -0,0 +1,6 @@
+-- binary
+04 07 # version, type
+00 08 # length
+12 34 56 78 # xid
+-- python
+ofp.message.get_config_request(xid=0x12345678)
diff --git a/test_data/of13/group_desc_stats_reply.data b/test_data/of13/group_desc_stats_reply.data
new file mode 100644
index 0000000..34c0d50
--- /dev/null
+++ b/test_data/of13/group_desc_stats_reply.data
@@ -0,0 +1,69 @@
+-- binary
+04 13 # version, type
+00 80 # length
+12 34 56 78 # xid
+00 07 # stats_type
+00 00 # flags
+00 00 00 00 # pad
+00 68 # entries[0].length
+03 # entries[0].group_type
+00 # entries[0].pad
+00 00 00 01 # entries[0].group_id
+00 30 # entries[0].buckets[0].len
+00 01 # entries[0].buckets[0].weight
+00 00 00 05 # entries[0].buckets[0].watch_port
+ff ff ff ff # entries[0].buckets[0].watch_group
+00 00 00 00 # entries[0].pad
+00 00 # entries[0].buckets[0].actions[0].type
+00 10 # entries[0].buckets[0].actions[0].len
+00 00 00 05 # entries[0].buckets[0].actions[0].port
+00 00 # entries[0].buckets[0].actions[0].max_len
+00 00 00 00 00 00 # entries[0].pad
+00 00 # entries[0].buckets[0].actions[1].type
+00 10 # entries[0].buckets[0].actions[1].len
+00 00 00 06 # entries[0].buckets[0].actions[1].port
+00 00 # entries[0].buckets[0].actions[1].max_len
+00 00 00 00 00 00 # entries[0].pad
+00 30 # entries[0].buckets[1].len
+00 01 # entries[0].buckets[1].weight
+00 00 00 06 # entries[0].buckets[1].watch_port
+ff ff ff ff # entries[0].buckets[1].watch_group
+00 00 00 00 # entries[0].pad
+00 00 # entries[0].buckets[1].actions[0].type
+00 10 # entries[0].buckets[1].actions[0].len
+00 00 00 05 # entries[0].buckets[1].actions[0].port
+00 00 # entries[0].buckets[1].actions[0].max_len
+00 00 00 00 00 00 # entries[0].pad
+00 00 # entries[0].buckets[1].actions[1].type
+00 10 # entries[0].buckets[1].actions[1].len
+00 00 00 06 # entries[0].buckets[1].actions[1].port
+00 00 # entries[0].buckets[1].actions[1].max_len
+00 00 00 00 00 00 # entries[0].pad
+00 08 # entries[1].length
+03 # entries[1].group_type
+00 # entries[1].pad
+00 00 00 02 # entries[1].group_id
+-- python
+ofp.message.group_desc_stats_reply(
+    xid=0x12345678,
+    flags=0,
+    entries=[
+        ofp.group_desc_stats_entry(
+            type=ofp.OFPGT_FF,
+            group_id=1,
+            buckets=[
+                ofp.bucket(
+                    weight=1,
+                    watch_port=5,
+                    watch_group=0xffffffff,
+                    actions=[
+                        ofp.action.output(port=5, max_len=0),
+                        ofp.action.output(port=6, max_len=0)]),
+                ofp.bucket(
+                    weight=1,
+                    watch_port=6,
+                    watch_group=0xffffffff,
+                    actions=[
+                        ofp.action.output(port=5, max_len=0),
+                        ofp.action.output(port=6, max_len=0)])]),
+        ofp.group_desc_stats_entry(type=ofp.OFPGT_FF, group_id=2, buckets=[])])
diff --git a/test_data/of13/group_mod.data b/test_data/of13/group_mod.data
new file mode 100644
index 0000000..8f25b57
--- /dev/null
+++ b/test_data/of13/group_mod.data
@@ -0,0 +1,59 @@
+-- binary
+04 0f # version, type
+00 70 # length
+12 34 56 78 # xid
+00 01 # command
+03 # group_type
+00 # pad
+00 00 00 05 # group_id
+00 30 # buckets[0].len
+00 01 # buckets[0].weight
+00 00 00 05 # buckets[0].watch_port
+ff ff ff ff # buckets[0].watch_group
+00 00 00 00 # pad
+00 00 # buckets[0].actions[0].type
+00 10 # buckets[0].actions[0].len
+00 00 00 05 # buckets[0].actions[0].port
+00 00 # buckets[0].actions[0].max_len
+00 00 00 00 00 00 # pad
+00 00 # buckets[0].actions[1].type
+00 10 # buckets[0].actions[1].len
+00 00 00 06 # buckets[0].actions[1].port
+00 00 # buckets[0].actions[1].max_len
+00 00 00 00 00 00 # pad
+00 30 # buckets[1].len
+00 01 # buckets[1].weight
+00 00 00 06 # buckets[1].watch_port
+ff ff ff ff # buckets[1].watch_group
+00 00 00 00 # pad
+00 00 # buckets[1].actions[0].type
+00 10 # buckets[1].actions[0].len
+00 00 00 05 # buckets[1].actions[0].port
+00 00 # buckets[1].actions[0].max_len
+00 00 00 00 00 00 # pad
+00 00 # buckets[1].actions[1].type
+00 10 # buckets[1].actions[1].len
+00 00 00 06 # buckets[1].actions[1].port
+00 00 # buckets[1].actions[1].max_len
+00 00 00 00 00 00 # pad
+-- python
+ofp.message.group_mod(
+    xid=0x12345678,
+    command=ofp.OFPGC_MODIFY,
+    group_type=ofp.OFPGT_FF,
+    group_id=5,
+    buckets=[
+        ofp.bucket(
+            weight=1,
+            watch_port=5,
+            watch_group=0xffffffff,
+            actions=[
+                ofp.action.output(port=5, max_len=0),
+                ofp.action.output(port=6, max_len=0)]),
+        ofp.bucket(
+            weight=1,
+            watch_port=6,
+            watch_group=0xffffffff,
+            actions=[
+                ofp.action.output(port=5, max_len=0),
+                ofp.action.output(port=6, max_len=0)])])
diff --git a/test_data/of13/group_stats_reply.data b/test_data/of13/group_stats_reply.data
new file mode 100644
index 0000000..b14eb74
--- /dev/null
+++ b/test_data/of13/group_stats_reply.data
@@ -0,0 +1,52 @@
+-- binary
+04 13 # version, type
+00 80 # length
+12 34 56 78 # xid
+00 06 # stats_type
+00 00 # flags
+00 00 00 00 # pad
+00 48 # entries[0].length
+00 00 # pad
+00 00 00 01 # entries[0].group_id
+00 00 00 08 # entries[0].ref_count
+00 00 00 00 # pad
+00 00 00 00 00 00 00 10 # entries[0].packet_count
+00 00 00 00 00 00 00 20 # entries[0].byte_count
+00 00 00 14 # entries[0].duration_sec
+00 00 00 64 # entries[0].duration_nsec
+00 00 00 00 00 00 00 01 # entries[0].bucket_stats[0].packet_count
+00 00 00 00 00 00 00 02 # entries[0].bucket_stats[0].byte_count
+00 00 00 00 00 00 00 03 # entries[0].bucket_stats[1].packet_count
+00 00 00 00 00 00 00 04 # entries[0].bucket_stats[1].byte_count
+00 28 # entries[0].length
+00 00 # pad
+00 00 00 01 # entries[0].group_id
+00 00 00 08 # entries[0].ref_count
+00 00 00 00 # pad
+00 00 00 00 00 00 00 10 # entries[0].packet_count
+00 00 00 00 00 00 00 20 # entries[0].byte_count
+00 00 00 14 # entries[0].duration_sec
+00 00 00 64 # entries[0].duration_nsec
+-- python
+ofp.message.group_stats_reply(
+    xid=0x12345678,
+    flags=0,
+    entries=[
+        ofp.group_stats_entry(
+            group_id=1,
+            ref_count=8,
+            packet_count=16,
+            byte_count=32,
+            duration_sec=20,
+            duration_nsec=100,
+            bucket_stats=[
+                ofp.bucket_counter(packet_count=1, byte_count=2),
+                ofp.bucket_counter(packet_count=3, byte_count=4)]),
+        ofp.group_stats_entry(
+            group_id=1,
+            ref_count=8,
+            packet_count=16,
+            byte_count=32,
+            duration_sec=20,
+            duration_nsec=100,
+            bucket_stats=[])])
diff --git a/test_data/of13/hello.data b/test_data/of13/hello.data
new file mode 100644
index 0000000..94be823
--- /dev/null
+++ b/test_data/of13/hello.data
@@ -0,0 +1,20 @@
+-- binary
+04 00 # version, type
+00 20 # length
+12 34 56 78 # xid
+00 01 # elements[0].type
+00 0c # elements[0].length
+00 00 00 01 # elements[0].bitmaps[0]
+00 00 00 02 # elements[0].bitmaps[1]
+00 01 # elements[1].type
+00 0c # elements[1].length
+00 00 00 03 # elements[1].bitmaps[0]
+00 00 00 04 # elements[1].bitmaps[1]
+-- python
+ofp.message.hello(
+    xid=0x12345678,
+    elements=[
+        ofp.hello_elem_versionbitmap(
+            bitmaps=[ofp.uint32(1), ofp.uint32(2)]),
+        ofp.hello_elem_versionbitmap(
+            bitmaps=[ofp.uint32(3), ofp.uint32(4)])])
diff --git a/test_data/of13/hello_elem_versionbitmap.data b/test_data/of13/hello_elem_versionbitmap.data
new file mode 100644
index 0000000..230f7db
--- /dev/null
+++ b/test_data/of13/hello_elem_versionbitmap.data
@@ -0,0 +1,10 @@
+-- binary
+00 01 # type
+00 0c # length
+01 23 45 67 # bitmaps[0]
+89 ab cd ef # bitmaps[1]
+-- python
+ofp.hello_elem_versionbitmap(
+    bitmaps=[
+        ofp.uint32(0x01234567),
+        ofp.uint32(0x89abcdef)])
diff --git a/test_data/of13/instruction_goto_table.data b/test_data/of13/instruction_goto_table.data
new file mode 100644
index 0000000..6d0e32d
--- /dev/null
+++ b/test_data/of13/instruction_goto_table.data
@@ -0,0 +1,7 @@
+-- binary
+00 01 # type
+00 08 # length
+05 # table_id
+00 00 00 # pad
+-- python
+ofp.instruction.goto_table(table_id=5)
diff --git a/test_data/of13/meter_config_stats_reply.data b/test_data/of13/meter_config_stats_reply.data
new file mode 100644
index 0000000..940e4f5
--- /dev/null
+++ b/test_data/of13/meter_config_stats_reply.data
@@ -0,0 +1,25 @@
+-- binary
+04 13 # version, type
+00 30 # length
+12 34 56 78 # xid
+00 0a # stats_type
+00 00 # flags
+00 00 00 00 # pad
+00 01 # entries[0].type
+00 10 # entries[0].length
+00 00 00 01 # entries[0].rate
+00 00 00 02 # entries[0].burst_size
+00 00 00 00 # pad
+00 02 # entries[1].type
+00 10 # entries[1].length
+00 00 00 03 # entries[1].rate
+00 00 00 04 # entries[1].burst_size
+05 # entries[1].prec_level
+00 00 00 # pad
+-- python
+ofp.message.meter_config_stats_reply(
+    xid=0x12345678,
+    flags=0,
+    entries=[
+        ofp.meter_band.drop(rate=1, burst_size=2),
+        ofp.meter_band.dscp_remark(rate=3, burst_size=4, prec_level=5)])
diff --git a/test_data/of13/meter_feature_stats_reply.data b/test_data/of13/meter_feature_stats_reply.data
new file mode 100644
index 0000000..4a1b9bf
--- /dev/null
+++ b/test_data/of13/meter_feature_stats_reply.data
@@ -0,0 +1,23 @@
+-- binary
+04 13 # version, type
+00 20 # length
+12 34 56 78 # xid
+00 0b # stats_type
+00 00 # flags
+00 00 00 00 # pad
+00 00 00 05 # max_meter
+00 00 00 03 # band_types
+00 00 00 09 # capabilities
+0a # max_bands
+07 # max_color
+00 00 # pad
+-- python
+ofp.message.meter_features_stats_reply(
+    xid=0x12345678,
+    flags=0,
+    features=ofp.meter_features(
+        max_meter=5,
+        band_types=ofp.OFPMBT_DROP|ofp.OFPMBT_DSCP_REMARK,
+        capabilities=ofp.OFPMF_KBPS|ofp.OFPMF_STATS,
+        max_bands=10,
+        max_color=7))
diff --git a/test_data/of13/meter_stats_reply.data b/test_data/of13/meter_stats_reply.data
new file mode 100644
index 0000000..04f1fe8
--- /dev/null
+++ b/test_data/of13/meter_stats_reply.data
@@ -0,0 +1,50 @@
+-- binary
+04 13 # version, type
+00 80 # length
+12 34 56 78 # xid
+00 09 # stats_type
+00 00 # flags
+00 00 00 00 # pad
+00 00 00 01 # entries[0].meter_id
+00 48 # entries[0].len
+00 00 00 00 00 00 # pad
+00 00 00 08 # entries[0].flow_count
+00 00 00 00 00 00 00 10 # entries[0].packet_in_count
+00 00 00 00 00 00 00 20 # entries[0].byte_in_count
+00 00 00 14 # entries[0].duration_sec
+00 00 00 64 # entries[0].duration_nsec
+00 00 00 00 00 00 00 01 # entries[0].band_stats[0].packet_band_count
+00 00 00 00 00 00 00 02 # entries[0].band_stats[0].byte_band_count
+00 00 00 00 00 00 00 03 # entries[0].band_stats[1].packet_band_count
+00 00 00 00 00 00 00 04 # entries[0].band_stats[1].byte_band_count
+00 00 00 02 # entries[1].meter_id
+00 28 # entries[1].len
+00 00 00 00 00 00 # pad
+00 00 00 08 # entries[1].flow_count
+00 00 00 00 00 00 00 10 # entries[1].packet_in_count
+00 00 00 00 00 00 00 20 # entries[1].byte_in_count
+00 00 00 14 # entries[1].duration_sec
+00 00 00 64 # entries[1].duration_nsec
+-- python
+ofp.message.meter_stats_reply(
+    xid=0x12345678,
+    flags=0,
+    entries=[
+        ofp.meter_stats(
+            meter_id=1,
+            flow_count=8,
+            packet_in_count=16,
+            byte_in_count=32,
+            duration_sec=20,
+            duration_nsec=100,
+            band_stats=[
+                ofp.meter_band_stats(packet_band_count=1, byte_band_count=2),
+                ofp.meter_band_stats(packet_band_count=3, byte_band_count=4)]),
+        ofp.meter_stats(
+            meter_id=2,
+            flow_count=8,
+            packet_in_count=16,
+            byte_in_count=32,
+            duration_sec=20,
+            duration_nsec=100,
+            band_stats=[])])
diff --git a/test_data/of13/oxm_in_phy_port.data b/test_data/of13/oxm_in_phy_port.data
new file mode 100644
index 0000000..32ac1ea
--- /dev/null
+++ b/test_data/of13/oxm_in_phy_port.data
@@ -0,0 +1,7 @@
+-- binary
+80 00 # class
+02 # type/masked
+04 # length
+00 00 00 2a # value
+-- python
+ofp.oxm.in_phy_port(value=42)
diff --git a/test_data/of13/oxm_in_phy_port_masked.data b/test_data/of13/oxm_in_phy_port_masked.data
new file mode 100644
index 0000000..99b0ad3
--- /dev/null
+++ b/test_data/of13/oxm_in_phy_port_masked.data
@@ -0,0 +1,8 @@
+-- binary
+80 00 # class
+03 # type/masked
+08 # length
+00 00 00 2a # value
+aa bb cc dd # mask
+-- python
+ofp.oxm.in_phy_port_masked(value=42, value_mask=0xaabbccdd)
diff --git a/test_data/of13/oxm_ipv6_dst.data b/test_data/of13/oxm_ipv6_dst.data
new file mode 100644
index 0000000..23c8fb5
--- /dev/null
+++ b/test_data/of13/oxm_ipv6_dst.data
@@ -0,0 +1,8 @@
+-- binary
+80 00 # class
+36 # type/masked
+10 # length
+00 01 02 03 04 05 06 07 # value
+08 09 0a 0b 0c 0d 0e 0f # ...
+-- python
+ofp.oxm.ipv6_dst('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
diff --git a/test_data/of13/packet_in.data b/test_data/of13/packet_in.data
new file mode 100644
index 0000000..e7d602a
--- /dev/null
+++ b/test_data/of13/packet_in.data
@@ -0,0 +1,31 @@
+-- binary
+04 0a # version, type
+00 35 # length
+12 34 56 78 # xid
+00 00 00 64 # buffer_id
+42 68 # total_len
+01 # reason
+14 # table_id
+fe dc ba 98 76 54 32 10 # cookie
+00 01 # match.type
+00 16 # match.length
+80 00 2A 02 # match.oxm_list[0].type_len
+00 01 # match.oxm_list[0].value
+80 00 01 08 # match.oxm_list[1].type_len
+00 00 00 04 # match.oxm_list[1].value
+00 00 00 05 # match.oxm_list[1].mask
+00 00 # match.pad
+00 00 # pad
+61 62 63 # data
+-- python
+ofp.message.packet_in(
+    xid=0x12345678,
+    buffer_id=100,
+    total_len=17000,
+    reason=ofp.OFPR_ACTION,
+    table_id=20,
+    cookie=0xFEDCBA9876543210,
+    match=ofp.match(oxm_list=[
+        ofp.oxm.arp_op(value=1),
+        ofp.oxm.in_port_masked(value=4, value_mask=5)]),
+    data="abc")
diff --git a/test_data/of13/packet_out.data b/test_data/of13/packet_out.data
new file mode 100644
index 0000000..ae8fa64
--- /dev/null
+++ b/test_data/of13/packet_out.data
@@ -0,0 +1,26 @@
+-- binary
+04 0d # version, type
+00 33 # length
+12 34 56 78 # xid
+00 00 00 64 # buffer_id
+00 00 00 04 # in_port
+00 18 # actions_len
+00 00 00 00 00 00 # pad
+00 00 # actions[0].type
+00 10 # actions[0].length
+00 00 00 02 # actions[0].port
+ff ff # actions[0].max_len
+00 00 00 00 00 00 # pad
+00 18 # actions[1].type
+00 08 # actions[1].length
+00 00 00 00 # pad
+61 62 63 # data
+-- python
+ofp.message.packet_out(
+    xid=0x12345678,
+    buffer_id=100,
+    in_port=4,
+    actions=[
+        ofp.action.output(port=2, max_len=0xffff),
+        ofp.action.dec_nw_ttl()],
+    data="abc")
diff --git a/test_data/of13/port_status.data b/test_data/of13/port_status.data
new file mode 100644
index 0000000..10f7c16
--- /dev/null
+++ b/test_data/of13/port_status.data
@@ -0,0 +1,36 @@
+-- binary
+04 0c # version, type
+00 50 # length
+12 34 56 78 # xid
+02 # reason
+00 00 00 00 00 00 00 # pad
+00 00 00 04 # port_no
+00 00 00 00 # pad
+01 02 03 04 05 06 # hw_addr
+00 00 # pad
+66 6f 6f 00 00 00 00 00 # name
+00 00 00 00 00 00 00 00 # ...
+00 00 00 24 # config
+00 00 00 02 # state
+00 00 00 01 # curr
+00 00 00 02 # advertised
+00 00 00 04 # supported
+00 00 00 08 # peer
+00 00 00 0a # curr_speed
+00 00 00 14 # max_speed
+-- python
+ofp.message.port_status(
+    xid=0x12345678,
+    reason=ofp.OFPPR_MODIFY,
+    desc=ofp.port_desc(
+        port_no=4,
+        hw_addr=[1,2,3,4,5,6],
+        name="foo",
+        config=ofp.OFPPC_NO_FWD|ofp.OFPPC_NO_RECV,
+        state=ofp.OFPPS_BLOCKED,
+        curr=ofp.OFPPF_10MB_HD,
+        advertised=ofp.OFPPF_10MB_FD,
+        supported=ofp.OFPPF_100MB_HD,
+        peer=ofp.OFPPF_100MB_FD,
+        curr_speed=10,
+        max_speed=20))
diff --git a/test_data/of13/set_config.data b/test_data/of13/set_config.data
new file mode 100644
index 0000000..49c5be0
--- /dev/null
+++ b/test_data/of13/set_config.data
@@ -0,0 +1,11 @@
+-- binary
+04 09 # version, type
+00 0c # length
+12 34 56 78 # xid
+00 02 # flags
+ff ff # miss_send_len
+-- python
+ofp.message.set_config(
+    xid=0x12345678,
+    flags=ofp.OFPC_FRAG_REASM,
+    miss_send_len=0xffff)
diff --git a/utest/test_test_data.py b/utest/test_test_data.py
new file mode 100755
index 0000000..16cf440
--- /dev/null
+++ b/utest/test_test_data.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# Copyright 2013, Big Switch Networks, Inc.
+#
+# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+# the following special exception:
+#
+# LOXI Exception
+#
+# As a special exception to the terms of the EPL, you may distribute libraries
+# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+# that copyright and licensing notices generated by LoxiGen are not altered or removed
+# from the LoxiGen Libraries and the notice provided below is (i) included in
+# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+# documentation for the LoxiGen Libraries, if distributed in binary form.
+#
+# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+#
+# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+# a copy of the EPL at:
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# EPL for the specific language governing permissions and limitations
+# under the EPL.
+
+import unittest
+import test_data
+
+class DataFileTests(unittest.TestCase):
+    def test_example(self):
+        self.assertTrue('./example.data' in test_data.list_files())
+        data = test_data.read('example.data')
+        self.assertEquals(sorted(['section1', 'section2', 'binary']), sorted(data.keys()))
+        self.assertEquals(' abc def\nghi', data['section1'])
+        self.assertEquals('123\n456\n789', data['section2'])
+        self.assertEquals('\x00\x01\x02\x03\x04\x05\x06\x07\x77\x66\x55\x44\x33\x22\x11\x00',
+                          data['binary'])
+
+    # Just make sure all included data files parse without exceptions
+    def test_all(self):
+        for name in test_data.list_files():
+            test_data.read(name)
+
+if __name__ == '__main__':
+    unittest.main()