root/opal/mca/pmix/pmix4x/pmix/test/test_spawn.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. spawn_cb
  2. test_spawn_common
  3. test_spawn

   1 /*
   2  * Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
   3  * Copyright (c) 2015      Mellanox Technologies, Inc.
   4  *                         All rights reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  *
  11  */
  12 
  13 #include "test_spawn.h"
  14 #include <time.h>
  15 
  16 typedef struct {
  17     int in_progress;
  18     char nspace[PMIX_MAX_NSLEN];
  19 } spawn_cbdata;
  20 
  21 static void spawn_cb(pmix_status_t status,
  22                       char nspace[], void *cbdata)
  23 {
  24     spawn_cbdata *cb = (spawn_cbdata*)cbdata;
  25 
  26     strncpy(cb->nspace, nspace, strlen(nspace)+1);
  27     cb->in_progress = 0;
  28 }
  29 
  30 static int test_spawn_common(char *my_nspace, int my_rank, int blocking)
  31 {
  32     int rc;
  33     pmix_app_t *apps;
  34     size_t napps;
  35     char nspace[PMIX_MAX_NSLEN+1];
  36     memset(nspace, 0, PMIX_MAX_NSLEN+1);
  37     napps = 1;
  38     PMIX_APP_CREATE(apps, napps);
  39     if (blocking) {
  40         if (PMIX_SUCCESS != (rc = PMIx_Spawn(NULL, 0, apps, napps, nspace))) {
  41             PMIX_APP_FREE(apps, napps);
  42             return rc;
  43         }
  44     } else {
  45         spawn_cbdata cbdata;
  46         cbdata.in_progress = 1;
  47         memset(cbdata.nspace, 0, PMIX_MAX_NSLEN);
  48         rc = PMIx_Spawn_nb(NULL, 0, apps, napps, spawn_cb, (void*)&cbdata);
  49         if (PMIX_SUCCESS != rc) {
  50             PMIX_APP_FREE(apps, napps);
  51             return rc;
  52         }
  53         PMIX_WAIT_FOR_COMPLETION(cbdata.in_progress);
  54         strncpy(nspace, cbdata.nspace, strlen(cbdata.nspace)+1);
  55     }
  56     PMIX_APP_FREE(apps, napps);
  57     if (strncmp(nspace, "foobar", strlen(nspace)+1)) {
  58         return PMIX_ERROR;
  59     }
  60     return rc;
  61 }
  62 
  63 int test_spawn(char *my_nspace, int my_rank)
  64 {
  65     int rc;
  66     rc = test_spawn_common(my_nspace, my_rank, 1);
  67     if (PMIX_SUCCESS != rc) {
  68         TEST_ERROR(("%s:%d: Spawn blocking test failed.", my_nspace, my_rank));
  69         return PMIX_ERROR;
  70     }
  71     TEST_VERBOSE(("%s:%d: Spawn blocking test succeded.", my_nspace, my_rank));
  72     rc = test_spawn_common(my_nspace, my_rank, 0);
  73     if (PMIX_SUCCESS != rc) {
  74         TEST_ERROR(("%s:%d: Spawn non-blocking test failed.", my_nspace, my_rank));
  75         return PMIX_ERROR;
  76     }
  77     TEST_VERBOSE(("%s:%d: Spawn non-blocking test succeded.", my_nspace, my_rank));
  78     return PMIX_SUCCESS;
  79 }

/* [<][>][^][v][top][bottom][index][help] */