/* * 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 #include #include #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #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 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); } 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; ibytes), "%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;isize != 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; ibytes), "%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;isize != 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; jtype = ((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;itype != 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); } /* size_t */ static bool test11(void) { orte_buffer_t *bufA; int rc; size_t i; size_t src[NUM_ELEMS]; size_t dst[NUM_ELEMS]; for(i=0; i