ovsdb-client: Serialize columns in predictable order on "monitor" command.
authorBen Pfaff <blp@nicira.com>
Fri, 7 May 2010 17:44:01 +0000 (10:44 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 7 May 2010 21:36:06 +0000 (14:36 -0700)
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
tests/ovsdb-monitor.at

index 7a8310f..7177b26 100644 (file)
@@ -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') {
index 0f29a05..7ccbb03 100644 (file)
@@ -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>""]"
 ]])