Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update -DMERCURY_USE_XDR=ON code to pass unit tests #773

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions Testing/unit/hg/mercury_rpc_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,16 @@ HG_TEST_RPC_CB(hg_test_rpc_open, handle)
struct hg_unit_info *info = (struct hg_unit_info *) HG_Class_get_data(
HG_Get_info(handle)->hg_class);
hg_size_t payload_size = HG_Get_input_payload_size(handle);
#ifdef HG_HAS_XDR
size_t expected_string_payload_size = /* note xdr rounding rules */
sizeof(uint64_t) + /* length */
RNDUP(strlen(HG_TEST_RPC_PATH) + 1) + /* string data, inc \0 at end */
RNDUP(sizeof(uint8_t)) + /* is_const */
RNDUP(sizeof(uint8_t)); /* is_owned */
#else
size_t expected_string_payload_size =
strlen(HG_TEST_RPC_PATH) + sizeof(uint64_t) + 3;
#endif

HG_TEST_CHECK_ERROR(
payload_size != sizeof(rpc_handle_t) + expected_string_payload_size,
Expand Down
8 changes: 8 additions & 0 deletions Testing/unit/hg/test_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,16 @@ hg_test_rpc_input(hg_handle_t handle, hg_addr_t addr, hg_id_t rpc_id,
rpc_open_in_t in_struct = {
.handle = rpc_open_handle, .path = HG_TEST_RPC_PATH};
hg_size_t payload_size;
#ifdef HG_HAS_XDR
size_t expected_string_payload_size = /* note xdr rounding rules */
sizeof(uint64_t) + /* length */
RNDUP(strlen(HG_TEST_RPC_PATH) + 1) + /* string data, inc \0 at end */
RNDUP(sizeof(uint8_t)) + /* is_const */
RNDUP(sizeof(uint8_t)); /* is_owned */
#else
size_t expected_string_payload_size =
strlen(HG_TEST_RPC_PATH) + sizeof(uint64_t) + 3;
#endif
unsigned int flag;
int rc;

Expand Down
5 changes: 0 additions & 5 deletions src/mercury.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,8 @@ hg_set_struct(struct hg_private_handle *hg_handle,
ret = hg_header_proc(HG_ENCODE, buf, buf_size, hg_header);
HG_CHECK_SUBSYS_HG_ERROR(rpc, error, ret, "Could not process header");

#ifdef HG_HAS_XDR
/* XDR requires entire buffer payload */
*payload_size = buf_size;
#else
/* Only send the actual size of the data, not the entire buffer */
*payload_size = hg_proc_get_size_used(proc) + header_offset;
#endif

return HG_SUCCESS;

Expand Down
12 changes: 6 additions & 6 deletions src/mercury_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ typedef enum { HG_CRC16, HG_CRC32, HG_CRC64, HG_NOHASH } hg_proc_hash_t;
#ifdef HG_HAS_XDR
# define HG_PROC_TYPE(proc, type, data, label, ret) \
do { \
HG_PROC_CHECK_SIZE(proc, sizeof(type), label, ret); \
HG_PROC_CHECK_SIZE(proc, RNDUP(sizeof(type)), label, ret); \
\
if (xdr_##type(hg_proc_get_xdr_ptr(proc), data) == 0) { \
ret = HG_PROTOCOL_ERROR; \
goto label; \
} \
\
HG_PROC_UPDATE(proc, sizeof(type)); \
HG_PROC_UPDATE(proc, RNDUP(sizeof(type))); \
HG_PROC_CHECKSUM_UPDATE(proc, data, sizeof(type)); \
} while (0)
#else
Expand Down Expand Up @@ -147,15 +147,15 @@ typedef enum { HG_CRC16, HG_CRC32, HG_CRC64, HG_NOHASH } hg_proc_hash_t;
#ifdef HG_HAS_XDR
# define HG_PROC_BYTES(proc, data, size, label, ret) \
do { \
HG_PROC_CHECK_SIZE(proc, size, label, ret); \
HG_PROC_CHECK_SIZE(proc, RNDUP(size), label, ret); \
\
if (xdr_bytes(hg_proc_get_xdr_ptr(proc), (char **) &data, \
(u_int *) &size, UINT_MAX) == 0) { \
if (xdr_opaque(hg_proc_get_xdr_ptr(proc), (char *) data, size) == \
0) { \
ret = HG_PROTOCOL_ERROR; \
goto label; \
} \
\
HG_PROC_UPDATE(proc, size); \
HG_PROC_UPDATE(proc, RNDUP(size)); \
HG_PROC_CHECKSUM_UPDATE(proc, data, size); \
} while (0)
#else
Expand Down
Loading