Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix the compilation of MPICH3 tests with the absolute paranoid flags (enable_maintainer)
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / probenull.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2005 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include "mpi.h"
8 #include "mpitest.h"
9
10 /*
11  * This program checks that MPI_Iprobe and MPI_Probe correctly handle
12  * a source of MPI_PROC_NULL
13  */
14
15 int main(int argc, char **argv)
16 {
17     int flag;
18     int errs = 0;
19     MPI_Status status;
20
21     MTest_Init(&argc, &argv);
22
23     MPI_Iprobe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status);
24     if (!flag) {
25         errs++;
26         printf("Iprobe of source=MPI_PROC_NULL returned flag=false\n");
27     }
28     else {
29         if (status.MPI_SOURCE != MPI_PROC_NULL) {
30             printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
31             errs++;
32         }
33         if (status.MPI_TAG != MPI_ANY_TAG) {
34             printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
35             errs++;
36         }
37     }
38     /* If Iprobe failed, probe is likely to as well.  Avoid a possible hang
39      * by testing Probe only if Iprobe test passed */
40     if (errs == 0) {
41         MPI_Probe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status);
42         if (status.MPI_SOURCE != MPI_PROC_NULL) {
43             printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
44             errs++;
45         }
46         if (status.MPI_TAG != MPI_ANY_TAG) {
47             printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
48             errs++;
49         }
50     }
51
52     MTest_Finalize(errs);
53     MPI_Finalize();
54     return 0;
55 }