root/test/util/opal_error.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

   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 "ompi_config.h"
  20 
  21 #include <stdio.h>
  22 #include <string.h>
  23 #include <stdlib.h>
  24 #ifdef HAVE_SYS_PARAM_H
  25 #include <sys/param.h>
  26 #endif
  27 #ifdef HAVE_NETINET_IN_H
  28 #include <netinet/in.h>
  29 #endif
  30 #ifdef HAVE_UNISTD_H
  31 #include <unistd.h>
  32 #endif
  33 #ifdef HAVE_NETDB_H
  34 #include <netdb.h>
  35 #endif
  36 #include <errno.h>
  37 
  38 #include "opal/util/error.h"
  39 #include "opal/constants.h"
  40 #include "opal/runtime/opal.h"
  41 #include "orte/constants.h"
  42 
  43 int
  44 main(int argc, char *argv[])
  45 {
  46     int i;
  47     int errors[] = { OPAL_SUCCESS,
  48                      OPAL_ERROR,
  49                      OPAL_ERR_OUT_OF_RESOURCE,
  50                      OPAL_ERR_NOT_FOUND,
  51                      OPAL_ERR_BAD_PARAM,
  52                      OPAL_ERR_MAX + 10, /* bad value */
  53                      1 }; /* sentinal */
  54     char buf[1024];
  55 
  56     opal_init(&argc, &argv);
  57 
  58     for (i = 0 ; errors[i] <= 0 ; ++i) {
  59         printf("--> error code: %d\n", errors[i]);
  60         opal_perror(errors[i], "perror test");
  61         printf("strerror test: %s\n", opal_strerror(errors[i]));
  62         opal_strerror_r(errors[i], buf, sizeof(buf));
  63         printf("strerror_r test: %s\n", buf);
  64     }
  65 
  66     printf("--> error in errno test\n");
  67     errno = EINVAL;
  68     opal_perror(OPAL_ERR_IN_ERRNO, "perror test");
  69     errno = EINVAL;
  70     printf("strerror test: %s\n", opal_strerror(OPAL_ERR_IN_ERRNO));
  71     errno = EINVAL;
  72     opal_strerror_r(OPAL_ERR_IN_ERRNO, buf, sizeof(buf));
  73     printf("strerror_r test: %s\n", buf);
  74 
  75     printf("--> orte error test\n");
  76     opal_perror(ORTE_ERR_BUFFER, "orte test");
  77 
  78     printf("--> orte unknown error test\n");
  79     opal_perror(ORTE_ERR_MAX + 10, "orte unknown test");
  80 
  81     printf("--> unknown error test\n");
  82     opal_perror(ORTE_ERR_MAX - 200, "unknown error");
  83 
  84     opal_finalize();
  85 
  86     return 0;
  87 }

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