From a1ae5dc8da2d30704f7654e0d593cf2ca1e088f7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 7 May 2010 10:44:01 -0700 Subject: [PATCH] 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. --- ovsdb/ovsdb-client.c | 18 +++++++++++++----- tests/ovsdb-monitor.at | 12 ++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 7a8310f15..7177b2614 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 0f29a05bf..7ccbb03c7 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>""]" ]]) -- 2.20.1