X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Ftest-ovsdb.c;h=672759be8be49fe3e1336b518cc24a3028d081b1;hb=4eb26d3cd41b6bcbd3e12e85bc9e4f36f47eb430;hp=2e12d495bd885d366c19afb1d3023aca98ae0d1d;hpb=c69ee87c10818267f991236201150b1fa51ae519;p=openvswitch diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index 2e12d495..672759be 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -257,34 +257,24 @@ static void do_log_io(int argc, char *argv[]) { const char *name = argv[1]; - char *mode = argv[2]; + char *mode_string = argv[2]; struct ovsdb_error *error; + enum ovsdb_log_open_mode mode; struct ovsdb_log *log; - char *save_ptr = NULL; - const char *token; - int flags; int i; - for (flags = 0, token = strtok_r(mode, " |", &save_ptr); token != NULL; - token = strtok_r(NULL, " |", &save_ptr)) - { - if (!strcmp(token, "O_RDONLY")) { - flags |= O_RDONLY; - } else if (!strcmp(token, "O_RDWR")) { - flags |= O_RDWR; - } else if (!strcmp(token, "O_TRUNC")) { - flags |= O_TRUNC; - } else if (!strcmp(token, "O_CREAT")) { - flags |= O_CREAT; - } else if (!strcmp(token, "O_EXCL")) { - flags |= O_EXCL; - } else if (!strcmp(token, "O_TRUNC")) { - flags |= O_TRUNC; - } + if (!strcmp(mode_string, "read-only")) { + mode = OVSDB_LOG_READ_ONLY; + } else if (!strcmp(mode_string, "read/write")) { + mode = OVSDB_LOG_READ_WRITE; + } else if (!strcmp(mode_string, "create")) { + mode = OVSDB_LOG_CREATE; + } else { + ovs_fatal(0, "unknown log-io open mode \"%s\"", mode_string); } - check_ovsdb_error(ovsdb_log_open(name, flags, &log)); + check_ovsdb_error(ovsdb_log_open(name, mode, -1, &log)); printf("%s: open successful\n", name); for (i = 3; i < argc; i++) { @@ -751,7 +741,7 @@ do_evaluate_conditions(int argc OVS_UNUSED, char *argv[]) json_destroy(json); for (i = 0; i < n_conditions; i++) { - printf("condition %2d:", i); + printf("condition %2zu:", i); for (j = 0; j < n_rows; j++) { bool result = ovsdb_condition_evaluate(rows[j], &conditions[i]); if (j % 5 == 0) { @@ -857,7 +847,7 @@ do_execute_mutations(int argc OVS_UNUSED, char *argv[]) json_destroy(json); for (i = 0; i < n_sets; i++) { - printf("mutation %2d:\n", i); + printf("mutation %2zu:\n", i); for (j = 0; j < n_rows; j++) { struct ovsdb_error *error; struct ovsdb_row *row; @@ -979,7 +969,7 @@ do_query(int argc OVS_UNUSED, char *argv[]) memset(cbdata.counts, 0, cbdata.n_rows * sizeof *cbdata.counts); ovsdb_query(table, &cnd, do_query_cb, &cbdata); - printf("query %2d:", i); + printf("query %2zu:", i); for (j = 0; j < cbdata.n_rows; j++) { if (j % 5 == 0) { putchar(' '); @@ -1112,7 +1102,7 @@ do_query_distinct(int argc OVS_UNUSED, char *argv[]) } ovsdb_row_set_destroy(&results); - printf("query %2d:", i); + printf("query %2zu:", i); for (j = 0; j < n_rows; j++) { int count = rows[j].class->count; @@ -1607,7 +1597,7 @@ parse_uuids(const struct json *json, struct ovsdb_symbol_table *symtab, struct uuid uuid; if (json->type == JSON_STRING && uuid_from_string(&uuid, json->u.string)) { - char *name = xasprintf("#%d#", *n); + char *name = xasprintf("#%zu#", *n); fprintf(stderr, "%s = "UUID_FMT"\n", name, UUID_ARGS(&uuid)); ovsdb_symbol_table_put(symtab, name, &uuid, false); free(name); @@ -1745,12 +1735,7 @@ idl_set(struct ovsdb_idl *idl, char *commands, int step) } } - while ((status = ovsdb_idl_txn_commit(txn)) == TXN_INCOMPLETE) { - ovsdb_idl_run(idl); - ovsdb_idl_wait(idl); - ovsdb_idl_txn_wait(txn); - poll_block(); - } + status = ovsdb_idl_txn_commit_block(txn); printf("%03d: commit, status=%s", step, ovsdb_idl_txn_status_to_string(status)); if (increment) { @@ -1779,7 +1764,8 @@ do_idl(int argc, char *argv[]) if (argc > 2) { struct stream *stream; - error = stream_open_block(argv[1], &stream); + error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), + &stream); if (error) { ovs_fatal(error, "failed to connect to \"%s\"", argv[1]); }