root/test/util/orte_universe_setup_file_io.c

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

DEFINITIONS

This source file includes following definitions.
  1. main
  2. test1
  3. test2

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * $COPYRIGHT$
  13  *
  14  * Additional copyrights may follow
  15  *
  16  * $HEADER$
  17  */
  18 
  19 #include "orte_config.h"
  20 #include "orte/constants.h"
  21 
  22 #include <stdio.h>
  23 #include <string.h>
  24 #include <stdlib.h>
  25 #ifdef HAVE_SYS_PARAM_H
  26 #include <sys/param.h>
  27 #endif
  28 
  29 #include "orte/util/univ_info.h"
  30 #include "orte/util/universe_setup_file_io.h"
  31 #include "support.h"
  32 
  33 static bool test1(void);   /* verify it returns info */
  34 static bool test2(void);   /* test second time through */
  35 
  36 orte_universe_t orte_universe_info;
  37 
  38 int main(int argc, char* argv[])
  39 {
  40     test_init("universe_setup_file_io");
  41 
  42     /* initialize the univ_info structure */
  43     orte_universe_info.name = strdup("default-universe");
  44     orte_universe_info.host = strdup("test-host.domain.org");
  45     orte_universe_info.uid = strdup("this-is-me");
  46     orte_universe_info.persistence = true;
  47     orte_universe_info.scope = strdup("private");
  48     orte_universe_info.console = false;
  49     orte_universe_info.seed_uri = strdup("0.0.0;tcp://128.165.148.81:52424");
  50     orte_universe_info.console_connected = false;
  51     orte_universe_info.scriptfile = NULL;
  52 
  53     if (test1()) {
  54         test_success();
  55     }
  56     else {
  57       test_failure("universe_setup_file_io write failed");
  58     }
  59 
  60     if (test2()) {
  61         test_success();
  62     }
  63     else {
  64       test_failure("universe_setup_file_io read failed");
  65     }
  66 
  67     test_finalize();
  68     return 0;
  69 }
  70 
  71 
  72 static bool test1(void)
  73 {
  74     int rc;
  75 
  76     /* Test write */
  77 
  78     if (ORTE_SUCCESS != (rc = orte_write_universe_setup_file("test-file", &orte_universe_info))) {
  79         fprintf(stderr, "universe_setup_file_io: failed write with code %d\n", rc);
  80         return false;
  81     }
  82 
  83     return true;
  84 }
  85 
  86 
  87 static bool test2(void)
  88 {
  89     int rc;
  90     orte_universe_t univ;
  91 
  92     /* Test read */
  93 
  94     if (ORTE_SUCCESS != (rc = orte_read_universe_setup_file("test-file", &univ))) {
  95         fprintf(stderr, "universe_setup_file_io: failed read with code %d\n", rc);
  96         return false;
  97     }
  98 
  99     if (0 != strcmp(orte_universe_info.name, univ.name) ||
 100         0 != strcmp(orte_universe_info.host, univ.host) ||
 101         0 != strcmp(orte_universe_info.uid, univ.uid) ||
 102         orte_universe_info.persistence != univ.persistence ||
 103         0 != strcmp(orte_universe_info.scope, univ.scope) ||
 104         orte_universe_info.console != univ.console ||
 105         0 != strcmp(orte_universe_info.seed_uri, univ.seed_uri) ||
 106         orte_universe_info.console_connected != univ.console_connected ||
 107         orte_universe_info.scriptfile != univ.scriptfile) {
 108         fprintf(stderr, "universe_setup_file_io: read mismatch\n");
 109         return false;
 110     }
 111 
 112     return true;
 113 }

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