Skip to content

Commit

Permalink
daos: negative test case bug fixes (#499)
Browse files Browse the repository at this point in the history
This fixes bugs found in a test case that is currently being
skippin the DAOS CI. There were a couple of regressions that
need fixing. If a daos source string without a container was
passed in dcp was not reporting invalid arguments were passed.
Also, it should not matter if the source/dest pool or cont UUID
are upper or lower case. It was incorrectly reporting that the
DAOS source and destination were the same in that case.

    * properly check if a source pool and source cont are passed
    * allow passing in upper or lower case UUIDs for src and dst
    * return -1 when daos read or write fails

Signed-off-by: Danielle Sikich <danielle.sikich@intel.com>
  • Loading branch information
Danielle Sikich committed Sep 29, 2021
1 parent 8daf762 commit bdc379b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/common/mfu_daos.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,32 @@ static int daos_check_args(
return 0;
}

/* if passed in values for src/dst are both uuids ignore the case when comparing */

/* Determine whether the source and destination
* use the same pool and container */
bool same_pool = (strcmp(da->src_pool, da->dst_pool) == 0);
bool same_cont = same_pool && (strcmp(da->src_cont, da->dst_cont) == 0);
int rc1, rc2;
bool same_pool = false;
uuid_t src_pool;
uuid_t dst_pool;
rc1 = uuid_parse(da->src_pool, src_pool);
rc2 = uuid_parse(da->dst_pool, dst_pool);
if (rc1 == 0 && rc2 == 0) {
same_pool = (strcasecmp(da->src_pool, da->dst_pool) == 0);
} else {
same_pool = (strcmp(da->src_pool, da->dst_pool) == 0);
}

bool same_cont = false;
uuid_t src_cont;
uuid_t dst_cont;
rc1 = uuid_parse(da->src_cont, src_cont);
rc2 = uuid_parse(da->dst_cont, dst_cont);
if (rc1 == 0 && rc2 == 0) {
same_cont = same_pool && (strcasecmp(da->src_cont, da->dst_cont) == 0);
} else {
same_cont = same_pool && (strcmp(da->src_cont, da->dst_cont) == 0);
}

/* Determine whether the source and destination paths are the same.
* Assume NULL == NULL. */
Expand Down Expand Up @@ -412,7 +434,7 @@ static int daos_set_paths(
}
int src_rc = daos_parse_path(src_path, src_len, &da->src_pool, &da->src_cont);
if (src_rc == 0) {
if (da->src_cont == NULL) {
if (strlen(da->src_cont) == 0) {
MFU_LOG(MFU_LOG_ERR, "Source pool requires a source container.");
rc = 1;
goto out;
Expand Down
6 changes: 6 additions & 0 deletions src/common/mfu_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ ssize_t daos_read(const char* file, void* buf, size_t size, mfu_file_t* mfu_file
int rc = dfs_sys_read(mfu_file->dfs_sys, mfu_file->obj, buf, mfu_file->offset, &got_size, NULL);
if (rc != 0) {
errno = rc;
return -1;
} else {
/* update file pointer with number of bytes read */
mfu_file->offset += (daos_off_t)got_size;
Expand Down Expand Up @@ -945,6 +946,7 @@ ssize_t daos_write(const char* file, const void* buf, size_t size, mfu_file_t* m
int rc = dfs_sys_write(mfu_file->dfs_sys, mfu_file->obj, buf, mfu_file->offset, &write_size, NULL);
if (rc != 0) {
errno = rc;
return -1;
} else {
/* update file pointer with number of bytes written */
mfu_file->offset += write_size;
Expand Down Expand Up @@ -977,6 +979,8 @@ ssize_t daos_pread(const char* file, void* buf, size_t size, off_t offset, mfu_f
int rc = dfs_sys_read(mfu_file->dfs_sys, mfu_file->obj, buf, offset, &got_size, NULL);
if (rc != 0) {
errno = rc;
/* return -1 if dfs_sys_read encounters error */
return -1;
}
return (ssize_t)got_size;
#else
Expand Down Expand Up @@ -1061,6 +1065,8 @@ ssize_t daos_pwrite(const char* file, const void* buf, size_t size, off_t offset
int rc = dfs_sys_write(mfu_file->dfs_sys, mfu_file->obj, buf, offset, &write_size, NULL);
if (rc != 0) {
errno = rc;
/* report -1 if dfs_sys_write encounters error */
return -1;
}
return (ssize_t)write_size;
#else
Expand Down

0 comments on commit bdc379b

Please sign in to comment.