Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / errhan / adderr.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "mpitest.h"
11 #include "mpitestconf.h"
12 #ifdef HAVE_STRING_H
13 #include <string.h>
14 #endif
15
16 /* Create NCLASSES new classes, each with 5 codes (160 total) */
17 #define NCLASSES 32
18 #define NCODES   5
19
20 int main(int argc, char *argv[])
21 {
22     int errs = 0;
23     char string[MPI_MAX_ERROR_STRING], outstring[MPI_MAX_ERROR_STRING];
24     int newclass[NCLASSES], newcode[NCLASSES][NCODES];
25     int i, j, slen, outclass;
26
27     MTest_Init(&argc, &argv);
28
29     /* Initialize the new codes */
30     for (i = 0; i < NCLASSES; i++) {
31         MPI_Add_error_class(&newclass[i]);
32         for (j = 0; j < NCODES; j++) {
33             MPI_Add_error_code(newclass[i], &newcode[i][j]);
34             sprintf(string, "code for class %d code %d\n", i, j);
35             MPI_Add_error_string(newcode[i][j], string);
36         }
37     }
38
39     /* check the values */
40     for (i = 0; i < NCLASSES; i++) {
41         MPI_Error_class(newclass[i], &outclass);
42         if (outclass != newclass[i]) {
43             errs++;
44             printf("Error class %d is not a valid error code %d %d\n", i, outclass, newclass[i]);
45         }
46         for (j = 0; j < NCODES; j++) {
47             MPI_Error_class(newcode[i][j], &outclass);
48             if (outclass != newclass[i]) {
49                 errs++;
50                 printf("Class of code for %d is not correct %d %d\n", j, outclass, newclass[i]);
51             }
52             MPI_Error_string(newcode[i][j], outstring, &slen);
53             sprintf(string, "code for class %d code %d\n", i, j);
54             if (strcmp(outstring, string)) {
55                 errs++;
56                 printf("Error string is :%s: but should be :%s:\n", outstring, string);
57             }
58         }
59     }
60
61     MTest_Finalize(errs);
62     MPI_Finalize();
63     return MTestReturnValue(errs);
64 }