This source file includes following definitions.
- main
- test1
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 #include "opal_config.h"
  22 #include "opal/constants.h"
  23 
  24 #include <stdio.h>
  25 #include <string.h>
  26 #include <stdlib.h>
  27 
  28 #include "opal/runtime/opal.h"
  29 #include "opal/dss/dss.h"
  30 
  31 #define NUM_ITERS 100
  32 #define NUM_ELEMS 1024
  33 
  34 static bool test1(void);        
  35 
  36 static FILE *test_out;
  37 
  38 
  39 int main (int argc, char* argv[])
  40 {
  41     int ret = 0;
  42 
  43     opal_init(&argc, &argv);
  44 
  45     test_out = stderr;
  46 
  47     
  48 
  49     fprintf(test_out, "executing test1\n");
  50     if (test1()) {
  51         fprintf(test_out, "Test1 succeeded\n");
  52     } else {
  53         fprintf(test_out, "Test1 failed\n");
  54         ret = 1;
  55     }
  56 
  57     opal_finalize();
  58 
  59     return ret;
  60 }
  61 
  62 static bool test1(void)        
  63 {
  64     opal_buffer_t *bufA, *bufB;
  65     int rc;
  66     int32_t i;
  67     int16_t src[NUM_ELEMS];
  68     int16_t dst[NUM_ELEMS];
  69     int32_t src32[NUM_ELEMS];
  70     int32_t dst32[NUM_ELEMS];
  71 
  72     
  73     for (i=0; i < NUM_ELEMS; i++) {
  74         src[i] = i;
  75         src32[i] = 132 * i;
  76     }
  77 
  78     
  79     bufA = OBJ_NEW(opal_buffer_t);
  80     if (NULL == bufA) {
  81         fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
  82         return false;
  83     }
  84 
  85     bufA->type = OPAL_DSS_BUFFER_NON_DESC;
  86 
  87     
  88     for (i=0;i<NUM_ITERS;i++) {
  89         rc = opal_dss.pack(bufA, src, NUM_ELEMS, OPAL_INT16);
  90         if (OPAL_SUCCESS != rc) {
  91             fprintf(test_out, "opal_dss.pack failed with return code %d\n", rc);
  92             return(false);
  93         }
  94     }
  95 
  96     
  97     bufB = OBJ_NEW(opal_buffer_t);
  98     if (NULL == bufB) {
  99         fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n");
 100         return false;
 101     }
 102 
 103     bufB->type = OPAL_DSS_BUFFER_NON_DESC;
 104 
 105     
 106     for (i=0;i<NUM_ITERS;i++) {
 107         rc = opal_dss.pack(bufB, src32, NUM_ELEMS, OPAL_INT32);
 108         if (OPAL_SUCCESS != rc) {
 109             fprintf(test_out, "opal_dss.pack failed with return code %d\n", rc);
 110             return(false);
 111         }
 112     }
 113 
 114     
 115     if (OPAL_SUCCESS != (rc = opal_dss.copy_payload(bufB, bufA))) {
 116         fprintf(test_out, "opal_dss.copy_payload failed with return code %d\n", rc);
 117         return(false);
 118     }
 119 
 120     
 121     for (i=0;i<NUM_ITERS;i++) {
 122         rc = opal_dss.pack(bufB, src32, NUM_ELEMS, OPAL_INT32);
 123         if (OPAL_SUCCESS != rc) {
 124             fprintf(test_out, "opal_dss.pack failed with return code %d\n", rc);
 125             return(false);
 126         }
 127     }
 128 
 129     
 130     for (i=0; i<NUM_ITERS; i++) {
 131         int j;
 132         int32_t count;
 133 
 134         for(j=0; j<NUM_ELEMS; j++)
 135             dst32[j] = -1;
 136 
 137         count = NUM_ELEMS;
 138         rc = opal_dss.unpack(bufB, dst32, &count, OPAL_INT32);
 139         if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
 140             fprintf(test_out, "opal_dss.unpack of dest buffer failed with return code %d\n", rc);
 141             return(false);
 142         }
 143 
 144         for(j=0; j<NUM_ELEMS; j++) {
 145             if(src32[j] != dst32[j]) {
 146                 fprintf(test_out, "test1: invalid results from unpack of dest buffer\n");
 147                 return(false);
 148             }
 149         }
 150     }
 151 
 152     for (i=0; i<NUM_ITERS; i++) {
 153         int j;
 154         int32_t count;
 155 
 156         for(j=0; j<NUM_ELEMS; j++)
 157             dst[j] = -1;
 158 
 159         count = NUM_ELEMS;
 160         rc = opal_dss.unpack(bufB, dst, &count, OPAL_INT16);
 161         if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
 162             fprintf(test_out, "opal_dss.unpack of dest buffer failed with return code %d\n", rc);
 163             return(false);
 164         }
 165 
 166         for(j=0; j<NUM_ELEMS; j++) {
 167             if(src[j] != dst[j]) {
 168                 fprintf(test_out, "test1: invalid results from unpack of dest buffer\n");
 169                 return(false);
 170             }
 171         }
 172     }
 173 
 174     for (i=0; i<NUM_ITERS; i++) {
 175         int j;
 176         int32_t count;
 177 
 178         for(j=0; j<NUM_ELEMS; j++)
 179             dst32[j] = -1;
 180 
 181         count = NUM_ELEMS;
 182         rc = opal_dss.unpack(bufB, dst32, &count, OPAL_INT32);
 183         if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
 184             fprintf(test_out, "opal_dss.unpack of dest buffer failed with return code %d\n", rc);
 185             return(false);
 186         }
 187 
 188         for(j=0; j<NUM_ELEMS; j++) {
 189             if(src32[j] != dst32[j]) {
 190                 fprintf(test_out, "test1: invalid results from unpack of dest buffer\n");
 191                 return(false);
 192             }
 193         }
 194     }
 195 
 196     
 197     for (i=0; i<NUM_ITERS; i++) {
 198         int j;
 199         int32_t count;
 200 
 201         for(j=0; j<NUM_ELEMS; j++)
 202             dst[j] = -1;
 203 
 204         count = NUM_ELEMS;
 205         rc = opal_dss.unpack(bufA, dst, &count, OPAL_INT16);
 206         if (OPAL_SUCCESS != rc || count != NUM_ELEMS) {
 207             fprintf(test_out, "opal_dss.unpack of src buffer failed with return code %d\n", rc);
 208             return(false);
 209         }
 210 
 211         for(j=0; j<NUM_ELEMS; j++) {
 212             if(src[j] != dst[j]) {
 213                 fprintf(test_out, "test1: invalid results from unpack of src buffer\n");
 214                 return(false);
 215             }
 216         }
 217     }
 218 
 219     OBJ_RELEASE(bufA);
 220     OBJ_RELEASE(bufB);
 221     if (NULL != bufA || NULL != bufB) {
 222         fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n");
 223         return false;
 224     }
 225 
 226     return (true);
 227 }
 228 
 229