locitest: generate tests from the test_data files
The "c" section of the test data file should allocate and populate a LOCI
object. The resulting wire buffer is compared to the "binary" section.
This only tests serialization, but given that we have autogenerated tests that
round-trip each object I think this is sufficient.
I added C sections to the OF 1.0 test data files. OF 1.3 tests will come in a
future pull request.
diff --git a/test_data/of10/flow_add.data b/test_data/of10/flow_add.data
index 9801a36..fc09a23 100644
--- a/test_data/of10/flow_add.data
+++ b/test_data/of10/flow_add.data
@@ -1,6 +1,6 @@
-- binary
01 0e 00 70 12 34 56 78
-00 00 00 0c 00 03 01 23
+00 10 00 02 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
@@ -17,7 +17,7 @@
ofp.message.flow_add(
xid=0x12345678,
match=ofp.match(
- wildcards=ofp.OFPFW_DL_SRC|ofp.OFPFW_DL_DST,
+ wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_DL_VLAN_PCP,
in_port=3,
ipv4_src=0xc0a8037f,
ipv4_dst=0xffffffff,
@@ -33,7 +33,7 @@
flow_add {
xid = 0x12345678,
match = match_v1 {
- wildcards = OFPFW_DL_SRC|OFPFW_DL_DST,
+ wildcards = OFPFW_DL_VLAN|OFPFW_DL_VLAN_PCP,
in_port = 3,
eth_src = 01:23:45:67:89:ab,
eth_dst = cd:ef:01:23:45:67,
@@ -60,3 +60,49 @@
bsn_set_tunnel_dst { dst = 0x0 }
]
}
+-- c
+obj = of_flow_add_new(OF_VERSION_1_0);
+of_flow_add_xid_set(obj, 0x12345678);
+of_flow_add_idle_timeout_set(obj, 5);
+of_flow_add_flags_set(obj, 2);
+{
+ of_match_t match = { OF_VERSION_1_0 };
+ match.fields.in_port = 3;
+ match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
+ match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
+ match.fields.ipv4_src = 0xc0a8037f;
+ match.fields.ipv4_dst = 0xffffffff;
+ OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+ OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
+ OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
+ OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
+ of_flow_add_match_set(obj, &match);
+}
+{
+ of_list_action_t actions;
+ of_flow_add_actions_bind(obj, &actions);
+ {
+ of_action_t action;
+ of_action_output_init(&action.output, OF_VERSION_1_0, -1, 1);
+ of_list_action_append_bind(&actions, &action);
+ of_action_output_port_set(&action.output, OF_PORT_DEST_FLOOD);
+ }
+ {
+ of_action_t action;
+ of_action_nicira_dec_ttl_init(&action.nicira_dec_ttl, OF_VERSION_1_0, -1, 1);
+ of_list_action_append_bind(&actions, &action);
+ }
+ {
+ of_action_t action;
+ of_action_bsn_set_tunnel_dst_init(&action.bsn_set_tunnel_dst, OF_VERSION_1_0, -1, 1);
+ of_list_action_append_bind(&actions, &action);
+ }
+}