aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-05-07 10:44:01 -0700
committerBen Pfaff <blp@nicira.com>2010-05-07 14:36:06 -0700
commita1ae5dc8da2d30704f7654e0d593cf2ca1e088f7 (patch)
tree70d2f5afd14c202b62505a5c3f87d65cf677266e
parente86dd676cdb1885ee4f8f1fa92176d159d5bb533 (diff)
ovsdb-client: Serialize columns in predictable order on "monitor" command.
The "monitor" command goes to some trouble to write its output in a predictable order, so that test programs can reliably compare it against expectations. This commit fixes up one part that was missing, which is that the columns were not being ordered predictably (it depended on hash order, which differs between big-endian and little-endian systems). It also updates the test suite to expect the new order.
-rw-r--r--ovsdb/ovsdb-client.c18
-rw-r--r--tests/ovsdb-monitor.at12
2 files changed, 19 insertions, 11 deletions
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 7a8310f1..7177b261 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -917,14 +917,22 @@ do_monitor(int argc, char *argv[])
ovsdb_column_set_add(&columns, column);
}
} else {
- struct shash_node *node;
-
- SHASH_FOR_EACH (node, &table->columns) {
- const struct ovsdb_column *column = node->data;
- if (column->index != OVSDB_COL_UUID) {
+ const struct shash_node **nodes;
+ size_t i, n;
+
+ n = shash_count(&table->columns);
+ nodes = shash_sort(&table->columns);
+ for (i = 0; i < n; i++) {
+ const struct ovsdb_column *column = nodes[i]->data;
+ if (column->index != OVSDB_COL_UUID
+ && column->index != OVSDB_COL_VERSION) {
ovsdb_column_set_add(&columns, column);
}
}
+ free(nodes);
+
+ ovsdb_column_set_add(&columns,
+ ovsdb_table_schema_get_column(table, "_version"));
}
if (argc >= 6 && *argv[5] != '\0') {
diff --git a/tests/ovsdb-monitor.at b/tests/ovsdb-monitor.at
index 0f29a05b..7ccbb03c 100644
--- a/tests/ovsdb-monitor.at
+++ b/tests/ovsdb-monitor.at
@@ -204,13 +204,13 @@ OVSDB_CHECK_MONITOR([monitor weak reference change],
{"op": "delete",
"table": "a",
"where": [["a", "==", 0]]}]]]],
- [[row,action,a,a2a,a2b,a2a1,_version
-<0>,initial,0,"[""set"",[]]","[""uuid"",""<1>""]","[""uuid"",""<0>""]","[""uuid"",""<2>""]"
-<3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<3>""]","[""uuid"",""<4>""]"
+ [[row,action,a,a2a,a2a1,a2b,_version
+<0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
+<3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
-row,action,a,a2a,a2b,a2a1,_version
-<0>,delete,0,"[""set"",[]]","[""uuid"",""<1>""]","[""uuid"",""<0>""]","[""uuid"",""<2>""]"
+row,action,a,a2a,a2a1,a2b,_version
+<0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
<3>,old,,"[""uuid"",""<0>""]",,,
-,new,1,"[""set"",[]]","[""uuid"",""<1>""]","[""uuid"",""<3>""]","[""uuid"",""<5>""]"
+,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
]])