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

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

DEFINITIONS

This source file includes following definitions.
  1. cd_cb
  2. cnct_cb
  3. test_connect_disconnect

   1 /*
   2  * Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  *
   9  */
  10 
  11 #include "test_cd.h"
  12 #include <time.h>
  13 
  14 typedef struct {
  15     int in_progress;
  16     int status;
  17     pmix_proc_t pname;
  18 } cd_cbdata;
  19 
  20 static void cd_cb(pmix_status_t status, void *cbdata)
  21 {
  22     cd_cbdata *cb = (cd_cbdata*)cbdata;
  23 
  24     cb->status = status;
  25     cb->in_progress = 0;
  26 }
  27 
  28 static void cnct_cb(pmix_status_t status, void *cbdata)
  29 {
  30     cd_cbdata *cb = (cd_cbdata*)cbdata;
  31 
  32     cb->status = status;
  33     cb->in_progress = 0;
  34 }
  35 
  36 int test_connect_disconnect(char *my_nspace, int my_rank)
  37 {
  38     int rc;
  39     pmix_proc_t proc;
  40     cd_cbdata cbdata;
  41 
  42     (void)strncpy(proc.nspace, my_nspace, PMIX_MAX_NSLEN);
  43     proc.rank = PMIX_RANK_WILDCARD;
  44 
  45     rc = PMIx_Connect(&proc, 1, NULL, 0);
  46     if (PMIX_SUCCESS != rc) {
  47         TEST_ERROR(("%s:%d: Connect blocking test failed.", my_nspace, my_rank));
  48         return PMIX_ERROR;
  49     }
  50     TEST_VERBOSE(("%s:%d: Connect blocking test succeded", my_nspace, my_rank));
  51 
  52     rc = PMIx_Disconnect(&proc, 1, NULL, 0);
  53     if (PMIX_SUCCESS != rc) {
  54         TEST_ERROR(("%s:%d: Disconnect blocking test failed.", my_nspace, my_rank));
  55         return PMIX_ERROR;
  56     }
  57     TEST_VERBOSE(("%s:%d: Disconnect blocking test succeded.", my_nspace, my_rank));
  58 
  59     cbdata.in_progress = 1;
  60     rc = PMIx_Connect_nb(&proc, 1, NULL, 0, cnct_cb, &cbdata);
  61     if (PMIX_SUCCESS == rc) {
  62         PMIX_WAIT_FOR_COMPLETION(cbdata.in_progress);
  63         rc = cbdata.status;
  64     }
  65     if (PMIX_SUCCESS != rc) {
  66         TEST_ERROR(("%s:%d: Connect non-blocking test failed.", my_nspace, my_rank));
  67         return PMIX_ERROR;
  68     }
  69     TEST_VERBOSE(("%s:%d: Connect non-blocking test succeded.", my_nspace, my_rank));
  70 
  71     cbdata.in_progress = 1;
  72     rc = PMIx_Disconnect_nb(&proc, 1, NULL, 0, cd_cb, &cbdata);
  73     if (PMIX_SUCCESS == rc) {
  74         PMIX_WAIT_FOR_COMPLETION(cbdata.in_progress);
  75         rc = cbdata.status;
  76     }
  77     if (PMIX_SUCCESS != rc) {
  78         TEST_ERROR(("%s:%d: Disconnect non-blocking test failed.", my_nspace, my_rank));
  79         return PMIX_ERROR;
  80     }
  81     TEST_VERBOSE(("%s:%d: Disconnect non-blocking test succeded.", my_nspace, my_rank));
  82     return PMIX_SUCCESS;
  83 }

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