summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2016-01-27 20:50:59 -0800
committerBen Pfaff <blp@ovn.org>2016-03-11 20:56:26 -0800
commitf1c16a8585df9f7eacb20fc8f0ab8edd26f3b9dc (patch)
treeea12f0490c81315c960d6305c9a1a1274a556afb /tests
parent6335d074ed721ccb714abbf73f88cf7d2fa3108d (diff)
downloadopenvswitch-f1c16a8585df9f7eacb20fc8f0ab8edd26f3b9dc.tar.gz
ovn: Use callback function instead of simap for logical port number map.
An simap is convenient but it isn't very flexible. If the client wants to keep extra data with each node then it has to build a second parallel data structure. A callback function is kind of a pain for the clients from the point of view of having to write it and deal with auxiliary data, etc., but it allows the storage to be more flexible. An upcoming commit will make further use of this capability. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ovn.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/test-ovn.c b/tests/test-ovn.c
index ae2787c38..494297534 100644
--- a/tests/test-ovn.c
+++ b/tests/test-ovn.c
@@ -238,6 +238,18 @@ create_symtab(struct shash *symtab)
expr_symtab_add_string(symtab, "big_string", MFF_XREG0, NULL);
}
+static bool
+lookup_port_cb(const void *ports_, const char *port_name, unsigned int *portp)
+{
+ const struct simap *ports = ports_;
+ const struct simap_node *node = simap_find(ports, port_name);
+ if (!node) {
+ return false;
+ }
+ *portp = node->data;
+ return true;
+}
+
static void
test_parse_expr__(int steps)
{
@@ -274,7 +286,7 @@ test_parse_expr__(int steps)
if (steps > 3) {
struct hmap matches;
- expr_to_matches(expr, &ports, &matches);
+ expr_to_matches(expr, lookup_port_cb, &ports, &matches);
expr_matches_print(&matches, stdout);
expr_matches_destroy(&matches);
} else {
@@ -934,7 +946,7 @@ test_tree_shape_exhaustively(struct expr *expr, struct shash *symtab,
struct expr_match *m;
struct test_rule *test_rule;
- expr_to_matches(modified, &string_map, &matches);
+ expr_to_matches(modified, lookup_port_cb, &string_map, &matches);
classifier_init(&cls, NULL);
HMAP_FOR_EACH (m, hmap_node, &matches) {
@@ -1229,7 +1241,8 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
struct action_params ap = {
.symtab = &symtab,
- .ports = &ports,
+ .lookup_port = lookup_port_cb,
+ .aux = &ports,
.ct_zones = &ct_zones,
.n_tables = 16,