1
1

Two major changes to the runtime:

1. implement and enable the non-described buffer operations. I will send out a more detailed explanation separately. However, this mode of operation (which is now the default) significantly reduces message size during startup. If you want the described buffers, set the mca param "-mca dss_describe_buffer 1".

2. revise the xcast system to support both linear and binomial tree broadcast methods. Since we are seeing scenarios where the binomiall tree can cause problems, I have made the linear method the default. To run with the binomial tree, set the mca param "-mca oob_xcast_mode binomial".

3. add some detailed timing reports to the xcast operation. These are enabled via "-mca oob_xcast_timing 1".

4. add some more unit tests for the dss and gpr (focused on support for the non-described buffer)

This commit was SVN r12722.
Этот коммит содержится в:
Ralph Castain 2006-12-01 22:30:39 +00:00
родитель 3edd850d2e
Коммит 897744cdeb
38 изменённых файлов: 10129 добавлений и 655 удалений

Просмотреть файл

@ -99,7 +99,9 @@ bool orte_dss_too_small(orte_buffer_t *buffer, size_t bytes_reqd)
bytes_remaining_packed = buffer->pack_ptr - buffer->unpack_ptr;
if (bytes_remaining_packed < bytes_reqd) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
/* don't error log this - it could be that someone is trying to
* simply read until the buffer is empty
*/
return true;
}
@ -138,9 +140,7 @@ int orte_dss_get_data_type(orte_buffer_t *buffer, orte_data_type_t *type)
return ORTE_ERR_PACK_FAILURE;
}
if (ORTE_SUCCESS != (rc = info->odti_unpack_fn(buffer, type, &n, ORTE_DATA_TYPE_T))) {
ORTE_ERROR_LOG(rc);
}
rc = info->odti_unpack_fn(buffer, type, &n, ORTE_DATA_TYPE_T);
return rc;
}

Просмотреть файл

@ -156,8 +156,20 @@ int orte_dss_open(void)
orte_dss_debug = false;
}
/** set the default buffer type */
default_buf_type = ORTE_DSS_BUFFER_FULLY_DESC;
/** set the default buffer type. If we are in debug mode - as given by
* the orte_debug param being set - then we use fully described buffers.
* Otherwise, we default to non-described for brevity
*/
id = mca_base_param_register_int("dss", "describe", "buffer",
"Set the default mode for OpenRTE buffers (0=non-described [default], 1=described",
0);
mca_base_param_lookup_int(id, &rc);
if (0 == rc) {
/* param not set - assume non-described buffers */
default_buf_type = ORTE_DSS_BUFFER_NON_DESC;
} else {
default_buf_type = ORTE_DSS_BUFFER_FULLY_DESC;
}
/* setup the page size -this is for use by the BUFFER system, NOT the data type
manager that keeps track of registered data types!! It must be converted to

Просмотреть файл

@ -388,12 +388,26 @@ int orte_dss_pack_data_value(orte_buffer_t *buffer, void *src, orte_std_cntr_t n
sdv = (orte_data_value_t **) src;
for (i = 0; i < num; ++i) {
/* if the src data value is NULL, then we will pack it as ORTE_NULL to indicate
* that the unpack should leave a NULL data value
*/
if (NULL == sdv[i]) {
if (ORTE_SUCCESS != (ret = orte_dss_store_data_type(buffer, ORTE_NULL))) {
ORTE_ERROR_LOG(ret);
return ret;
}
continue;
}
/* pack the data type - we'll need it on the other end */
if (ORTE_SUCCESS != (ret = orte_dss_store_data_type(buffer, sdv[i]->type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
/* if the data type is UNDEF, then nothing more to do */
if (ORTE_UNDEF == sdv[i]->type) continue;
/* Lookup the pack function for this type and call it */
if (NULL == (info = (orte_dss_type_info_t*)orte_pointer_array_get_item(orte_dss_types, sdv[i]->type))) {

Просмотреть файл

@ -40,6 +40,7 @@ int orte_dss_peek(orte_buffer_t *buffer, orte_data_type_t *type,
/* Double check and ensure that there is data left in the buffer. */
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
*type = ORTE_NULL;
*num_vals = 0;
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
@ -50,6 +51,7 @@ int orte_dss_peek(orte_buffer_t *buffer, orte_data_type_t *type,
* in the buffer since that info wasn't stored.
*/
if (ORTE_DSS_BUFFER_FULLY_DESC != buffer->type) {
ORTE_ERROR_LOG(ORTE_ERR_UNKNOWN_DATA_TYPE);
*type = ORTE_UNDEF;
*num_vals = 0;
return ORTE_ERR_UNKNOWN_DATA_TYPE;
@ -59,8 +61,8 @@ int orte_dss_peek(orte_buffer_t *buffer, orte_data_type_t *type,
original pointers intact */
tmp = *buffer;
if (ORTE_SUCCESS != (
ret = orte_dss_get_data_type(&tmp, &local_type))) {
if (ORTE_SUCCESS != (ret = orte_dss_get_data_type(&tmp, &local_type))) {
ORTE_ERROR_LOG(ret);
*type = ORTE_NULL;
*num_vals = 0;
return ret;
@ -102,12 +104,14 @@ int orte_dss_peek_type(orte_buffer_t *buffer, orte_data_type_t *type)
* in the buffer since that info wasn't stored.
*/
if (ORTE_DSS_BUFFER_FULLY_DESC != buffer->type) {
ORTE_ERROR_LOG(ORTE_ERR_UNKNOWN_DATA_TYPE);
*type = ORTE_UNDEF;
return ORTE_ERR_UNKNOWN_DATA_TYPE;
}
/* Double check and ensure that there is data left in the buffer. */
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
*type = ORTE_UNDEF;
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -116,8 +120,8 @@ int orte_dss_peek_type(orte_buffer_t *buffer, orte_data_type_t *type)
original pointers intact */
tmp = *buffer;
if (ORTE_SUCCESS != (
ret = orte_dss_get_data_type(&tmp, type))) {
if (ORTE_SUCCESS != (ret = orte_dss_get_data_type(&tmp, type))) {
ORTE_ERROR_LOG(ret);
*type = ORTE_UNDEF;
return ret;
}

Просмотреть файл

@ -37,7 +37,7 @@ int orte_dss_set_buffer_type(orte_buffer_t *buffer, orte_dss_buffer_type_t type)
}
/** see if the buffer is empty - if not, generate error */
if (buffer->base_ptr == buffer->pack_ptr) {
if (buffer->base_ptr != buffer->pack_ptr) {
ORTE_ERROR_LOG(ORTE_ERR_BUFFER);
return ORTE_ERR_BUFFER;
}

Просмотреть файл

@ -26,6 +26,7 @@
#include "opal/types.h"
#include "opal/util/output.h"
#include "opal/mca/backtrace/backtrace.h"
#include "orte/mca/errmgr/errmgr.h"
@ -34,7 +35,7 @@
int orte_dss_unpack(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *num_vals,
orte_data_type_t type)
{
int ret=ORTE_SUCCESS, rc=ORTE_SUCCESS;
int rc, ret;
orte_std_cntr_t local_num, n=1;
orte_data_type_t local_type;
@ -64,7 +65,6 @@ int orte_dss_unpack(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *num_vals,
if (ORTE_DSS_BUFFER_FULLY_DESC == buffer->type) {
if (ORTE_SUCCESS != (
rc = orte_dss_get_data_type(buffer, &local_type))) {
ORTE_ERROR_LOG(rc);
*num_vals = 0;
return rc;
}
@ -76,9 +76,7 @@ int orte_dss_unpack(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *num_vals,
}
n=1;
if (ORTE_SUCCESS != (
rc = orte_dss_unpack_std_cntr(buffer, &local_num, &n, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
if (ORTE_SUCCESS != (rc = orte_dss_unpack_std_cntr(buffer, &local_num, &n, ORTE_STD_CNTR))) {
*num_vals = 0;
return rc;
}
@ -92,21 +90,18 @@ int orte_dss_unpack(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *num_vals,
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_INADEQUATE_SPACE);
local_num = *num_vals;
ret = ORTE_ERR_UNPACK_INADEQUATE_SPACE;
} else if (local_num < *num_vals) { /** more than enough storage */
} else { /** enough or more than enough storage */
*num_vals = local_num; /** let the user know how many we actually unpacked */
ret = ORTE_SUCCESS;
}
/** Unpack the value(s) */
if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, dst, &local_num, type))) {
ORTE_ERROR_LOG(rc);
*num_vals = 0;
ret = rc;
}
if (ORTE_SUCCESS != ret) {
return ret;
}
return rc;
return ret;
}
int orte_dss_unpack_buffer(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *num_vals,
@ -138,9 +133,7 @@ int orte_dss_unpack_buffer(orte_buffer_t *buffer, void *dst, orte_std_cntr_t *nu
return ORTE_ERR_UNPACK_FAILURE;
}
if (ORTE_SUCCESS != (rc = info->odti_unpack_fn(buffer, dst, num_vals, type))) {
ORTE_ERROR_LOG(rc);
}
rc = info->odti_unpack_fn(buffer, dst, num_vals, type);
return rc;
}
@ -184,9 +177,7 @@ int orte_dss_unpack_bool(orte_buffer_t *buffer, void *dest,
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_BOOL))) {
ORTE_ERROR_LOG(ret);
}
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_BOOL);
return ret;
}
@ -227,9 +218,7 @@ int orte_dss_unpack_int(orte_buffer_t *buffer, void *dest,
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_INT))) {
ORTE_ERROR_LOG(ret);
}
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_INT);
return ret;
}
@ -270,9 +259,7 @@ int orte_dss_unpack_sizet(orte_buffer_t *buffer, void *dest,
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(ret);
}
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_SIZE_T);
return ret;
}
@ -313,9 +300,7 @@ int orte_dss_unpack_pid(orte_buffer_t *buffer, void *dest,
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_PID_T))) {
ORTE_ERROR_LOG(ret);
}
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_PID_T);
return ret;
}
@ -332,7 +317,6 @@ int orte_dss_unpack_null(orte_buffer_t *buffer, void *dest,
OPAL_OUTPUT( ( orte_dss_verbose, "orte_dss_unpack_null * %d\n", (int)*num_vals ) );
/* check to see if there's enough data in buffer */
if (orte_dss_too_small(buffer, *num_vals)) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -354,7 +338,6 @@ int orte_dss_unpack_byte(orte_buffer_t *buffer, void *dest,
OPAL_OUTPUT( ( orte_dss_verbose, "orte_dss_unpack_byte * %d\n", (int)*num_vals ) );
/* check to see if there's enough data in buffer */
if (orte_dss_too_small(buffer, *num_vals)) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -376,7 +359,6 @@ int orte_dss_unpack_int16(orte_buffer_t *buffer, void *dest,
OPAL_OUTPUT( ( orte_dss_verbose, "orte_dss_unpack_int16 * %d\n", (int)*num_vals ) );
/* check to see if there's enough data in buffer */
if (orte_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -399,7 +381,6 @@ int orte_dss_unpack_int32(orte_buffer_t *buffer, void *dest,
OPAL_OUTPUT( ( orte_dss_verbose, "orte_dss_unpack_int32 * %d\n", (int)*num_vals ) );
/* check to see if there's enough data in buffer */
if (orte_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -422,7 +403,6 @@ int orte_dss_unpack_int64(orte_buffer_t *buffer, void *dest,
OPAL_OUTPUT( ( orte_dss_verbose, "orte_dss_unpack_int64 * %d\n", (int)*num_vals ) );
/* check to see if there's enough data in buffer */
if (orte_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) {
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER);
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
}
@ -445,7 +425,6 @@ int orte_dss_unpack_string(orte_buffer_t *buffer, void *dest,
for (i = 0; i < (*num_vals); ++i) {
if (ORTE_SUCCESS != (ret = orte_dss_unpack_std_cntr(buffer, &len, &n, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (0 == len) { /* zero-length string - unpack the NULL */
@ -457,7 +436,6 @@ int orte_dss_unpack_string(orte_buffer_t *buffer, void *dest,
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (ret = orte_dss_unpack_byte(buffer, sdest[i], &len, ORTE_BYTE))) {
ORTE_ERROR_LOG(ret);
return ret;
}
}
@ -476,38 +454,9 @@ int orte_dss_unpack_std_cntr(orte_buffer_t *buffer, void *dest, orte_std_cntr_t
orte_data_type_t type)
{
int ret;
orte_data_type_t remote_type;
/* if the buffer is fully described, then we can do some magic to handle
* the heterogeneous case. if not, then we can only shoot blind - it is the
* user's responsibility to ensure we are in a homogeneous environment.
*/
if (ORTE_DSS_BUFFER_FULLY_DESC == buffer->type) {
/* see what type was actually packed */
if (ORTE_SUCCESS != (ret = orte_dss_peek_type(buffer, &remote_type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (remote_type == ORTE_STD_CNTR_T) {
/* fast path it if the sizes are the same */
/* Turn around and unpack the real type */
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_STD_CNTR_T))) {
ORTE_ERROR_LOG(ret);
}
} else {
/* slow path - types are different sizes */
UNPACK_SIZE_MISMATCH(orte_std_cntr_t, remote_type, ret);
}
return ret;
}
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_STD_CNTR_T))) {
ORTE_ERROR_LOG(ret);
}
/* turn around and unpack the real type */
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_STD_CNTR_T);
return ret;
}
@ -519,38 +468,9 @@ int orte_dss_unpack_data_type(orte_buffer_t *buffer, void *dest, orte_std_cntr_t
orte_data_type_t type)
{
int ret;
orte_data_type_t remote_type;
/* if the buffer is fully described, then we can do some magic to handle
* the heterogeneous case. if not, then we can only shoot blind - it is the
* user's responsibility to ensure we are in a homogeneous environment.
*/
if (ORTE_DSS_BUFFER_FULLY_DESC == buffer->type) {
/* see what type was actually packed */
if (ORTE_SUCCESS != (ret = orte_dss_peek_type(buffer, &remote_type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (remote_type == ORTE_DATA_TYPE_T) {
/* fast path it if the sizes are the same */
/* Turn around and unpack the real type */
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DATA_TYPE_T))) {
ORTE_ERROR_LOG(ret);
}
} else {
/* slow path - types are different sizes */
UNPACK_SIZE_MISMATCH(orte_data_type_t, remote_type, ret);
}
return ret;
}
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DATA_TYPE_T))) {
ORTE_ERROR_LOG(ret);
}
/* turn around and unpack the real type */
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DATA_TYPE_T);
return ret;
}
@ -564,24 +484,33 @@ int orte_dss_unpack_data_value(orte_buffer_t *buffer, void *dest, orte_std_cntr_
orte_dss_type_info_t *info;
orte_data_value_t **ddv;
orte_std_cntr_t i, n;
orte_data_type_t dt;
size_t nsize;
int ret;
ddv = (orte_data_value_t **) dest;
for (i = 0; i < *num; ++i) {
/* see what the data type is */
n = 1;
if (ORTE_SUCCESS != (ret = orte_dss_get_data_type(buffer, &dt))) {
return ret;
}
/* if it is ORTE_NULL, then do nothing */
if (ORTE_NULL == dt) continue;
/* otherwise, allocate the new object and set the type */
ddv[i] = OBJ_NEW(orte_data_value_t);
if (NULL == ddv[i]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
ddv[i]->type = dt;
/* see what the data type is */
n = 1;
if (ORTE_SUCCESS != (ret = orte_dss_get_data_type(buffer, &(ddv[i]->type)))) {
ORTE_ERROR_LOG(ret);
return ret;
}
/* if it is UNDEF, then nothing more to do */
if (ORTE_UNDEF == ddv[i]->type) continue;
/* get enough memory to hold it */
if (ORTE_SUCCESS != (ret = orte_dss.size(&nsize, NULL, ddv[i]->type))) {
@ -604,13 +533,11 @@ int orte_dss_unpack_data_value(orte_buffer_t *buffer, void *dest, orte_std_cntr_
if (info->odti_structured) {
n=1;
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, &(ddv[i]->data), &n, ddv[i]->type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
} else {
n=1;
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, ddv[i]->data, &n, ddv[i]->type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
}
@ -642,7 +569,6 @@ int orte_dss_unpack_byte_object(orte_buffer_t *buffer, void *dest, orte_std_cntr
/* unpack object size in bytes */
if (ORTE_SUCCESS != (ret = orte_dss_unpack_std_cntr(buffer, &(dbyteptr[i]->size), &m, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (0 < dbyteptr[i]->size) {
@ -653,7 +579,6 @@ int orte_dss_unpack_byte_object(orte_buffer_t *buffer, void *dest, orte_std_cntr
}
if (ORTE_SUCCESS != (ret = orte_dss_unpack_byte(buffer, (dbyteptr[i]->bytes),
&(dbyteptr[i]->size), ORTE_BYTE))) {
ORTE_ERROR_LOG(ret);
return ret;
}
}

Просмотреть файл

@ -175,17 +175,10 @@ int orte_gpr_base_pack_keyval(orte_buffer_t *buffer, void *src,
return rc;
}
/* if there is a data value, then pack it */
if (NULL != keyval[i]->value) {
if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(keyval[i]->value), 1, ORTE_DATA_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} else { /* otherwise, pack a NULL so we know not to unpack one */
if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &null, 1, ORTE_NULL))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the data value */
if (ORTE_SUCCESS != (rc = orte_dss_pack_buffer(buffer, &(keyval[i]->value), 1, ORTE_DATA_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}

Просмотреть файл

@ -157,9 +157,7 @@ int orte_gpr_base_unpack_keyval(orte_buffer_t *buffer, void *dest,
{
int rc;
orte_gpr_keyval_t **keyval;
orte_std_cntr_t i, max_n=1;
orte_data_type_t dt;
char null;
orte_std_cntr_t i, max_n;
OPAL_TRACE(4);
@ -174,30 +172,20 @@ int orte_gpr_base_unpack_keyval(orte_buffer_t *buffer, void *dest,
}
/* unpack the key */
max_n=1;
if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &(keyval[i]->key),
&max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* check to see if a NULL is the next item - if so, then there is no data value */
if (ORTE_SUCCESS != (rc = orte_dss_peek_type(buffer, &dt))) {
/* unpack the data value */
max_n=1;
if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &(keyval[i]->value),
&max_n, ORTE_DATA_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_NULL == dt) { /* NULL is stored - unpack it and move on */
if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &null, &max_n, ORTE_NULL))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} else {/* unpack the data value */
max_n = 1;
if (ORTE_SUCCESS != (rc = orte_dss_unpack_buffer(buffer, &(keyval[i]->value),
&max_n, ORTE_DATA_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;

Просмотреть файл

@ -140,7 +140,7 @@ int orte_gpr_base_pack_index(orte_buffer_t *cmd, char *segment)
/* it's okay to pack a NULL string, so pack the segment regardless */
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &segment, 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
ORTE_ERROR_LOG(rc);
return rc;
}

Просмотреть файл

@ -52,10 +52,19 @@ int orte_gpr_base_pack_put(orte_buffer_t *cmd,
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, values, cnt, ORTE_GPR_VALUE))) {
/* pack the number of values */
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &cnt, 1, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the values, if any */
if (0 < cnt) {
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, values, cnt, ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
return ORTE_SUCCESS;
}

Просмотреть файл

@ -61,33 +61,28 @@ int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
return rc;
}
/* see if there are subscriptions - if so, pack them */
if (NULL != subscriptions) {
/* pack the nummber of subscriptions - if there are any, pack them */
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &num_subs, 1, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (0 < num_subs) {
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, subscriptions, num_subs, ORTE_GPR_SUBSCRIPTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} else {
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &zero, 1, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
/* the API DOES allow there to be no triggers - if that happens, then trigs will be NULL and num_trigs
* should be set to zero. we can't send that to the DPS though as it is an error condition over there,
* so check for it here and record a "zero" if nothing is there
*/
if (NULL != trigs && 0 < num_trigs) {
/* pack the nummber of triggers - if there are any, pack them */
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &num_trigs, 1, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (0 < num_trigs) {
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, trigs, num_trigs, ORTE_GPR_TRIGGER))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} else {
if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &zero, 1, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
return ORTE_SUCCESS;

Просмотреть файл

@ -39,16 +39,9 @@ int orte_gpr_base_print_dump(orte_buffer_t *buffer)
{
char *line;
orte_std_cntr_t n;
orte_data_type_t type;
int rc;
n = 1;
while (ORTE_SUCCESS == orte_dss.peek(buffer, &type, &n)) {
if (ORTE_SUCCESS !=
(rc = orte_dss.unpack(buffer, &line, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
while (ORTE_SUCCESS == orte_dss.unpack(buffer, &line, &n, ORTE_STRING)) {
opal_output(orte_gpr_base_output, "%s", line);
free(line);
n=1;

Просмотреть файл

@ -116,16 +116,6 @@ int orte_gpr_base_unpack_index(orte_buffer_t *buffer, int *ret, orte_std_cntr_t
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dss.peek(buffer, &type, &n))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_STRING != type) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
if (0 < n) {
*index = (char **)malloc(n*sizeof(char*));
if (NULL == *index) {

Просмотреть файл

@ -1,26 +1,26 @@
/* -*- C -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI General Purpose Registry - Replica component
*
*/
*
* The Open MPI General Purpose Registry - Replica component
*
*/
/*
* includes
@ -35,20 +35,19 @@
#include "orte/mca/gpr/replica/communications/gpr_replica_comm.h"
/*
* handle message from proxies
* handle message from proxies
*/
int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
orte_process_name_t *sender,
orte_buffer_t **output_buffer)
orte_process_name_t *sender,
orte_buffer_t **output_buffer)
{
orte_buffer_t *answer;
orte_gpr_cmd_flag_t command;
int rc, ret, rc2;
orte_std_cntr_t n, num_vals;
orte_std_cntr_t n;
bool compound_cmd=false;
orte_data_type_t type;
OPAL_TRACE(3);
*output_buffer = OBJ_NEW(orte_buffer_t);
@ -61,324 +60,307 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
n = 1;
rc = ORTE_SUCCESS;
ret = ORTE_SUCCESS;
while (ORTE_SUCCESS == orte_dss.peek(input_buffer, &type, &num_vals)) {
if (ORTE_SUCCESS !=
orte_dss.unpack(input_buffer, &command, &n, ORTE_GPR_CMD)) {
break;
while (ORTE_SUCCESS == (rc = orte_dss.unpack(input_buffer, &command, &n, ORTE_GPR_CMD))) {
switch(command) {
case ORTE_GPR_COMPOUND_CMD: /***** COMPOUND COMMAND ******/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcompound cmd");
}
switch(command) {
case ORTE_GPR_COMPOUND_CMD: /***** COMPOUND COMMAND ******/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcompound cmd");
}
compound_cmd = true;
break;
compound_cmd = true;
break;
case ORTE_GPR_DELETE_SEGMENT_CMD: /****** DELETE SEGMENT *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdelete segment cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_delete_segment_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_PUT_CMD: /***** PUT *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tput cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_put_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_GET_CMD: /***** GET *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tget cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_get_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_GET_CONDITIONAL_CMD: /***** GET_CONDITIONAL *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tget conditional cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_get_conditional_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DELETE_ENTRIES_CMD: /***** DELETE ENTRIES *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdelete object cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_delete_entries_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_INDEX_CMD: /***** INDEX *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tindex cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_index_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_SUBSCRIBE_CMD: /***** SUBSCRIBE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tsubscribe cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_subscribe_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_UNSUBSCRIBE_CMD: /***** UNSUBSCRIBE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tunsubscribe cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_unsubscribe_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CANCEL_TRIGGER_CMD: /***** CANCEL_TRIGGER *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcancel trigger cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cancel_trigger_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DELETE_SEGMENT_CMD: /****** DELETE SEGMENT *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdelete segment cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_delete_segment_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_ALL_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump all cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_all_cmd(answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SEGMENTS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump segments cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segments_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_TRIGGERS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump triggers cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_triggers_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump subscriptions cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_subscriptions_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_A_TRIGGER_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a trigger cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_trigger_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a subscription cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_subscription_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_CALLBACKS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump callbacks cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_callbacks_cmd(answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SEGMENT_SIZE_CMD: /***** DUMP *****/
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segment_size_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_INCREMENT_VALUE_CMD: /***** INCREMENT_VALUE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tincrement_value cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_increment_value_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DECREMENT_VALUE_CMD: /***** DECREMENT_VALUE ******/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdecrement_value cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_decrement_value_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CLEANUP_JOB_CMD: /***** CLEANUP JOB *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcleanup job cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cleanup_job_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CLEANUP_PROC_CMD: /***** CLEANUP PROCESS *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcleanup proc cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cleanup_proc_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
default: /**** UNRECOGNIZED COMMAND ****/
case ORTE_GPR_PUT_CMD: /***** PUT *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tput cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_put_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_GET_CMD: /***** GET *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tget cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_get_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_GET_CONDITIONAL_CMD: /***** GET_CONDITIONAL *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tget conditional cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_get_conditional_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DELETE_ENTRIES_CMD: /***** DELETE ENTRIES *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdelete object cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_delete_entries_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_INDEX_CMD: /***** INDEX *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tindex cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_index_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_SUBSCRIBE_CMD: /***** SUBSCRIBE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tsubscribe cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_subscribe_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_UNSUBSCRIBE_CMD: /***** UNSUBSCRIBE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tunsubscribe cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_unsubscribe_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CANCEL_TRIGGER_CMD: /***** CANCEL_TRIGGER *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcancel trigger cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cancel_trigger_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_ALL_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump all cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_all_cmd(answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SEGMENTS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump segments cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segments_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_TRIGGERS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump triggers cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_triggers_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump subscriptions cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_subscriptions_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_A_TRIGGER_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a trigger cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_trigger_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a subscription cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_subscription_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_CALLBACKS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump callbacks cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_callbacks_cmd(answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_SEGMENT_SIZE_CMD: /***** DUMP *****/
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segment_size_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_INCREMENT_VALUE_CMD: /***** INCREMENT_VALUE *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tincrement_value cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_increment_value_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DECREMENT_VALUE_CMD: /***** DECREMENT_VALUE ******/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdecrement_value cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_decrement_value_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CLEANUP_JOB_CMD: /***** CLEANUP JOB *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcleanup job cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cleanup_job_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_CLEANUP_PROC_CMD: /***** CLEANUP PROCESS *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tcleanup proc cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cleanup_proc_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
default: /**** UNRECOGNIZED COMMAND ****/
command = ORTE_GPR_ERROR;
if (ORTE_SUCCESS != (rc = orte_dss.pack(answer, (void*)&command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
} /* end switch command */
n = 1; /* unpack a single command */
} /* end while */
if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != rc) {
ORTE_ERROR_LOG(rc);
}
/* deal with compound cmds to ensure proper return values */
if (compound_cmd) {
OBJ_RELEASE(answer);
@ -414,7 +396,7 @@ RETURN_ERROR:
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc2 = orte_dss.pack(answer, (void*)&command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc2);
ORTE_ERROR_LOG(rc2);
}
if (ORTE_SUCCESS != ret) {
orte_dss.pack(answer, &ret, 1, ORTE_INT);

Просмотреть файл

@ -225,23 +225,16 @@ int orte_gpr_replica_recv_index_cmd(orte_buffer_t *buffer,
return rc;
}
if (ORTE_SUCCESS != (ret = orte_dss.peek(buffer, &type, &n))) {
n = 1;
if (ORTE_SUCCESS != (ret = orte_dss.unpack(buffer, &segment, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
if (ORTE_STRING != type) { /* get index of segment names */
seg = NULL;
} else {
if (ORTE_SUCCESS != (ret = orte_dss.unpack(buffer, &segment, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
/* locate the segment */
if (ORTE_SUCCESS != (ret = orte_gpr_replica_find_seg(&seg, false, segment))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
/* locate the segment */
if (ORTE_SUCCESS != (ret = orte_gpr_replica_find_seg(&seg, false, segment))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_index_fn(seg, &cnt, &index))) {

Просмотреть файл

@ -40,9 +40,8 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
orte_gpr_value_t **values = NULL, *val;
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_itag_t *itags=NULL;
orte_data_type_t type;
int rc, ret;
orte_std_cntr_t i=0, cnt;
orte_std_cntr_t i=0, cnt, num_values;
OPAL_TRACE(3);
@ -52,25 +51,21 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
}
cnt = 1;
if (ORTE_SUCCESS != (rc = orte_dss.peek(buffer, &type, &cnt))) {
if (ORTE_SUCCESS != (rc = orte_dss.unpack(buffer, &num_values, &cnt, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
free(values);
ret = rc;
goto RETURN_ERROR;
}
if (ORTE_GPR_VALUE != type || 0 >= cnt) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
ret = ORTE_ERR_BAD_PARAM;
goto RETURN_ERROR;
}
values = (orte_gpr_value_t**)malloc(cnt * sizeof(orte_gpr_value_t*));
values = (orte_gpr_value_t**)malloc(num_values * sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
ret = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR;
}
cnt = num_values;
if (ORTE_SUCCESS != (rc = orte_dss.unpack(buffer, values, &cnt, ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
free(values);

Просмотреть файл

@ -40,7 +40,6 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
orte_buffer_t *output_buffer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_SUBSCRIBE_CMD;
orte_data_type_t type;
int rc, ret;
orte_std_cntr_t n, num_subs, num_trigs;
orte_gpr_trigger_t **trigs=NULL;
@ -53,105 +52,52 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dss.peek(input_buffer, &type, &n))) {
/* get the number of subscriptions */
n=1;
if (ORTE_SUCCESS != (rc = orte_dss.unpack(input_buffer, &num_subs, &n, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* if the original command did not provide any subscriptions, then we put a orte_std_cntr_t value in the buffer of "zero"
* to avoid causing buffer problems. thus, we need to check to see if the type is orte_std_cntr_t vs subscription vs
* something else. if it is trigger, then we need the number to be greater than 0, which should always
* be true (we check it just to be safe). if it is orte_std_cntr_t, then the value should be zero - anything else
* generates an error.
*/
if (ORTE_STD_CNTR == type) {
/* this case means that there were no subscriptions, so we need to clear the value from the buffer
* and continue on
*/
n=1;
if (ORTE_SUCCESS != orte_dss.unpack(input_buffer, &num_subs, &n, ORTE_STD_CNTR)) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* if the returned number of subscriptions isn't zero, then we have a problem */
if (0 != num_subs) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
rc = ORTE_ERR_COMM_FAILURE;
goto RETURN_ERROR;
}
} else if (ORTE_GPR_SUBSCRIPTION == type && 0 < n) {
/* create the space for the subscriptions */
subscriptions = (orte_gpr_subscription_t**)malloc(n * sizeof(orte_gpr_subscription_t*));
/* create the space for the subscriptions, if any are there - and unpack them */
if (0 < num_subs) {
subscriptions = (orte_gpr_subscription_t**)malloc(num_subs * sizeof(orte_gpr_subscription_t*));
if (NULL == subscriptions) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR;
}
n = num_subs;
if (ORTE_SUCCESS != (rc = orte_dss.unpack(input_buffer, subscriptions, &n, ORTE_GPR_SUBSCRIPTION))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
num_subs = n;
} else {
/* we must have an error condition - it either wasn't the right type, or we had the type okay
* but don't have a good number of elements. report the error and move on
*/
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
rc = ORTE_ERR_COMM_FAILURE;
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (rc = orte_dss.peek(input_buffer, &type, &n))) {
/* get the number of triggers */
n=1;
if (ORTE_SUCCESS != (rc = orte_dss.unpack(input_buffer, &num_trigs, &n, ORTE_STD_CNTR))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* if the original command did not provide any triggers, then we put a orte_std_cntr_t value in the buffer of "zero"
* to avoid causing buffer problems. thus, we need to check to see if the type is orte_std_cntr_t vs trigger vs
* something else. if it is trigger, then we need the number to be greater than 0, which should always
* be true (we check it just to be safe). if it is orte_std_cntr_t, then the value should be zero - anything else
* generates an error.
*/
if (ORTE_STD_CNTR == type) {
/* this case means that there were no triggers, so we need to clear the value from the buffer
* and continue on
*/
n=1;
if (ORTE_SUCCESS != orte_dss.unpack(input_buffer, &num_trigs, &n, ORTE_STD_CNTR)) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* if the returned number of triggers isn't zero, then we have a problem */
if (0 != num_trigs) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
rc = ORTE_ERR_COMM_FAILURE;
goto RETURN_ERROR;
}
} else if (ORTE_GPR_TRIGGER == type && 0 < n) {
/* create the space for the triggers */
trigs = (orte_gpr_trigger_t**)malloc(n * sizeof(orte_gpr_trigger_t*));
/* create the space for the triggers, if any are there - and unpack them */
if (0 < num_trigs) {
trigs = (orte_gpr_trigger_t**)malloc(num_trigs * sizeof(orte_gpr_trigger_t*));
if (NULL == trigs) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR;
}
n = num_trigs;
if (ORTE_SUCCESS != orte_dss.unpack(input_buffer, trigs, &n, ORTE_GPR_TRIGGER)) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
num_trigs = n;
} else {
/* we must have an error condition - it either wasn't the right type, or we had the type okay
* but don't have a good number of elements. report the error and move on
*/
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
rc = ORTE_ERR_COMM_FAILURE;
goto RETURN_ERROR;
}
/* register subscriptions */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(sender,
num_subs, subscriptions,

Просмотреть файл

@ -78,16 +78,9 @@ int orte_ns_base_print_dump(orte_buffer_t *buffer)
{
char *line;
orte_std_cntr_t n;
orte_data_type_t type;
int rc;
n = 1;
while (ORTE_SUCCESS == orte_dss.peek(buffer, &type, &n)) {
if (ORTE_SUCCESS !=
(rc = orte_dss.unpack(buffer, &line, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
while (ORTE_SUCCESS == orte_dss.unpack(buffer, &line, &n, ORTE_STRING)) {
opal_output(mca_ns_base_output, "%s", line);
free(line);
n=1;

Просмотреть файл

@ -32,38 +32,9 @@ int orte_odls_unpack_daemon_cmd(orte_buffer_t *buffer, void *dest, orte_std_cntr
orte_data_type_t type)
{
int ret;
orte_data_type_t remote_type;
/* if the buffer is fully described, then we can do some magic to handle
* the heterogeneous case. if not, then we can only shoot blind - it is the
* user's responsibility to ensure we are in a homogeneous environment.
*/
if (ORTE_DSS_BUFFER_FULLY_DESC == buffer->type) {
/* see what type was actually packed */
if (ORTE_SUCCESS != (ret = orte_dss_peek_type(buffer, &remote_type))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (remote_type == ORTE_DAEMON_CMD_T) {
/* fast path it if the sizes are the same */
/* Turn around and unpack the real type */
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DAEMON_CMD_T))) {
ORTE_ERROR_LOG(ret);
}
} else {
/* slow path - types are different sizes */
UNPACK_SIZE_MISMATCH(orte_daemon_cmd_flag_t, remote_type, ret);
}
return ret;
}
/* if we get here, then this buffer is NOT fully described. just unpack it
* using the local size - user gets the pain if it's wrong
*/
if (ORTE_SUCCESS != (ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DAEMON_CMD_T))) {
ORTE_ERROR_LOG(ret);
}
/* turn around and unpack the real type */
ret = orte_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DAEMON_CMD_T);
return ret;
}

Просмотреть файл

@ -47,6 +47,8 @@ extern "C" {
* global flag for use in timing tests
*/
ORTE_DECLSPEC extern bool orte_oob_base_timing;
ORTE_DECLSPEC extern bool orte_oob_xcast_timing;
ORTE_DECLSPEC extern int orte_oob_xcast_mode;
/*
* OOB API

Просмотреть файл

@ -44,7 +44,9 @@ char* mca_oob_base_exclude = NULL;
opal_list_t mca_oob_base_components;
opal_list_t mca_oob_base_modules;
opal_list_t mca_oob_base_exception_handlers;
bool orte_oob_base_timing = false;
bool orte_oob_base_timing;
bool orte_oob_xcast_timing;
int orte_oob_xcast_mode;
/**
* Function for finding and opening either all MCA components, or the one
@ -53,6 +55,7 @@ bool orte_oob_base_timing = false;
int mca_oob_base_open(void)
{
int param, value;
char *mode;
/* Open up all available components */
@ -84,6 +87,27 @@ int mca_oob_base_open(void)
orte_oob_base_timing = false;
}
param = mca_base_param_reg_int_name("oob_xcast", "timing",
"Request that xcast timing loops be measured",
false, false, 0, &value);
if (value != 0) {
orte_oob_xcast_timing = true;
} else {
orte_oob_xcast_timing = false;
}
param = mca_base_param_reg_string_name("oob_xcast", "mode",
"Select xcast mode (\"linear\" [default] | \"binomial\")",
false, false, "linear", &mode);
if (0 == strcmp(mode, "linear")) {
orte_oob_xcast_mode = 1;
} else if (0 != strcmp(mode, "binomial")) {
opal_output(0, "oob_xcast_mode: unknown option %s", mode);
return ORTE_ERROR;
} else {
orte_oob_xcast_mode = 0;
}
/* All done */
return ORTE_SUCCESS;
}

Просмотреть файл

@ -30,13 +30,14 @@
#include "orte/util/proc_info.h"
#include "orte/dss/dss.h"
#include "orte/mca/oob/oob.h"
#include "orte/mca/oob/base/base.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/rmgr/rmgr.h"
#include "orte/mca/smr/smr.h"
#include "orte/runtime/runtime.h"
#include "orte/mca/oob/oob.h"
#include "orte/mca/oob/base/base.h"
/**
* A "broadcast-like" function to a job's processes.
@ -50,10 +51,55 @@ static opal_mutex_t xcastmutex;
static int xcast_bitmap, bitmap_save;
static bool bitmap_init = false;
static int mca_oob_xcast_binomial_tree(orte_jobid_t job,
bool process_first,
orte_buffer_t* buffer,
orte_gpr_trigger_cb_fn_t cbfunc);
static int mca_oob_xcast_linear(orte_jobid_t job,
bool process_first,
orte_buffer_t* buffer,
orte_gpr_trigger_cb_fn_t cbfunc);
int mca_oob_xcast(orte_jobid_t job,
bool process_first,
orte_buffer_t* buffer,
orte_gpr_trigger_cb_fn_t cbfunc)
{
int rc;
struct timeval start, stop;
if (orte_oob_xcast_timing) {
if (NULL != buffer) {
opal_output(0, "xcast [%ld,%ld,%ld]: buffer size %lu", ORTE_NAME_ARGS(ORTE_PROC_MY_NAME),
(unsigned long)buffer->bytes_used);
}
gettimeofday(&start, NULL);
}
switch(orte_oob_xcast_mode) {
case 0: /* binomial tree */
rc = mca_oob_xcast_binomial_tree(job, process_first, buffer, cbfunc);
break;
case 1: /* linear */
rc = mca_oob_xcast_linear(job, process_first, buffer, cbfunc);
break;
}
if (orte_oob_xcast_timing) {
gettimeofday(&stop, NULL);
opal_output(0, "xcast [%ld,%ld,%ld]: mode %s time %ld usec", ORTE_NAME_ARGS(ORTE_PROC_MY_NAME),
orte_oob_xcast_mode ? "linear" : "binomial",
(long int)((stop.tv_sec - start.tv_sec)*1000000 +
(stop.tv_usec - start.tv_usec)));
}
return rc;
}
static int mca_oob_xcast_binomial_tree(orte_jobid_t job,
bool process_first,
orte_buffer_t* buffer,
orte_gpr_trigger_cb_fn_t cbfunc)
{
orte_std_cntr_t i;
int rc;
@ -173,4 +219,97 @@ int mca_oob_xcast(orte_jobid_t job,
return ORTE_SUCCESS;
}
static int mca_oob_xcast_linear(orte_jobid_t job,
bool process_first,
orte_buffer_t* buffer,
orte_gpr_trigger_cb_fn_t cbfunc)
{
orte_std_cntr_t i;
int rc;
int tag = ORTE_RML_TAG_XCAST;
int status;
orte_process_name_t *peers=NULL;
orte_std_cntr_t n=0;
orte_proc_state_t state;
opal_list_t attrs;
opal_list_item_t *item;
/* check to see if there is something to send - this is only true on the HNP end.
* However, we cannot just test to see if we are the HNP since, if we are a singleton,
* we are the HNP *and* we still need to handle both ends of the xcast
*/
if (NULL != buffer) {
OBJ_CONSTRUCT(&xcastmutex, opal_mutex_t);
OPAL_THREAD_LOCK(&xcastmutex);
/* this is the HNP end, so it does all the sends in this algorithm. First, we need
* to get the job peers so we know who to send the message to
*/
OBJ_CONSTRUCT(&attrs, opal_list_t);
orte_rmgr.add_attribute(&attrs, ORTE_NS_USE_JOBID, ORTE_JOBID, &job, ORTE_RMGR_ATTR_OVERRIDE);
if (ORTE_SUCCESS != (rc = orte_ns.get_peers(&peers, &n, &attrs))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&xcastmutex);
OBJ_DESTRUCT(&xcastmutex);
return rc;
}
item = opal_list_remove_first(&attrs);
OBJ_RELEASE(item);
OBJ_DESTRUCT(&attrs);
for(i=0; i<n; i++) {
/* check status of peer to ensure they are alive */
if (ORTE_SUCCESS != (rc = orte_smr.get_proc_state(&state, &status, peers+i))) {
ORTE_ERROR_LOG(rc);
free(peers);
OPAL_THREAD_UNLOCK(&xcastmutex);
OBJ_DESTRUCT(&xcastmutex);
return rc;
}
if (state != ORTE_PROC_STATE_TERMINATED && state != ORTE_PROC_STATE_ABORTED) {
rc = mca_oob_send_packed(peers+i, buffer, tag, 0);
if (rc < 0) {
ORTE_ERROR_LOG(rc);
free(peers);
OPAL_THREAD_UNLOCK(&xcastmutex);
OBJ_DESTRUCT(&xcastmutex);
return rc;
}
}
}
free(peers);
OPAL_THREAD_UNLOCK(&xcastmutex);
OBJ_DESTRUCT(&xcastmutex);
return ORTE_SUCCESS;
/* if we are not the HNP, then we need to just receive the message and process it */
} else {
orte_buffer_t rbuf;
orte_gpr_notify_message_t *msg;
OBJ_CONSTRUCT(&rbuf, orte_buffer_t);
rc = mca_oob_recv_packed(ORTE_NAME_WILDCARD, &rbuf, tag);
if(rc < 0) {
OBJ_DESTRUCT(&rbuf);
return rc;
}
if (cbfunc != NULL) {
msg = OBJ_NEW(orte_gpr_notify_message_t);
if (NULL == msg) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
i=1;
if (ORTE_SUCCESS != (rc = orte_dss.unpack(&rbuf, &msg, &i, ORTE_GPR_NOTIFY_MSG))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(msg);
return rc;
}
cbfunc(msg);
OBJ_RELEASE(msg);
}
OBJ_DESTRUCT(&rbuf);
}
return ORTE_SUCCESS;
}

12
orte/test/unit/dss/Makefile Обычный файл
Просмотреть файл

@ -0,0 +1,12 @@
PROGS = dss_buffer dss_cmp dss_copy dss_inc_dec dss_print dss_release dss_set_get dss_size
all: $(PROGS)
CC = ortecc
CFLAGS = -g
CXX = ortec++
CXXFLAGS = -g
FFLAGS = -g
clean:
rm -f $(PROGS) *~ .gdb*

983
orte/test/unit/dss/dss_buffer.c Обычный файл
Просмотреть файл

@ -0,0 +1,983 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 100
#define NUM_ELEMS 1024
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify orte_std_cntr_t */
static bool test12(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
orte_init(true);
test_out = stderr;
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
static bool test1(void) /* verify different buffer inits */
{
orte_buffer_t *bufA;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/*
* OMPI_INT16 pack/unpack
*/
static bool test2(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
int16_t src[NUM_ELEMS];
int16_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
orte_dss.set_buffer_type(bufA, ORTE_DSS_BUFFER_NON_DESC);
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_INT16);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count;
for(j=0; j<NUM_ELEMS; j++)
dst[j] = -1;
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_INT16);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/*
* OMPI_INT pack/unpack
*/
static bool test3(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
int src[NUM_ELEMS];
int dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_INT);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count;
for(j=0; j<NUM_ELEMS; j++)
dst[j] = -1;
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_INT);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/*
* OMPI_INT32 pack/unpack
*/
static bool test4(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
int32_t src[NUM_ELEMS];
int32_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_INT32);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
for(j=0; j<NUM_ELEMS; j++)
dst[j] = -1;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_INT32);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/*
* ORTE_INT64 pack/unpack
*/
static bool test5(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i;
int64_t src[NUM_ELEMS];
int64_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = 1000*i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_INT64);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack int64 failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
for(j=0; j<NUM_ELEMS; j++)
dst[j] = -1;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_INT64);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack int64 failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack int64\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/*
* OMPI_STRING pack/unpack
*/
static bool test6(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
char* src[NUM_ELEMS];
char* dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
asprintf(&src[i], "%d", i);
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_STRING);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
for(j=0; j<NUM_ELEMS; j++)
dst[j] = NULL;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_STRING);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(strcmp(src[j],dst[j]) != 0) {
fprintf(test_out, "test4: invalid results from unpack\n");
fprintf(test_out, "item %d src=[%s] len=%d dst=[%s] len=%d\n", j, src[j], (int)strlen(src[j]), dst[j], (int)strlen(dst[j]));
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/**
* OMPI_BOOL pack/unpack
*/
static bool test7(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
bool src[NUM_ELEMS];
bool dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = ((i % 2) == 0) ? true : false;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_BOOL);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_BOOL);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test6: invalid results from unpack\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/**
* OMPI_BYTE_OBJECT pack/unpack
*/
static bool test8(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
orte_byte_object_t *src[NUM_ELEMS];
orte_byte_object_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = (orte_byte_object_t*)malloc(sizeof(orte_byte_object_t));
asprintf((char**)&(src[i]->bytes), "%d", i);
src[i]->size = strlen((char*)(src[i]->bytes)) + 1;
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_BYTE_OBJECT);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_BYTE_OBJECT);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j]->size != dst[j]->size ||
memcmp(src[j]->bytes,dst[j]->bytes,src[j]->size) != 0) {
fprintf(test_out, "test7: invalid results from unpack\n");
fprintf(test_out, "test7: object element %d has incorrect unpacked value\n", j);
return(false);
}
}
}
/* cleanup */
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/**
* ompi everything composite multipack/unpack
*/
static bool test9(void)
{
orte_buffer_t *bufA;
int rc;
int32_t i;
/* pack and unpack in this order */
/* each block now has an offset to make debugging easier.. first block=100, 200,... */
orte_byte_object_t *srco[NUM_ELEMS];
orte_byte_object_t *dsto[NUM_ELEMS];
char* srcs[NUM_ELEMS];
char* dsts[NUM_ELEMS];
bool srcb[NUM_ELEMS];
bool dstb[NUM_ELEMS];
int32_t src32[NUM_ELEMS];
int32_t dst32[NUM_ELEMS];
int16_t src16[NUM_ELEMS];
int16_t dst16[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
/* object offset 100 */
srco[i] = (orte_byte_object_t*)malloc(sizeof(orte_byte_object_t));
asprintf((char**)&(srco[i]->bytes), "%d", i+100);
srco[i]->size = strlen((char*)(srco[i]->bytes)) + 1;
/* strings +200 */
asprintf(&srcs[i], "%d", i+200);
/* bool */
srcb[i] = ((i % 2) == 0) ? true : false;
/* INT32 +300 */
src32[i] = i+300;
/* INT16 +400 */
src16[i] = i+400;
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
/* object first */
rc = orte_dss.pack(bufA, srco, NUM_ELEMS, ORTE_BYTE_OBJECT);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack on object failed with return code %d\n", rc);
return(false);
}
/* STRING */
rc = orte_dss.pack(bufA, srcs, NUM_ELEMS, ORTE_STRING);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack on string failed with return code %d\n", rc);
return(false);
}
/* BOOL */
rc = orte_dss.pack(bufA, srcb, NUM_ELEMS, ORTE_BOOL);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack on bool failed with return code %d\n", rc);
return(false);
}
/* INT32 */
rc = orte_dss.pack(bufA, src32, NUM_ELEMS, ORTE_INT32);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack on INT32 failed with return code %d\n", rc);
return(false);
}
/* INT16 */
rc = orte_dss.pack(bufA, src16, NUM_ELEMS, ORTE_INT16);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack on INT16 failed with return code %d\n", rc);
return(false);
}
}
/* fprintf(test_out,"test8:packed buffer info for STRING with %d iterations %d elements each\n", NUM_ITERS, NUM_ELEMS); */
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count;
/* string */
for(j=0; j<NUM_ELEMS; j++) dsts[j] = NULL;
/* bool */
memset(dstb,-1,sizeof(dstb));
/* int32 */
for(j=0; j<NUM_ELEMS; j++) dst32[j] = -1;
/* int16 */
for(j=0; j<NUM_ELEMS; j++) dst16[j] = -1;
/* object */
count=NUM_ELEMS;
rc = orte_dss.unpack(bufA, dsto, &count, ORTE_BYTE_OBJECT);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack on object failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(srco[j]->size != dsto[j]->size ||
memcmp(srco[j]->bytes,dsto[j]->bytes,srco[j]->size) != 0) {
fprintf(test_out, "test8: object element %d has incorrect unpacked value\n", j);
return(false);
}
}
/* string */
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dsts, &count, ORTE_STRING);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack on string failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(strcmp(srcs[j],dsts[j]) != 0) {
fprintf(test_out, "test8: invalid results from unpack\n");
fprintf(test_out, "item %d src=[%s] len=%d dst=[%s] len=%d\n", j, srcs[j], (int)strlen(srcs[j]), dsts[j], (int)strlen(dsts[j]));
return(false);
}
}
/* bool */
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dstb, &count, ORTE_BOOL);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack on bool failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(srcb[j] != dstb[j]) {
fprintf(test_out, "test8: invalid results from unpack\n");
return(false);
}
}
/* int32 */
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst32, &count, ORTE_INT32);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack on int32 failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src32[j] != dst32[j]) {
fprintf(test_out, "test8: invalid results from unpack\n");
return(false);
}
}
/* int16 */
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst16, &count, ORTE_INT16);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack on int16 failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src16[j] != dst16[j]) {
fprintf(test_out, "test8: invalid results from unpack\n");
return(false);
}
}
} /* per iteration */
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test10(void)
{
orte_buffer_t *bufA;
int rc;
int i;
int16_t i16[NUM_ELEMS];
orte_data_value_t *src[NUM_ELEMS];
orte_data_value_t *dst[NUM_ELEMS];
/* setup source array of data values */
for(i=0; i<NUM_ELEMS; i++) {
i16[i] = (int16_t)i;
src[i] = OBJ_NEW(orte_data_value_t);
src[i]->type = ((i % 2) == 0) ? ORTE_INT16 : ORTE_STRING;
if (ORTE_INT16 == src[i]->type)
src[i]->data = &i16[i];
else
src[i]->data = strdup("truly-a-dumb-test");
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_DATA_VALUE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with error code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_DATA_VALUE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out,
"orte_dss.unpack (DATA_VALUE) failed on iteration %d with error code %d\n",
i, rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if (src[j]->type != dst[j]->type) {
fprintf(test_out, "orte_dss.unpack (DATA_VALUE) invalid results type mismatch from unpack\n");
return(false);
}
if (0 != orte_dss.compare(src[j], dst[j], src[j]->type)) {
fprintf(test_out, "orte_dss.unpack (DATA_VALUE) invalid results value mismatch from unpack");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
/* orte_std_cntr_t */
static bool test11(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i;
orte_std_cntr_t src[NUM_ELEMS];
orte_std_cntr_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = 1000*i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_SIZE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack orte_std_cntr_t failed");
fprintf(test_out, "orte_pack_orte_std_cntr_t failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
orte_std_cntr_t j;
orte_std_cntr_t count;
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_SIZE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack orte_std_cntr_t failed");
fprintf(test_out, "orte_unpack_orte_std_cntr_t failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack orte_std_cntr_t");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return (true);
}
/*
* pid_t pack/unpack
*/
static bool test12(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i;
pid_t src[NUM_ELEMS];
pid_t dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++)
src[i] = (pid_t)i;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_PID);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_pack pid_t failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
orte_std_cntr_t j;
orte_std_cntr_t count;
count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_PID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_pack pid_t failed with return code %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(src[j] != dst[j]) {
fprintf(test_out, "test2: invalid results from unpack");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}

688
orte/test/unit/dss/dss_cmp.c Обычный файл
Просмотреть файл

@ -0,0 +1,688 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1, v2=100;
uint8_t u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1, v2=100;
uint16_t u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1, v2=100;
uint32_t u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1, v2=100;
uint64_t u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1, v2=100;
uint u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for signed value2 greater\n");
return(false);
}
u1 = u2;
if (ORTE_EQUAL != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned equality\n");
return(false);
}
u1 = u2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value1 greater\n");
return(false);
}
u1 = u2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.compare failed for unsigned value2 greater\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2="This is a longer string";
if (ORTE_EQUAL != orte_dss.compare(string1, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(string1, string2, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v1, v2=true;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = true;
v2 = false;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = false;
v2 = true;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1, v2=100;
orte_data_type_t type=ORTE_PID;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
v1 = v2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
v1 = v2 + 1;
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
v1 = v2 - 1;
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v1.size = 20;
v1.bytes = (uint8_t*)malloc(v1.size);
for (i=0; i<v1.size; i++) v1.bytes[i] = i;
v2.size = v1.size;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = v1.bytes[i];
v2.bytes[(v2.size)/2] += 1;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v2, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat1=100, dat2=200;
orte_data_value_t v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v1.type = ORTE_INT;
v1.data = &dat1;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_EQUAL != orte_dss.compare(&v1, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for equality\n");
return(false);
}
if (ORTE_VALUE1_GREATER != orte_dss.compare(&v2, &v1, type)) {
fprintf(test_out, "orte_dss.compare failed for value1 greater\n");
return(false);
}
if (ORTE_VALUE2_GREATER != orte_dss.compare(&v1, &v2, type)) {
fprintf(test_out, "orte_dss.compare failed for value2 greater\n");
return(false);
}
return (true);
}

530
orte/test/unit/dss/dss_copy.c Обычный файл
Просмотреть файл

@ -0,0 +1,530 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*u1 != u2) {
fprintf(test_out, "orte_dss.copy failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2;
if (ORTE_EQUAL != orte_dss.copy((void**)&string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.copy returned error code\n");
return(false);
}
if (0 != strcmp(string1, string2)) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (*v1 != v2) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t *v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i]=i;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (v1->size != v2.size) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
for (i=0; i < v2.size; i++) {
if (v1->bytes[i] != v2.bytes[i]) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t *v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy failed\n");
return(false);
}
return (true);
}

689
orte/test/unit/dss/dss_inc_dec.c Обычный файл
Просмотреть файл

@ -0,0 +1,689 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1, v2=100;
uint8_t u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1, v2=100;
uint16_t u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1, v2=100;
uint32_t u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1, v2=100;
uint64_t u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1, v2=100;
uint u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for signed value\n");
return(false);
}
dv.type = utype;
dv.data = &u2;
u1 = u2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (u2 != u1+1) {
fprintf(test_out, "orte_dss.increment failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (u2 != u1) {
fprintf(test_out, "orte_dss.decrement failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
orte_data_value_t dv;
dv.type = ORTE_STRING;
dv.data = string1;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v2=true;
orte_data_value_t dv;
dv.type = ORTE_BOOL;
dv.data = &v2;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for size value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1, v2=100;
orte_data_type_t type=ORTE_PID;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for pid value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for daemon cmd value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for daemon cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
orte_data_value_t dv;
dv.type = type;
dv.data = &v2;
v1 = v2;
if (ORTE_SUCCESS != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment returned error\n");
return(false);
}
if (v2 != v1+1) {
fprintf(test_out, "orte_dss.increment failed for data type value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.decrement(&dv)) {
fprintf(test_out, "orte_dss.decrement returned error\n");
return(false);
}
if (v2 != v1) {
fprintf(test_out, "orte_dss.decrement failed for data type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2;
orte_data_value_t dv;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
dv.type = ORTE_BYTE_OBJECT;
dv.data = &v2;
if (ORTE_ERR_OPERATION_UNSUPPORTED != orte_dss.increment(&dv)) {
fprintf(test_out, "orte_dss.increment failed to return correct error\n");
return(false);
}
return (true);
}

572
orte/test/unit/dss/dss_print.c Обычный файл
Просмотреть файл

@ -0,0 +1,572 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v2=-100;
uint8_t u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v2=-100;
uint16_t u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v2=-100;
uint32_t u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v2=-100;
uint64_t u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v2=-100;
uint u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for signed value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for signed value: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &u2, utype)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed for unsigned value\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for unsigned value: %s\n", output);
free(output);
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for string: %s\n", output);
free(output);
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v2=true;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for bool: %s\n", output);
free(output);
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v2=100;
orte_data_type_t type=ORTE_SIZE;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for size: %s\n", output);
free(output);
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v2=100;
orte_data_type_t type=ORTE_PID;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for pid: %s\n", output);
free(output);
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for daemon cmd: %s\n", output);
free(output);
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
char *output;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for data type: %s\n", output);
free(output);
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
char *output;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for byte object: %s\n", output);
free(output);
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t v2;
orte_data_type_t type=ORTE_DATA_VALUE;
char *output;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &v2, type)) {
fprintf(test_out, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(test_out, "orte_dss.print failed\n");
return(false);
}
fprintf(test_out, "orte_dss.print output for data value: %s\n", output);
free(output);
return (true);
}

582
orte/test/unit/dss/dss_release.c Обычный файл
Просмотреть файл

@ -0,0 +1,582 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
orte_data_value_t dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT8;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT8;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT16;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT16;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_INT32;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT32;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_UINT64;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&u1, &u2, utype)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = utype;
dval.data = u1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
char *string2;
if (ORTE_EQUAL != orte_dss.copy((void**)&string2, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.copy returned error code\n");
return(false);
}
dval.type = ORTE_STRING;
dval.data = string2;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for string value\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = ORTE_BOOL;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for bool value\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for daemon_cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for data_type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t *v1, v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i]= i;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for byte_object value\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t *v1, v2;
orte_data_type_t type=ORTE_DATA_VALUE;
v2.type = ORTE_INT;
v2.data = &dat2;
if (ORTE_SUCCESS != orte_dss.copy((void**)&v1, &v2, type)) {
fprintf(test_out, "orte_dss.copy returned error\n");
return(false);
}
dval.type = type;
dval.data = v1;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release failed for data_value value\n");
return(false);
}
return (true);
}

574
orte/test/unit/dss/dss_set_get.c Обычный файл
Просмотреть файл

@ -0,0 +1,574 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t *v1, v2=100;
uint8_t *u1, u2=150;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t *v1, v2=100;
uint16_t *u1, u2=150;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t *v1, v2=100;
uint32_t *u1, u2=150;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t *v1, v2=100;
uint64_t *u1, u2=150;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int *v1, v2=100;
uint *u1, u2=150;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
orte_data_value_t udv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.set(&udv, &u2, utype)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&u1, &udv, utype)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for unsigned value\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string", *string2;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&string2, &dv, ORTE_STRING)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (0 != strcmp(string1, string2)) {
fprintf(test_out, "orte_dss.get/set failed for string value\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool *v1, v2=true;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for bool value\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t *v1, v2=100;
orte_data_type_t type=ORTE_SIZE;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for size value\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t *v1, v2=100;
orte_data_type_t type=ORTE_PID;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for pid value\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t *v1, v2=100;
orte_data_type_t type=ORTE_DAEMON_CMD;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for daemon cmd value\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t *v1, v2=100;
orte_data_type_t type=ORTE_DATA_TYPE;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, type)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, type)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (v2 != *v1) {
fprintf(test_out, "orte_dss.get/set failed for data type value\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i;
orte_byte_object_t v2, *v1;
orte_data_value_t dv = {{OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF, NULL};
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
if (ORTE_SUCCESS != orte_dss.set(&dv, &v2, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.set returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.get((void**)&v1, &dv, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.get returned error\n");
return(false);
}
if (0 != orte_dss.compare(v1, &v2, ORTE_BYTE_OBJECT)) {
fprintf(test_out, "orte_dss.get/set failed for byte object value\n");
return(false);
}
return (true);
}

702
orte/test/unit/dss/dss_size.c Обычный файл
Просмотреть файл

@ -0,0 +1,702 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include "orte/orte_types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "opal/runtime/opal.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/dss/dss.h"
#define NUM_ITERS 3
#define NUM_ELEMS 10
static bool test1(void); /* verify different buffer inits */
static bool test2(void); /* verify int16 */
static bool test3(void); /* verify int */
static bool test4(void); /* verify int32 */
static bool test5(void); /* verify int64 */
static bool test6(void); /* verify string */
static bool test7(void); /* verify BOOL */
static bool test8(void); /* verify OBJECT */
static bool test9(void); /* verify composite (multiple types and element counts) */
static bool test10(void); /* verify KEYVAL */
static bool test11(void); /* verify size_t */
static bool test12(void); /* verify pid_t */
static bool test13(void); /* verify pid_t */
FILE *test_out;
int main (int argc, char* argv[])
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(test_out, "DSS started\n");
} else {
fprintf(test_out, "DSS could not start\n");
exit (1);
}
/* run the tests */
fprintf(test_out, "executing test1\n");
if (test1()) {
fprintf(test_out, "Test1 succeeded\n");
}
else {
fprintf(test_out, "Test1 failed\n");
}
fprintf(test_out, "executing test2\n");
if (test2()) {
fprintf(test_out, "Test2 succeeded\n");
}
else {
fprintf(test_out, "Test2 failed\n");
}
fprintf(test_out, "executing test3\n");
if (test3()) {
fprintf(test_out, "Test3 succeeded\n");
}
else {
fprintf(test_out, "Test3 failed\n");
}
fprintf(test_out, "executing test4\n");
if (test4()) {
fprintf(test_out, "Test4 succeeded\n");
}
else {
fprintf(test_out, "Test4 failed\n");
}
fprintf(test_out, "executing test5\n");
if (test5()) {
fprintf(test_out, "Test5 succeeded\n");
}
else {
fprintf(test_out, "Test5 failed\n");
}
fprintf(test_out, "executing test6\n");
if (test6()) {
fprintf(test_out, "Test6 succeeded\n");
}
else {
fprintf(test_out, "Test6 failed\n");
}
fprintf(test_out, "executing test7\n");
if (test7()) {
fprintf(test_out, "Test7 succeeded\n");
}
else {
fprintf(test_out, "Test7 failed\n");
}
fprintf(test_out, "executing test8\n");
if (test8()) {
fprintf(test_out, "Test8 succeeded\n");
}
else {
fprintf(test_out, "Test8 failed\n");
}
fprintf(test_out, "executing test9\n");
if (test9()) {
fprintf(test_out, "Test9 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test9 failed\n");
}
fprintf(test_out, "executing test10\n");
if (test10()) {
fprintf(test_out, "Test10 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test10 failed\n");
}
fprintf(test_out, "executing test11\n");
if (test11()) {
fprintf(test_out, "Test11 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test11 failed\n");
}
fprintf(test_out, "executing test12\n");
if (test12()) {
fprintf(test_out, "Test12 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test12 failed\n");
}
fprintf(test_out, "executing test13\n");
if (test13()) {
fprintf(test_out, "Test13 succeeded\n");
}
else {
fprintf(test_out, "orte_dss test13 failed\n");
}
fclose(test_out);
orte_dss_close();
opal_finalize();
return(0);
}
/*
* INT8
*/
static bool test1(void)
{
int8_t v1;
uint8_t u1;
size_t s;
orte_data_type_t type=ORTE_INT8, utype=ORTE_UINT8;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT16
*/
static bool test2(void)
{
int16_t v1;
uint16_t u1;
orte_data_type_t type=ORTE_INT16, utype=ORTE_UINT16;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT32
*/
static bool test3(void)
{
int32_t v1;
uint32_t u1;
orte_data_type_t type=ORTE_INT32, utype=ORTE_UINT32;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT64
*/
static bool test4(void)
{
int64_t v1;
uint64_t u1;
orte_data_type_t type=ORTE_INT64, utype=ORTE_UINT64;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* INT
*/
static bool test5(void)
{
int v1;
uint u1;
orte_data_type_t type=ORTE_INT, utype=ORTE_UINT;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for signed value with NULL\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, &u1, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(u1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, utype)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for unsigned value with NULL\n");
return(false);
}
return (true);
}
/*
* STRING
*/
static bool test6(void)
{
char *string1="This is a short string";
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, string1, ORTE_STRING)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != strlen(string1)+1) {
fprintf(test_out, "orte_dss.size failed for string\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, ORTE_STRING)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(string1)) {
fprintf(test_out, "orte_dss.size failed for string with NULL\n");
return(false);
}
return (true);
}
/*
* BOOL
*/
static bool test7(void)
{
bool v1;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for bool");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, ORTE_BOOL)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for bool with NULL\n");
return(false);
}
return (true);
}
/*
* SIZE
*/
static bool test8(void)
{
size_t v1;
orte_data_type_t type=ORTE_SIZE;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for size with NULL\n");
return(false);
}
return (true);
}
/*
* PID
*/
static bool test9(void)
{
pid_t v1;
orte_data_type_t type=ORTE_PID;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for pid\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for pid with NULL\n");
return(false);
}
return (true);
}
/*
* DAEMON CMD
*/
static bool test10(void)
{
orte_daemon_cmd_flag_t v1;
orte_data_type_t type=ORTE_DAEMON_CMD;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for daemon cmd\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for daemon cmd with NULL\n");
return(false);
}
return (true);
}
/*
* DATA TYPE
*/
static bool test11(void)
{
orte_data_type_t v1;
orte_data_type_t type=ORTE_DATA_TYPE;
size_t s;
if (ORTE_SUCCESS != orte_dss.size(&s, &v1, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for data type\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v1)) {
fprintf(test_out, "orte_dss.size failed for data type with NULL\n");
return(false);
}
return (true);
}
/**
* ORTE_BYTE_OBJECT
*/
static bool test12(void)
{
size_t i, ts;
orte_byte_object_t v2;
orte_data_type_t type=ORTE_BYTE_OBJECT;
size_t s;
v2.size = 20;
v2.bytes = (uint8_t*)malloc(v2.size);
for (i=0; i<v2.size; i++) v2.bytes[i] = i;
ts = sizeof(v2) + 20*sizeof(uint8_t);
if (ORTE_SUCCESS != orte_dss.size(&s, &v2, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != ts) {
fprintf(test_out, "orte_dss.size failed for byte object\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v2)) {
fprintf(test_out, "orte_dss.size failed for byte object with NULL\n");
return(false);
}
return (true);
}
/* ORTE_DATA_VALUE */
static bool test13(void)
{
int dat2=200;
orte_data_value_t v2;
orte_data_type_t type=ORTE_DATA_VALUE;
size_t s, ts;
v2.type = ORTE_INT;
v2.data = &dat2;
ts = sizeof(v2) + sizeof(int);
if (ORTE_SUCCESS != orte_dss.size(&s, &v2, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != ts) {
fprintf(test_out, "orte_dss.size failed for data value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&s, NULL, type)) {
fprintf(test_out, "orte_dss.size returned error\n");
return(false);
}
if (s != sizeof(v2)) {
fprintf(test_out, "orte_dss.size failed for data value with NULL\n");
return(false);
}
return (true);
}

12
orte/test/unit/gpr/Makefile Обычный файл
Просмотреть файл

@ -0,0 +1,12 @@
PROGS = gpr_dt_buffer gpr_dt_cmp gpr_dt_copy gpr_dt_print gpr_dt_release gpr_dt_size
all: $(PROGS)
CC = ortecc
CFLAGS = -g
CXX = ortec++
CXXFLAGS = -g
FFLAGS = -g
clean:
rm -f $(PROGS) *~ .gdb*

942
orte/test/unit/gpr/gpr_dt_buffer.c Обычный файл
Просмотреть файл

@ -0,0 +1,942 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
#define NUM_ITERS 1
#define NUM_ELEMS 3
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
orte_init();
test_out = stderr;
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_buffer_t *bufA;
orte_gpr_cmd_flag_t scmd[NUM_ELEMS], dcmd[NUM_ELEMS];
orte_gpr_subscription_id_t ssubid[NUM_ELEMS], dsubid[NUM_ELEMS];
orte_gpr_trigger_id_t strigid[NUM_ELEMS], dtrigid[NUM_ELEMS];
orte_gpr_notify_action_t snotact[NUM_ELEMS], dnotact[NUM_ELEMS];
orte_gpr_trigger_action_t strigact[NUM_ELEMS], dtrigact[NUM_ELEMS];
orte_gpr_notify_msg_type_t snottype[NUM_ELEMS], dnottype[NUM_ELEMS];
orte_gpr_addr_mode_t smode[NUM_ELEMS], dmode[NUM_ELEMS];
orte_std_cntr_t i;
int rc;
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for(i=0; i<NUM_ELEMS; i++) {
scmd[i] = 0x0f;
ssubid[i] = i;
strigid[i] = i;
snotact[i] = ORTE_GPR_NOTIFY_ANY;
strigact[i] = ORTE_GPR_TRIG_ANY;
snottype[i] = 0x0f;
smode[i] = 0x0f0f;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, scmd, NUM_ELEMS, ORTE_GPR_CMD);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, ssubid, NUM_ELEMS, ORTE_GPR_SUBSCRIPTION_ID);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, strigid, NUM_ELEMS, ORTE_GPR_TRIGGER_ID);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, snotact, NUM_ELEMS, ORTE_GPR_NOTIFY_ACTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, strigact, NUM_ELEMS, ORTE_GPR_TRIGGER_ACTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, snottype, NUM_ELEMS, ORTE_GPR_NOTIFY_MSG_TYPE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.pack(bufA, smode, NUM_ELEMS, ORTE_GPR_ADDR_MODE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
/* buffer is FIFO, so unpack in same order */
rc = orte_dss.unpack(bufA, dcmd, &count, ORTE_GPR_CMD);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dsubid, &count, ORTE_GPR_SUBSCRIPTION_ID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dtrigid, &count, ORTE_GPR_TRIGGER_ID);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dnotact, &count, ORTE_GPR_NOTIFY_ACTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dtrigact, &count, ORTE_GPR_TRIGGER_ACTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dnottype, &count, ORTE_GPR_NOTIFY_MSG_TYPE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
rc = orte_dss.unpack(bufA, dmode, &count, ORTE_GPR_ADDR_MODE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
/* all from this iteration are unpacked - check all values */
for(j=0; j<NUM_ELEMS; j++) {
if(scmd[j] != dcmd[j] ||
ssubid[j] != dsubid[j] ||
strigid[j] != dtrigid[j] ||
snotact[j] != dnotact[j] ||
strigact[j] != dtrigact[j] ||
snottype[j] != dnottype[j] ||
smode[j] != dmode[j]) {
fprintf(test_out, "test unstructured values: invalid values returned\n");
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return (true);
}
static bool test_keyval(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i;
int16_t i16;
int32_t i32;
orte_gpr_keyval_t *src[NUM_ELEMS];
orte_gpr_keyval_t *dst[NUM_ELEMS];
orte_data_value_t *dval, *sval;
/* setup source array of keyvals */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_keyval_t);
asprintf(&(src[i]->key), "%lu", (unsigned long)i);
src[i]->value = OBJ_NEW(orte_data_value_t);
sval = src[i]->value;
sval->type = ((i % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
i16 = i;
i32 = i;
if (ORTE_INT16 == sval->type) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_KEYVAL);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed with error %s\n",
ORTE_ERROR_NAME(rc));
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_KEYVAL);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack (KEYVAL) failed on iteration %lu with error %s\n",
(unsigned long)i, ORTE_ERROR_NAME(rc));
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if (0 != strcmp(src[j]->key, dst[j]->key)) {
fprintf(test_out, "test9: invalid results key mismatch from unpack\n");
return(false);
}
if (src[j]->value->type != dst[j]->value->type) {
fprintf(test_out, "test9: invalid results type mismatch from unpack\n");
return(false);
}
sval = src[j]->value;
dval = dst[j]->value;
if (ORTE_EQUAL != orte_dss.compare(sval->data, dval->data, sval->type)) {
fprintf(test_out, "test keyval: invalid value returned\n");
return(false);
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_val(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i, j, k;
int16_t i16;
int32_t i32;
orte_gpr_value_t *src[NUM_ELEMS];
orte_gpr_value_t *dst[NUM_ELEMS];
orte_data_value_t *dval, *sval;
/* test gpr_value */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_value_t);
src[i]->segment = strdup("test-segment");
src[i]->num_tokens = (i % 10) + 1; /* ensure there is always at least one */
src[i]->tokens = (char**)malloc(src[i]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->num_tokens; j++) {
src[i]->tokens[j] = strdup("test-token");
}
src[i]->cnt = (i % 20) + 1;
src[i]->keyvals = (orte_gpr_keyval_t**)malloc(src[i]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->cnt; j++) {
src[i]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src[i]->keyvals[j]->value;
asprintf(&((src[i]->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
}
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW");
fprintf(test_out, "OBJ_NEW failed\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_VALUE);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "orte_dss.pack failed");
fprintf(test_out, "orte_dss.pack failed with error %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_VALUE);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "orte_dss.unpack failed");
fprintf(test_out, "orte_dss.unpack failed with error %d\n", rc);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if(0 != strcmp(src[j]->segment, dst[j]->segment) ||
src[j]->num_tokens != dst[j]->num_tokens ||
src[j]->cnt != dst[j]->cnt) {
fprintf(test_out, "test1_val: invalid results from unpack");
return(false);
}
for (k=0; k<src[j]->num_tokens; k++) {
if (0 != strcmp(src[j]->tokens[k], dst[j]->tokens[k])) {
fprintf(test_out, "test1_val: invalid results (tokens) from unpack");
return(false);
}
}
for (k=0; k < src[j]->cnt; k++) {
if (0 != strcmp((src[j]->keyvals[k])->key,
(dst[j]->keyvals[k])->key)) {
fprintf(test_out, "test1_val: invalid results (keyvalues) from unpack");
return(false);
}
dval = dst[j]->keyvals[k]->value;
sval = src[j]->keyvals[k]->value;
if (sval->type != dval->type) {
fprintf(test_out, "test1_val: invalid results (keyvalue types) from unpack");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, dval->type)) {
fprintf(stderr, "test1_val: orte_dss.compare failed\n");
return(false);
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer");
return false;
}
return(true);
}
static bool test_sub(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i, j, k, m;
orte_gpr_subscription_t *src[NUM_ELEMS];
orte_gpr_subscription_t *dst[NUM_ELEMS];
/* test gpr_subscription */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to NUM_ELEMS+1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to NUM_ELEMS */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to NUM_ELEMS */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_SUBSCRIPTION);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_sub pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_SUBSCRIPTION);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_sub unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_sub invalid results from unpack\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_sub: invalid results from unpack\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_sub: invalid results (value num_tokens) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_sub: invalid results (tokens) from unpack\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_sub: invalid results (value cnt) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_sub: invalid results (keys) from unpack\n");
return(false);
}
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_trig(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i, j, k, m;
orte_gpr_trigger_t *src[NUM_ELEMS];
orte_gpr_trigger_t *dst[NUM_ELEMS];
/* test gpr_trigger */
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to NUM_ELEMS+1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to NUM_ELEMS */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to NUM_ELEMS */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_TRIGGER);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_trig pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
memset(dst,-1,sizeof(dst));
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_TRIGGER);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_trig unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_trig invalid results from unpack\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_trig: invalid results from unpack\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_trig: invalid results (value num_tokens) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_trig: invalid results (tokens) from unpack\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_trig: invalid results (value cnt) from unpack\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_trig: invalid results (keys) from unpack\n");
return(false);
}
}
}
}
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_notify_data(void)
{
orte_buffer_t *bufA;
int rc;
orte_std_cntr_t i, j, k, l, n;
orte_data_value_t *sdv, *ddv;
int32_t i32;
orte_gpr_value_t *value, **sval, **dval;
orte_gpr_notify_data_t *src[NUM_ELEMS];
orte_gpr_notify_data_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to NUM_ELEMS-1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0-NUM_ELEMS-1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0-NUM_ELEMS-1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
/* source data set, now create buffer and pack source data */
bufA = OBJ_NEW(orte_buffer_t);
if (NULL == bufA) {
fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
return false;
}
for (i=0;i<NUM_ITERS;i++) {
rc = orte_dss.pack(bufA, src, NUM_ELEMS, ORTE_GPR_NOTIFY_DATA);
if (ORTE_SUCCESS != rc) {
fprintf(test_out, "test_notify_data pack failed with return code %d\n", rc);
return(false);
}
}
for (i=0; i<NUM_ITERS; i++) {
int j;
orte_std_cntr_t count = NUM_ELEMS;
rc = orte_dss.unpack(bufA, dst, &count, ORTE_GPR_NOTIFY_DATA);
if (ORTE_SUCCESS != rc || count != NUM_ELEMS) {
fprintf(test_out, "test_notify_data unpack failed with return code %d (count=%lu)\n", rc, (unsigned long) count);
return(false);
}
for(j=0; j<NUM_ELEMS; j++) {
if (
src[j]->id != dst[j]->id ||
src[j]->cnt != dst[j]->cnt ||
src[j]->remove != dst[j]->remove
) {
fprintf(test_out, "test_notify_data: invalid results from unpack\n");
return(false);
}
if ((NULL == src[j]->target && NULL != dst[j]->target) ||
(NULL != src[j]->target && NULL == dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched NULL targets\n");
return(false);
}
if (NULL != src[j]->target && NULL != dst[j]->target &&
0 != strcmp(src[j]->target, dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched target names\n");
return(false);
}
/* now compare each value of the cnt depedant values */
sval = (orte_gpr_value_t**)(src[j]->values)->addr;
dval = (orte_gpr_value_t**)(dst[j]->values)->addr;
/* because of the way this has been done, we can safely assume
* that these are in the same relative order
*/
for (k=0, n=0; n < src[j]->cnt &&
k < (src[j]->values)->size; k++) {
if (NULL != sval[k]) {
n++;
if (sval[k]->addr_mode != dval[k]->addr_mode) {
fprintf(test_out, "test_notify_data: invalid results (values-addr-mode) from unpack\n");
return(false);
}
if (0 != strcmp(sval[k]->segment, dval[k]->segment)) {
fprintf(test_out, "test_notify_data: invalid results (values-segment) from unpack\n");
return(false);
}
if (sval[k]->num_tokens != dval[k]->num_tokens) {
fprintf(test_out, "test_notify_data: invalid results (values-num_tokens) from unpack\n");
return(false);
}
for (l=0; l<sval[k]->num_tokens; l++) {
if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) {
fprintf(test_out, "test_notify_data: invalid results (values-tokens) from unpack\n");
return(false);
}
} /* for each token inside each grp value */
if (sval[k]->cnt != dval[k]->cnt) {
fprintf(test_out, "test_notify_data: invalid results (values-cnt (of keyval pairs)) from unpack\n");
return(false);
}
for (l=0; l< sval[k]->cnt; l++) {
if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-key) from unpack\n");
return(false);
}
sdv = sval[k]->keyvals[l]->value;
ddv = dval[k]->keyvals[l]->value;
if (sdv->type != ddv->type) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-type) from unpack\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(sdv->data, ddv->data, sdv->type)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-value.i32) from unpack\n");
return(false);
}
}/* for each keyvalpair inside each grp value */
} /* for each grp value */
}
} /* for each ELEMENT */
}
OBJ_RELEASE(bufA);
if (NULL != bufA) {
fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
return false;
}
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

548
orte/test/unit/gpr/gpr_dt_cmp.c Обычный файл
Просмотреть файл

@ -0,0 +1,548 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
orte_init();
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_CMD yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_SUBSCRIPTION_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_TRIGGER_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_NOTIFY_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_TRIGGER_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_NOTIFY_MSG_TYPE yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.compare ORTE_GPR_ADDR_MODE yielded incorrect value\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src, *dst;
orte_data_value_t *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy dynamic keyval returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.compare dynamic keyval failed\n");
return(false);
}
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy static keyval returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.compare static keyval failed\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src, *dst;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
orte_std_cntr_t j;
int16_t i16;
int32_t i32;
return true; /* no comparison function defined yet */
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy dynamic value returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.compare dynamic value failed\n");
return(false);
}
OBJ_RELEASE(dst);
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy static value returned error\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.compare static value failed\n");
return(false);
}
OBJ_RELEASE(dst);
return(true);
}
static bool test_sub(void)
{
orte_std_cntr_t i, j, k;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.compare sub failed\n");
return(false);
}
}
return (true);
}
static bool test_trig(void)
{
orte_std_cntr_t i, j, k;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.compare trig failed\n");
return(false);
}
}
return (true);
}
static bool test_notify_data(void)
{
orte_std_cntr_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
return true; /* no comparison function defined yet */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.compare notify_data failed\n");
return(false);
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

832
orte/test/unit/gpr/gpr_dt_copy.c Обычный файл
Просмотреть файл

@ -0,0 +1,832 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dcmd, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
if (*dcmd != scmd) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (*dsubid != ssubid) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (*dtrigid != strigid) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (*dnotact != snotact) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (*dtrigact != strigact) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (*dnottype != snottype) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE yielded incorrect value\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (*dmode != smode) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE yielded incorrect value\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src, *dst;
orte_data_value_t *dval, *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy dynamic keyval returned error\n");
return(false);
}
if (0 != strcmp(src->key, dst->key)) {
fprintf(stderr, "orte_dss.copy dynamic keyval string mismatch\n");
return(false);
}
sval = src->value;
dval = dst->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy dynamic keyval type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy dynamic keyval data mismatch\n");
return(false);
}
OBJ_RELEASE(dst);
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.copy static keyval returned error\n");
return(false);
}
if (0 != strcmp(src1.key, dst->key)) {
fprintf(stderr, "orte_dss.copy static keyval string mismatch\n");
return(false);
}
sval = src1.value;
dval = dst->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy static keyval type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy static keyval data mismatch\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src, *dst;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
size_t j;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy dynamic value returned error\n");
return(false);
}
if (src->addr_mode != dst->addr_mode) {
fprintf(stderr, "orte_dss.copy dynamic value addr_mode mismatch\n");
return(false);
}
if (0 != strcmp(src->segment, dst->segment)) {
fprintf(stderr, "orte_dss.copy dynamic value segment mismatch\n");
return(false);
}
if (src->num_tokens != dst->num_tokens) {
fprintf(stderr, "orte_dss.copy dynamic value num_tokens mismatch\n");
return(false);
}
for (j=0; j < src->num_tokens; j++) {
if (0 != strcmp(src->tokens[j], dst->tokens[j])) {
fprintf(stderr, "orte_dss.copy dynamic value token mismatch\n");
return(false);
}
}
if (src->cnt != dst->cnt) {
fprintf(stderr, "orte_dss.copy dynamic value cnt mismatch\n");
return(false);
}
for (j=0; j < src->cnt; j++) {
if (0 != strcmp(src->keyvals[j]->key, dst->keyvals[j]->key)) {
fprintf(stderr, "orte_dss.copy dynamic value key mismatch\n");
return(false);
}
sval = src->keyvals[j]->value;
dval = dst->keyvals[j]->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy dynamic value data type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, sval->type)) {
fprintf(stderr, "orte_dss.copy dynamic value data mismatch\n");
return(false);
}
}
OBJ_RELEASE(dst);
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.copy static value returned error\n");
return(false);
}
if (value.addr_mode != dst->addr_mode) {
fprintf(stderr, "orte_dss.copy static value addr_mode mismatch\n");
return(false);
}
if (0 != strcmp(value.segment, dst->segment)) {
fprintf(stderr, "orte_dss.copy static value segment mismatch\n");
return(false);
}
if (value.num_tokens != dst->num_tokens) {
fprintf(stderr, "orte_dss.copy static value num_tokens mismatch\n");
return(false);
}
for (j=0; j < value.num_tokens; j++) {
if (0 != strcmp(value.tokens[j], dst->tokens[j])) {
fprintf(stderr, "orte_dss.copy static value token mismatch\n");
return(false);
}
}
if (value.cnt != dst->cnt) {
fprintf(stderr, "orte_dss.copy static value cnt mismatch\n");
return(false);
}
for (j=0; j < value.cnt; j++) {
if (0 != strcmp(value.keyvals[j]->key, dst->keyvals[j]->key)) {
fprintf(stderr, "orte_dss.copy static value key mismatch\n");
return(false);
}
sval = value.keyvals[j]->value;
dval = dst->keyvals[j]->value;
if (sval->type != dval->type) {
fprintf(stderr, "orte_dss.copy static value data type mismatch\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dval->data, sval->data, sval->type)) {
fprintf(stderr, "orte_dss.copy static value data mismatch\n");
return(false);
}
}
OBJ_RELEASE(dst);
return(true);
}
static bool test_sub(void)
{
size_t i, j, k, m;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_sub invalid name results\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_sub: invalid values\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_sub: invalid results (value num_tokens)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_sub: invalid results (tokens)\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_sub: invalid results (value cnt)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_sub: invalid results (keys)\n");
return(false);
}
}
}
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k, m;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if ((NULL == src[j]->name && NULL != dst[j]->name) ||
(NULL != src[j]->name && NULL == dst[j]->name)
) {
fprintf(test_out, "test_trig invalid name results\n");
return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->action != dst[j]->action ||
src[j]->cnt != dst[j]->cnt
) {
fprintf(test_out, "test_trig: invalid value results\n");
return(false);
}
/* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->cnt; k++) {
if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
fprintf(test_out, "test_trig: invalid results (value num_tokens)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
fprintf(test_out, "test_trig: invalid results (tokens)\n");
return(false);
}
}
if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
fprintf(test_out, "test_trig: invalid results (value cnt)\n");
return(false);
}
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
fprintf(test_out, "test_trig: invalid results (keys)\n");
return(false);
}
}
}
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k, l, n;
orte_data_value_t *sdv, *ddv;
int32_t i32;
orte_gpr_value_t *value, **sval, **dval;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (
src[j]->id != dst[j]->id ||
src[j]->cnt != dst[j]->cnt ||
src[j]->remove != dst[j]->remove
) {
fprintf(test_out, "test_notify_data: invalid values\n");
return(false);
}
if ((NULL == src[j]->target && NULL != dst[j]->target) ||
(NULL != src[j]->target && NULL == dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched NULL targets\n");
return(false);
}
if (NULL != src[j]->target && NULL != dst[j]->target &&
0 != strcmp(src[j]->target, dst[j]->target)) {
fprintf(test_out, "test_notify_data failed with mismatched target names\n");
return(false);
}
/* now compare each value of the cnt depedant values */
sval = (orte_gpr_value_t**)(src[j]->values)->addr;
dval = (orte_gpr_value_t**)(dst[j]->values)->addr;
/* because of the way this has been done, we can safely assume
* that these are in the same relative order
*/
for (k=0, n=0; n < src[j]->cnt &&
k < (src[j]->values)->size; k++) {
if (NULL != sval[k]) {
n++;
if (sval[k]->addr_mode != dval[k]->addr_mode) {
fprintf(test_out, "test_notify_data: invalid results (values-addr-mode)\n");
return(false);
}
if (0 != strcmp(sval[k]->segment, dval[k]->segment)) {
fprintf(test_out, "test_notify_data: invalid results (values-segment)\n");
return(false);
}
if (sval[k]->num_tokens != dval[k]->num_tokens) {
fprintf(test_out, "test_notify_data: invalid results (values-num_tokens)\n");
return(false);
}
for (l=0; l<sval[k]->num_tokens; l++) {
if (0 != strcmp(sval[k]->tokens[l], dval[k]->tokens[l])) {
fprintf(test_out, "test_notify_data: invalid results (values-tokens)\n");
return(false);
}
} /* for each token inside each grp value */
if (sval[k]->cnt != dval[k]->cnt) {
fprintf(test_out, "test_notify_data: invalid results (values-cnt (of keyval pairs))\n");
return(false);
}
for (l=0; l< sval[k]->cnt; l++) {
if (0 != strcmp(sval[k]->keyvals[l]->key, dval[k]->keyvals[l]->key)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-key)\n");
return(false);
}
sdv = sval[k]->keyvals[l]->value;
ddv = dval[k]->keyvals[l]->value;
if (sdv->type != ddv->type) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-type)\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(sdv->data, ddv->data, sdv->type)) {
fprintf(test_out, "test_notify_data: invalid results (values-keyvals-value.i32)\n");
return(false);
}
}/* for each keyvalpair inside each grp value */
} /* for each grp value */
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

635
orte/test/unit/gpr/gpr_dt_print.c Обычный файл
Просмотреть файл

@ -0,0 +1,635 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *stderr;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
stderr = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd;
orte_gpr_subscription_id_t ssubid;
orte_gpr_trigger_id_t strigid;
orte_gpr_notify_action_t snotact;
orte_gpr_trigger_action_t strigact;
orte_gpr_notify_msg_type_t snottype;
orte_gpr_addr_mode_t smode;
char *output;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_EQUAL != orte_dss.print(&output, NULL, &scmd, ORTE_GPR_CMD)) {
fprintf(stderr, "orte_dss.print returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for gpr cmd\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for gpr cmd: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for subscription\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for subscription: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for trigger id\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for trigger id: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify action\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify action: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for trigger action\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for trigger action: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify message type\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify message type: %s\n", output);
free(output);
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for notify message type\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for notify message type: %s\n", output);
free(output);
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
orte_gpr_keyval_t *src;
orte_data_value_t *sval;
char *output;
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_KEYVAL returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_KEYVAL\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_KEYVAL: %s\n", output);
free(output);
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_data_value_t *sval;
size_t j;
int16_t i16;
int32_t i32;
char *output;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
sval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
sval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (sval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_VALUE returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_VALUE\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_VALUE: %s\n", output);
free(output);
return(true);
}
static bool test_sub(void)
{
size_t i, j, k;
orte_gpr_subscription_t *src[2];
char *output;
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_SUBSCRIPTION returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_SUBSCRIPTION\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_SUBSCRIPTION: %s\n", output);
free(output);
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k;
orte_gpr_trigger_t *src[2];
char *output;
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_TRIGGER returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_TRIGGER\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_TRIGGER: %s\n", output);
free(output);
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
char *output;
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(stderr, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_DATA returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_NOTIFY_DATA\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_NOTIFY_DATA: %s\n", output);
free(output);
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_message_t *msg;
char *output;
msg = OBJ_NEW(orte_gpr_notify_message_t);
msg->msg_type = 2;
msg->target = strdup("nonsense-msg");
msg->id = 1;
msg->remove = false;
msg->cnt = 2;
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(stderr, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
/* add the data object to the pointer array */
orte_pointer_array_add(&i, msg->data, src[i]);
} /* for each data */
if (ORTE_SUCCESS != orte_dss.print(&output, NULL, msg, ORTE_GPR_NOTIFY_MSG)) {
fprintf(stderr, "orte_dss.print ORTE_GPR_NOTIFY_MSG returned error\n");
return(false);
}
if (NULL == output) {
fprintf(stderr, "orte_dss.print failed for ORTE_GPR_NOTIFY_MSG\n");
return(false);
}
fprintf(stderr, "orte_dss.print output for ORTE_GPR_NOTIFY_MSG: %s\n", output);
free(output);
return (true);
}

561
orte/test/unit/gpr/gpr_dt_release.c Обычный файл
Просмотреть файл

@ -0,0 +1,561 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd, *dcmd;
orte_gpr_subscription_id_t ssubid, *dsubid;
orte_gpr_trigger_id_t strigid, *dtrigid;
orte_gpr_notify_action_t snotact, *dnotact;
orte_gpr_trigger_action_t strigact, *dtrigact;
orte_gpr_notify_msg_type_t snottype, *dnottype;
orte_gpr_addr_mode_t smode, *dmode;
orte_data_value_t *dval2, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
dval2 = OBJ_NEW(orte_data_value_t);
dval2->type = ORTE_GPR_CMD;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval2->data), &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_CMD returned error\n");
return(false);
}
orte_dss.release(dval2);
if (NULL != dval2->data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_CMD failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dsubid, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
dval.type = ORTE_GPR_SUBSCRIPTION_ID;
dval.data = dsubid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_SUBSCRIPTION_ID failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigid, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
dval.type = ORTE_GPR_TRIGGER_ID;
dval.data = dtrigid;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_TRIGGER_ID failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnotact, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
dval.type = ORTE_GPR_NOTIFY_ACTION;
dval.data = dnotact;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_NOTIFY_ACTION failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dtrigact, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
dval.type = ORTE_GPR_TRIGGER_ACTION;
dval.data = dtrigact;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_TRIGGER_ACTION failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dnottype, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
dval.type = ORTE_GPR_NOTIFY_MSG_TYPE;
dval.data = dnottype;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_NOTIFY_MSG_TYPE failed to NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.copy((void**)&dmode, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.copy ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
dval.type = ORTE_GPR_ADDR_MODE;
dval.data = dmode;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_ADDR_MODE failed to NULL pointer\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int32_t i16=2345;
orte_gpr_keyval_t *src;
orte_data_value_t *sval, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
dval.type = ORTE_GPR_KEYVAL;
dval.data = src;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_KEYVAL failed to NULL pointer\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_gpr_keyval_t *keyvals;
orte_data_value_t *sval, dval = { {OBJ_CLASS(orte_data_value_t),0},ORTE_UNDEF,NULL};
size_t j;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
sval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
sval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (sval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
dval.type = ORTE_GPR_VALUE;
dval.data = src;
orte_dss.release(&dval);
if (NULL != dval.data) {
fprintf(test_out, "orte_dss.release ORTE_GPR_KEYVAL failed to NULL pointer\n");
return(false);
}
return(true);
}
static bool test_sub(void)
{
size_t i, j, k;
orte_gpr_subscription_t *src[2];
orte_gpr_subscription_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.compare sub failed\n");
return(false);
}
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k;
orte_gpr_trigger_t *src[2];
orte_gpr_trigger_t *dst[2];
return true; /* no comparison function defined yet */
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.compare trig failed\n");
return(false);
}
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
orte_gpr_notify_data_t *dst[2];
return true; /* no comparison function defined yet */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.copy((void**)&dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data copy failed\n");
return(false);
}
if (ORTE_EQUAL != orte_dss.compare(dst[j], src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.compare notify_data failed\n");
return(false);
}
} /* for each ELEMENT */
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}

644
orte/test/unit/gpr/gpr_dt_size.c Обычный файл
Просмотреть файл

@ -0,0 +1,644 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* The Open MPI general purpose registry - unit test
*
*/
/*
* includes
*/
#include "orte_config.h"
#include <stdio.h>
#include <string.h>
#include "orte/orte_constants.h"
#include "opal/runtime/opal.h"
#include "opal/util/malloc.h"
#include "opal/util/output.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/dss/dss.h"
#include "orte/util/proc_info.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h"
static bool test_unstruct(void);
static bool test_keyval(void);
static bool test_val(void);
static bool test_sub(void);
static bool test_trig(void);
static bool test_notify_data(void);
static bool test_notify_msg(void);
FILE *test_out;
int main(int argc, char **argv)
{
int ret;
opal_init();
/* register handler for errnum -> string converstion */
opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);
test_out = stderr;
/* Ensure the process info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_proc_info())) {
return ret;
}
orte_process_info.seed = true;
orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
orte_process_info.my_name->cellid = 0;
orte_process_info.my_name->jobid = 0;
orte_process_info.my_name->vpid = 0;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(stderr, "MCA started\n");
} else {
fprintf(stderr, "MCA could not start\n");
exit (1);
}
/* open the dss */
if (ORTE_SUCCESS == orte_dss_open()) {
fprintf(stderr, "DSS started\n");
} else {
fprintf(stderr, "DSS could not start\n");
exit (1);
}
/* startup the gpr to register data types */
if (ORTE_SUCCESS == orte_gpr_base_open()) {
fprintf(stderr, "GPR opened\n");
} else {
fprintf(stderr, "GPR could not open\n");
exit (1);
}
/* Now do the tests */
fprintf(stderr, "executing test_unstruct\n");
if (test_unstruct()) {
fprintf(stderr, "test_unstruct succeeded\n");
}
else {
fprintf(stderr, "test_unstruct failed\n");
}
fprintf(stderr, "executing test_keyval\n");
if (test_keyval()) {
fprintf(stderr, "test_keyval succeeded\n");
}
else {
fprintf(stderr, "test_keyval failed\n");
}
fprintf(stderr, "executing test_val\n");
if (test_val()) {
fprintf(stderr, "test_val succeeded\n");
}
else {
fprintf(stderr, "test_val failed\n");
}
fprintf(stderr, "executing test_sub\n");
if (test_sub()) {
fprintf(stderr, "test_sub succeeded\n");
}
else {
fprintf(stderr, "test_sub failed\n");
}
fprintf(stderr, "executing test_trig\n");
if (test_trig()) {
fprintf(stderr, "test_trig succeeded\n");
}
else {
fprintf(stderr, "test_trig failed\n");
}
fprintf(stderr, "executing test_notify_data\n");
if (test_notify_data()) {
fprintf(stderr, "test_notify_data succeeded\n");
}
else {
fprintf(stderr, "test_notify_data failed\n");
}
fprintf(stderr, "executing test_notify_msg\n");
if (test_notify_msg()) {
fprintf(stderr, "test_notify_msg succeeded\n");
}
else {
fprintf(stderr, "test_notify_msg failed\n");
}
orte_dss_close();
mca_base_close();
opal_malloc_finalize();
opal_output_finalize();
opal_class_finalize();
return 0;
}
static bool test_unstruct(void)
{
orte_gpr_cmd_flag_t scmd;
orte_gpr_subscription_id_t ssubid;
orte_gpr_trigger_id_t strigid;
orte_gpr_notify_action_t snotact;
orte_gpr_trigger_action_t strigact;
orte_gpr_notify_msg_type_t snottype;
orte_gpr_addr_mode_t smode;
size_t sz;
scmd = 0x0f;
ssubid = 31;
strigid = 28;
snotact = ORTE_GPR_NOTIFY_ANY;
strigact = ORTE_GPR_TRIG_ANY;
snottype = 0x0f;
smode = 0x0f0f;
if (ORTE_SUCCESS != orte_dss.size(&sz, &scmd, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned error\n");
return(false);
}
if (sz != sizeof(scmd)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_CMD)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(scmd)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_CMD returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &ssubid, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned error\n");
return(false);
}
if (sz != sizeof(ssubid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_SUBSCRIPTION_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(ssubid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION_ID returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &strigid, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned error\n");
return(false);
}
if (sz != sizeof(strigid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER_ID)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(strigid)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ID returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &snotact, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned error\n");
return(false);
}
if (sz != sizeof(snotact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(snotact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_ACTION returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &strigact, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned error\n");
return(false);
}
if (sz != sizeof(strigact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER_ACTION)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(strigact)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER_ACTION returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &snottype, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned error\n");
return(false);
}
if (sz != sizeof(snottype)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_MSG_TYPE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(snottype)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_MSG_TYPE returned wrong size for NULL pointer\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &smode, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned error\n");
return(false);
}
if (sz != sizeof(smode)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned wrong size\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_ADDR_MODE)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned error for NULL pointer\n");
return(false);
}
if (sz != sizeof(smode)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_ADDR_MODE returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_keyval(void)
{
int16_t i16=10;
int32_t i32=2345;
orte_gpr_keyval_t *src;
orte_data_value_t *sval;
orte_gpr_keyval_t src1 = { {OBJ_CLASS(orte_gpr_keyval_t),0},"test-key-2",NULL};
size_t sz;
src = OBJ_NEW(orte_gpr_keyval_t);
src->key = strdup("test-key");
src->value = OBJ_NEW(orte_data_value_t);
sval = src->value;
sval->type = ORTE_INT16;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy int16 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, src, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size dynamic keyval returned error\n");
return(false);
}
src1.value = OBJ_NEW(orte_data_value_t);
sval = src1.value;
sval->type = ORTE_INT32;
if (ORTE_SUCCESS != orte_dss.set(sval, &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.set int32 returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, &src1, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size static keyval returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_KEYVAL)) {
fprintf(stderr, "orte_dss.size keyval with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_keyval_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_KEYVAL returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_val(void)
{
orte_gpr_value_t *src;
orte_gpr_value_t value = { {OBJ_CLASS(orte_gpr_value_t),0},
ORTE_GPR_TOKENS_AND,
"test-segment", 1, NULL, 0, NULL };
orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = { {OBJ_CLASS(orte_gpr_keyval_t),0},"dumb-key",NULL};
orte_data_value_t *dval, *sval;
size_t j, sz;
int16_t i16;
int32_t i32;
src = OBJ_NEW(orte_gpr_value_t);
src->addr_mode = 0x01;
src->segment = strdup("test-segment");
src->num_tokens = 3;
src->tokens = (char**)malloc(src->num_tokens * sizeof(char*));
for (j=0; j < src->num_tokens; j++) {
src->tokens[j] = strdup("test-token");
}
src->cnt = 21;
src->keyvals = (orte_gpr_keyval_t**)malloc(src->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src->cnt; j++) {
src->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src->keyvals[j]->value = OBJ_NEW(orte_data_value_t);
dval = src->keyvals[j]->value;
asprintf(&((src->keyvals[j])->key), "%lu",
(unsigned long) j);
dval->type = ((j % 2) == 0) ? ORTE_INT16 : ORTE_INT32;
if (dval->type == ORTE_INT16) {
i16 = 1024*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i16, ORTE_INT16)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
} else {
i32 = 2048*j;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(dval->data), &i32, ORTE_INT32)) {
fprintf(stderr, "orte_dss.copy returned error\n");
return(false);
}
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, src, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size dynamic value returned error\n");
return(false);
}
value.keyvals = &keyvals;
keyvals = &keyval;
keyval.value = OBJ_NEW(orte_data_value_t);
sval = keyval.value;
sval->type = ORTE_INT32;
sval->data = &i32;
i32 = 23456;
if (ORTE_SUCCESS != orte_dss.size(&sz, &value, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size static value returned error\n");
return(false);
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_VALUE)) {
fprintf(stderr, "orte_dss.size keyval with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_value_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_VALUE returned wrong size for NULL pointer\n");
return(false);
}
return(true);
}
static bool test_sub(void)
{
size_t i, j, k, sz;
orte_gpr_subscription_t *src[2];
/* test gpr_subscription */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
src[i]->action = (orte_gpr_notify_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for (j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_SUBSCRIPTION)) {
fprintf(test_out, "test_sub size failed\n");
return(false);
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_SUBSCRIPTION)) {
fprintf(stderr, "orte_dss.size sub with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_subscription_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_SUBSCRIPTION returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_trig(void)
{
size_t i, j, k, sz;
orte_gpr_trigger_t *src[2];
/* test gpr_trigger */
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_trigger_t);
if (i % 2) {
src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_trigger_id_t)i;
src[i]->action = (orte_gpr_trigger_action_t)0x0f;
/* test value counts of 1 to +1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test key counts of 0 to */
src[i]->values[k]->cnt = i;
if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
for (j=0; j < src[i]->values[k]->cnt; j++) {
src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */
}
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_TRIGGER)) {
fprintf(test_out, "test_trig size failed\n");
return(false);
}
}
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_TRIGGER)) {
fprintf(stderr, "orte_dss.size trig with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_subscription_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_TRIGGER returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_notify_data(void)
{
size_t i, j, k, sz;
orte_data_value_t *sdv;
int32_t i32;
orte_gpr_value_t *value;
orte_gpr_notify_data_t *src[2];
for(i=0; i<2; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t);
if (i % 2) { /* test half with a name and with remove=true */
src[i]->target = strdup("test-notify-data-name");
src[i]->remove = true;
}
src[i]->id = i;
/* test value counts of 0 to -1 */
src[i]->cnt = i; /* value count */
for (j=0; j < src[i]->cnt; j++) {
value = OBJ_NEW(orte_gpr_value_t);
value->addr_mode = (orte_gpr_addr_mode_t) i+j+1;
value->segment = strdup("test-gpr-notify-value-segment-name"); /* ek segment name again! */
/* tokens */
value->num_tokens = j; /* test tokens within gpr values within notify message between 0--1 */
if (value->num_tokens) { /* if to allow testing of num_tokens count of zero */
value->tokens = (char**)malloc(value->num_tokens * sizeof(char*));
for (k=0; k < value->num_tokens; k++) {
value->tokens[k] = strdup("test-grp-notify-value-token");
} /* for each token */
} /* if tokens */
/* keyval pairs (field name is 'cnt' same as used for value count so be careful) */
value->cnt = j; /* test keyval pairs within gpr values within notify message between 0--1 */
if (value->cnt) { /* if to allow testing of keyval pair count of zero */
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
for (k=0; k < value->cnt; k++) {
value->keyvals[k] = OBJ_NEW (orte_gpr_keyval_t);
value->keyvals[k]->value = OBJ_NEW(orte_data_value_t);
sdv = value->keyvals[k]->value;
value->keyvals[k]->key = strdup("test-grp-notify-value-key");
sdv->type = ORTE_INT32; /* make it simplier */
i32 = (i*100)+(j*10)+k;
if (ORTE_SUCCESS != orte_dss.copy((void**)&(sdv->data), &i32, ORTE_INT32)) {
fprintf(test_out, "test_notify_data: error copying data into source value\n");
return(false);
}
} /* for each keyval pair */
} /* if keyvals */
/* add the value to the data object */
orte_pointer_array_add(&k, src[i]->values, value);
} /* for each value */
}
for(j=0; j<2; j++) {
if (ORTE_SUCCESS != orte_dss.size(&sz, src[j], ORTE_GPR_NOTIFY_DATA)) {
fprintf(test_out, "test_notify_data size failed\n");
return(false);
}
} /* for each ELEMENT */
if (ORTE_SUCCESS != orte_dss.size(&sz, NULL, ORTE_GPR_NOTIFY_DATA)) {
fprintf(stderr, "orte_dss.size notify_data with NULL returned error\n");
return(false);
}
if (sz != sizeof(orte_gpr_notify_data_t)) {
fprintf(test_out, "orte_dss.size ORTE_GPR_NOTIFY_DATA returned wrong size for NULL pointer\n");
return(false);
}
return (true);
}
static bool test_notify_msg(void)
{
return (true);
}