summaryrefslogtreecommitdiff
path: root/tests/test-ovsdb.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-06-01 16:17:00 -0700
committerBen Pfaff <blp@nicira.com>2011-06-06 08:58:02 -0700
commit29d7226e8b17ce1891aaba8f3009715b24fa664f (patch)
tree444f2e997c8a87f4da51f1d53ab37ff88a96ed12 /tests/test-ovsdb.c
parent1cb29ab050c601448a89eb7311a9f07095921bbd (diff)
downloadopenvswitch-29d7226e8b17ce1891aaba8f3009715b24fa664f.tar.gz
ovsdb: Move ovsdb_table_put_row() into test program.
This function is not useful inside ovsdb itself but only in the "test-ovsdb" test program. To avoid the temptation to use it incorrectly inside ovsdb, this commit moves it into the test program.
Diffstat (limited to 'tests/test-ovsdb.c')
-rw-r--r--tests/test-ovsdb.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 5b8f4519c..5594b40f0 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -975,6 +975,16 @@ do_execute_mutations(int argc OVS_UNUSED, char *argv[])
ovsdb_table_destroy(table); /* Also destroys 'ts'. */
}
+/* Inserts a row, without bothering to update metadata such as refcounts. */
+static void
+put_row(struct ovsdb_table *table, struct ovsdb_row *row)
+{
+ const struct uuid *uuid = ovsdb_row_get_uuid(row);
+ if (!ovsdb_table_get_row(table, uuid)) {
+ hmap_insert(&table->rows, &row->hmap_node, uuid_hash(uuid));
+ }
+}
+
struct do_query_cbdata {
struct uuid *row_uuids;
int *counts;
@@ -1031,7 +1041,7 @@ do_query(int argc OVS_UNUSED, char *argv[])
UUID_ARGS(ovsdb_row_get_uuid(row)));
}
cbdata.row_uuids[i] = *ovsdb_row_get_uuid(row);
- ovsdb_table_put_row(table, row);
+ put_row(table, row);
}
json_destroy(json);
@@ -1152,7 +1162,7 @@ do_query_distinct(int argc OVS_UNUSED, char *argv[])
ovs_fatal(0, "duplicate UUID "UUID_FMT" in table",
UUID_ARGS(ovsdb_row_get_uuid(row)));
}
- ovsdb_table_put_row(table, row);
+ put_row(table, row);
}
json_destroy(json);