Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / waitany-null.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "mpitestconf.h"
9 #ifdef HAVE_STRING_H
10 #include <string.h>
11 #endif
12 #include "mpi.h"
13
14 static int verbose = 0;
15
16 int main(int argc, char *argv[]);
17 int parse_args(int argc, char **argv);
18
19 int main(int argc, char *argv[])
20 {
21     int i, err, errs = 0, rank, toterrs;
22
23     int         index;
24     MPI_Request requests[10];
25     MPI_Status  statuses[10];
26
27     MPI_Init(&argc, &argv);
28     parse_args(argc, argv);
29
30     for (i=0; i < 10; i++) {
31         requests[i] = MPI_REQUEST_NULL;
32     }
33
34     /* begin testing */
35     /* To improve reporting of problems about operations, we
36        change the error handler to errors return */
37     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
38
39     err = MPI_Waitany(10, requests, &index, statuses);
40
41     if (err != MPI_SUCCESS) {
42         errs++;
43         fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
44     }
45
46     if (index != MPI_UNDEFINED) {
47         errs++;
48         fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
49     }
50
51     /* end testing */
52     
53     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
54     MPI_Comm_rank( MPI_COMM_WORLD, & rank );
55     MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
56     if (rank == 0) {
57         if (toterrs) {
58             fprintf(stderr, " Found %d errors\n", toterrs);
59         }
60         else {
61             printf(" No Errors\n");
62         }
63     }
64     MPI_Finalize();
65     return 0;
66 }
67
68 int parse_args(int argc, char **argv)
69 {
70     /*
71     int ret;
72
73     while ((ret = getopt(argc, argv, "v")) >= 0)
74     {
75         switch (ret) {
76             case 'v':
77                 verbose = 1;
78                 break;
79         }
80     }
81     */
82     if (argc > 1 && strcmp(argv[1], "-v") == 0)
83         verbose = 1;
84     return 0;
85 }