Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/utils/ddb/tests/ddb_commands_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,41 @@ dtx_get_cmt_time(char *buf)
return cmt_time;
}

static void
open_cmd_tests(void **state)
{
struct dt_vos_pool_ctx *tctx = *state;
struct ddb_ctx ctx = {0};
struct open_options opt = {0};

ctx.dc_io_ft.ddb_print_message = dvt_fake_print;
ctx.dc_io_ft.ddb_print_error = dvt_fake_print;

/* Non-existent path: must return DER_INVAL */
opt.path = "/non/existent/vos-0";
assert_invalid(ddb_run_open(&ctx, &opt));

/* Read-only open: pool handle must be valid, dc_write_mode must be false */
opt.path = tctx->dvt_pmem_file;
opt.write_mode = false;
assert_success(ddb_run_open(&ctx, &opt));
assert_true(daos_handle_is_valid(ctx.dc_poh));
assert_false(ctx.dc_write_mode);
assert_success(ddb_run_close(&ctx));

/* Write-mode open: dc_write_mode must be propagated to the context */
opt.write_mode = true;
assert_success(ddb_run_open(&ctx, &opt));
assert_true(daos_handle_is_valid(ctx.dc_poh));
assert_true(ctx.dc_write_mode);

/* Pool already open: must return DER_BUSY with an error message */
dvt_fake_print_reset();
assert_rc_equal(-DER_BUSY, ddb_run_open(&ctx, &opt));
assert_printed_contains("Cannot operate on an opened pool. Close it first.");
assert_success(ddb_run_close(&ctx));
}

static void
dtx_aggr_tests(void **state)
{
Expand Down Expand Up @@ -621,6 +656,7 @@ ddb_commands_tests_run()
TEST(dtx_act_discard_invalid_tests),
TEST(dtx_abort_entry_tests),
TEST(feature_cmd_tests),
TEST(open_cmd_tests),
TEST(dtx_aggr_tests),
};

Expand Down
Loading