Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into pause_errors_4
Browse files Browse the repository at this point in the history
  • Loading branch information
qkoziol committed Jul 5, 2024
2 parents 10b1efc + 96acf6c commit 5b3592e
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 36 deletions.
2 changes: 1 addition & 1 deletion fortran/src/H5Pf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, o
herr_t status;
size_t c_namelen;
char *c_name = NULL;
off_t c_offset;
HDoff_t c_offset;
hsize_t size;

c_namelen = (size_t)*name_size;
Expand Down
33 changes: 19 additions & 14 deletions src/H5FDs3comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,15 +1454,16 @@ herr_t
H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, char *signed_headers_dest,
int _sh_size, hrb_t *http_request)
{
hrb_node_t *node = NULL;
const char *query_params = ""; /* unused at present */
herr_t ret_value = SUCCEED;
int ret = 0;
size_t cr_size = (size_t)_cr_size;
size_t sh_size = (size_t)_sh_size;
size_t cr_len = 0; /* working length of canonical request str */
size_t sh_len = 0; /* working length of signed headers str */
char tmpstr[H5FD_ROS3_MAX_SECRET_TOK_LEN];
hrb_node_t *node = NULL;
const char *query_params = ""; /* unused at present */
herr_t ret_value = SUCCEED;
int ret = 0;
size_t cr_size = (size_t)_cr_size;
size_t sh_size = (size_t)_sh_size;
size_t cr_len = 0; /* working length of canonical request str */
size_t sh_len = 0; /* working length of signed headers str */
char *tmpstr = NULL;
const size_t TMP_STR_SIZE = sizeof(char) * H5FD_ROS3_MAX_SECRET_TOK_LEN;

/* "query params" refers to the optional element in the URL, e.g.
* http://bucket.aws.com/myfile.txt?max-keys=2&prefix=J
Expand Down Expand Up @@ -1491,27 +1492,29 @@ H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, c
if (cr_len >= cr_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request");

/* TODO: compiler warning */
ret = snprintf(canonical_request_dest, (cr_size - 1), "%s\n%s\n%s\n", http_request->verb,
http_request->resource, query_params);
if (ret < 0 || (size_t)ret >= cr_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to compose canonical request first line");

if (NULL == (tmpstr = (char *)H5MM_calloc(TMP_STR_SIZE)))
HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "unable to allocate space for temp string");

/* write in canonical headers, building signed headers concurrently */
node = http_request->first_header; /* assumed sorted */
while (node != NULL) {

ret = snprintf(tmpstr, sizeof(tmpstr), "%s:%s\n", node->lowername, node->value);
if (ret < 0 || ret >= (int)sizeof(tmpstr))
ret = snprintf(tmpstr, TMP_STR_SIZE, "%s:%s\n", node->lowername, node->value);
if (ret < 0 || ret >= (int)TMP_STR_SIZE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to concatenate HTTP header %s:%s",
node->lowername, node->value);
cr_len += strlen(tmpstr);
if (cr_len + 1 > cr_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request");
strcat(canonical_request_dest, tmpstr);

ret = snprintf(tmpstr, sizeof(tmpstr), "%s;", node->lowername);
if (ret < 0 || ret >= (int)sizeof(tmpstr))
ret = snprintf(tmpstr, TMP_STR_SIZE, "%s;", node->lowername);
if (ret < 0 || ret >= (int)TMP_STR_SIZE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to append semicolon to lowername %s",
node->lowername);
sh_len += strlen(tmpstr);
Expand All @@ -1536,6 +1539,8 @@ H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, c
strcat(canonical_request_dest, EMPTY_SHA256);

done:
free(tmpstr);

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_s3comms_aws_canonical_request() */

Expand Down
5 changes: 3 additions & 2 deletions test/API/H5_api_async_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2674,10 +2674,11 @@ cleanup_files(void)
char file_name[64];
int i;

H5Fdelete(ASYNC_API_TEST_FILE, H5P_DEFAULT);
remove_test_file(NULL, ASYNC_API_TEST_FILE);

for (i = 0; i <= max_printf_file; i++) {
snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i);
H5Fdelete(file_name, H5P_DEFAULT);
remove_test_file(NULL, file_name);
} /* end for */
}

Expand Down
4 changes: 2 additions & 2 deletions test/API/H5_api_link_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27270,8 +27270,8 @@ link_visit_0_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info,
static void
cleanup_files(void)
{
H5Fdelete(EXTERNAL_LINK_TEST_FILE_NAME, H5P_DEFAULT);
H5Fdelete(EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME, H5P_DEFAULT);
remove_test_file(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME);
remove_test_file(test_path_prefix, EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME);
}

int
Expand Down
25 changes: 13 additions & 12 deletions test/API/H5_api_object_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4196,7 +4196,6 @@ test_object_copy_between_files(void)
hid_t attr_space_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t ocpypl_id = H5I_INVALID_HID;
char filename[H5_API_TEST_FILENAME_MAX_LENGTH];

TESTING_MULTIPART("object copying between files");

Expand Down Expand Up @@ -4750,10 +4749,6 @@ test_object_copy_between_files(void)
TEST_ERROR;
if (H5Fclose(file_id) < 0)
TEST_ERROR;
snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix,
OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME);
if (H5Fdelete(filename, H5P_DEFAULT) < 0)
TEST_ERROR;

PASSED();

Expand Down Expand Up @@ -5072,7 +5067,6 @@ test_object_visit(void)
hssize_t num_elems = 0;
size_t elem_size = 0;
char visit_filename[H5_API_TEST_FILENAME_MAX_LENGTH];
char filename[H5_API_TEST_FILENAME_MAX_LENGTH];

TESTING_MULTIPART("object visiting");

Expand Down Expand Up @@ -5714,12 +5708,6 @@ test_object_visit(void)
TEST_ERROR;
if (H5Fclose(file_id2) < 0)
TEST_ERROR;
snprintf(filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix,
OBJECT_VISIT_TEST_FILE_NAME);
if (H5Fdelete(filename, H5P_DEFAULT) < 0)
TEST_ERROR;
if (H5Fdelete(visit_filename, H5P_DEFAULT) < 0)
TEST_ERROR;

PASSED();

Expand Down Expand Up @@ -7375,6 +7363,16 @@ object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *obje
return 0;
}

/*
* Cleanup temporary test files
*/
static void
cleanup_files(void)
{
remove_test_file(test_path_prefix, OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME);
remove_test_file(test_path_prefix, OBJECT_VISIT_TEST_FILE_NAME);
}

int
H5_api_object_test(void)
{
Expand All @@ -7393,5 +7391,8 @@ H5_api_object_test(void)

printf("\n");

printf("Cleaning up testing files\n");
cleanup_files();

return nerrors;
}
9 changes: 8 additions & 1 deletion test/API/H5_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,14 @@ main(int argc, char **argv)
H5_api_test_run();

printf("Cleaning up testing files\n");
H5Fdelete(H5_api_test_filename, fapl_id);

H5E_BEGIN_TRY
{
if (H5Fis_accessible(H5_api_test_filename, H5P_DEFAULT) > 0) {
H5Fdelete(H5_api_test_filename, fapl_id);
}
}
H5E_END_TRY

if (n_tests_run_g > 0) {
printf("%zu/%zu (%.2f%%) API tests passed with VOL connector '%s'\n", n_tests_passed_g, n_tests_run_g,
Expand Down
14 changes: 10 additions & 4 deletions test/API/H5_api_test_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,17 @@ remove_test_file(const char *prefix, const char *filename)
else
test_file = filename;

if (H5Fdelete(test_file, H5P_DEFAULT) < 0) {
printf(" couldn't remove file '%s'\n", test_file);
ret_value = FAIL;
goto done;
H5E_BEGIN_TRY
{
if (H5Fis_accessible(test_file, H5P_DEFAULT) > 0) {
if (H5Fdelete(test_file, H5P_DEFAULT) < 0) {
printf(" couldn't remove file '%s'\n", test_file);
ret_value = FAIL;
goto done;
}
}
}
H5E_END_TRY

done:
free(prefixed_filename);
Expand Down

0 comments on commit 5b3592e

Please sign in to comment.