/*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
" parse string DATUMs as data of given TYPE, and re-serialize\n"
" parse-column NAME OBJECT\n"
" parse column NAME with info OBJECT, and re-serialize\n"
- " parse-table NAME OBJECT\n"
+ " parse-table NAME OBJECT [DEFAULT-IS-ROOT]\n"
" parse table NAME with info OBJECT\n"
" parse-row TABLE ROW..., and re-serialize\n"
" parse each ROW of defined TABLE\n"
do_parse_table(int argc OVS_UNUSED, char *argv[])
{
struct ovsdb_table_schema *ts;
+ bool default_is_root;
struct json *json;
+ default_is_root = argc > 3 && !strcmp(argv[3], "true");
+
json = parse_json(argv[2]);
check_ovsdb_error(ovsdb_table_schema_from_json(json, argv[1], &ts));
json_destroy(json);
- print_and_free_json(ovsdb_table_schema_to_json(ts));
+ print_and_free_json(ovsdb_table_schema_to_json(ts, default_is_root));
ovsdb_table_schema_destroy(ts);
}
static void
do_transact_commit(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- ovsdb_txn_commit(do_transact_txn, false);
+ ovsdb_error_destroy(ovsdb_txn_commit(do_transact_txn, false));
do_transact_txn = NULL;
}
n_rows = hmap_count(&do_transact_table->rows);
rows = xmalloc(n_rows * sizeof *rows);
i = 0;
- HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node,
- &do_transact_table->rows) {
+ HMAP_FOR_EACH (row, hmap_node, &do_transact_table->rows) {
rows[i++] = row;
}
assert(i == n_rows);
idltest_simple_set_s(s, arg3);
} else if (!strcmp(arg2, "u")) {
struct uuid uuid;
- uuid_from_string(&uuid, arg3);
+ if (!uuid_from_string(&uuid, arg3)) {
+ ovs_fatal(0, "\"%s\" is not a valid UUID", arg3);
+ }
idltest_simple_set_u(s, uuid);
} else if (!strcmp(arg2, "r")) {
idltest_simple_set_r(s, atof(arg3));
"i=%d", atoi(arg1));
}
idltest_simple_delete(s);
+ } else if (!strcmp(name, "verify")) {
+ const struct idltest_simple *s;
+
+ if (!arg2 || arg3) {
+ ovs_fatal(0, "\"verify\" command requires 2 arguments");
+ }
+
+ s = idltest_find_simple(idl, atoi(arg1));
+ if (!s) {
+ ovs_fatal(0, "\"verify\" command asks for nonexistent "
+ "i=%d", atoi(arg1));
+ }
+
+ if (!strcmp(arg2, "i")) {
+ idltest_simple_verify_i(s);
+ } else if (!strcmp(arg2, "b")) {
+ idltest_simple_verify_b(s);
+ } else if (!strcmp(arg2, "s")) {
+ idltest_simple_verify_s(s);
+ } else if (!strcmp(arg2, "u")) {
+ idltest_simple_verify_s(s);
+ } else if (!strcmp(arg2, "r")) {
+ idltest_simple_verify_r(s);
+ } else {
+ ovs_fatal(0, "\"verify\" command asks for unknown column %s",
+ arg2);
+ }
} else if (!strcmp(name, "increment")) {
if (!arg2 || arg3) {
- ovs_fatal(0, "\"set\" command requires 2 arguments");
+ ovs_fatal(0, "\"increment\" command requires 2 arguments");
}
ovsdb_idl_txn_increment(txn, arg1, arg2, NULL);
increment = true;
idltest_init();
- idl = ovsdb_idl_create(argv[1], &idltest_idl_class);
+ idl = ovsdb_idl_create(argv[1], &idltest_idl_class, true);
if (argc > 2) {
struct stream *stream;
{ "parse-data-strings", 2, INT_MAX, do_parse_data_strings },
{ "sort-atoms", 2, 2, do_sort_atoms },
{ "parse-column", 2, 2, do_parse_column },
- { "parse-table", 2, 2, do_parse_table },
+ { "parse-table", 2, 3, do_parse_table },
{ "parse-rows", 2, INT_MAX, do_parse_rows },
{ "compare-rows", 2, INT_MAX, do_compare_rows },
{ "parse-conditions", 2, INT_MAX, do_parse_conditions },