Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Finish pulling changes from mpich trunk testsuite
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / big_count_status.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2013 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7
8 #include <mpi.h>
9 #include <assert.h>
10 #include <stdio.h>
11
12 int test_count(MPI_Count count)
13 {
14     MPI_Status stat;
15     int cancelled, cancelled2;
16     MPI_Count bcount, bcount2;
17     int nerrs = 0;
18
19     bcount = count;
20     cancelled = 0;
21     MPI_Status_set_cancelled(&stat, cancelled);
22     MPI_Status_set_elements_x(&stat, MPI_BYTE, bcount);
23     MPI_Get_elements_x(&stat, MPI_BYTE, &bcount2);
24     MPI_Test_cancelled(&stat, &cancelled2);
25     if (bcount != bcount2) {
26         fprintf(stderr, "Count Error: expected %lx, got %lx\n", bcount, bcount2);
27         nerrs++;
28     }
29     if (cancelled != cancelled2) {
30         fprintf(stderr, "Cancelled Error: expected %d, got %d\n", cancelled, cancelled2);
31         nerrs++;
32     }
33     return nerrs;
34 }
35
36 int main(int argc, char **argv)
37 {
38     int nerrors = 0;
39
40     MPI_Init(&argc, &argv);
41     /* baseline: this tiny value should pose no problems */
42     nerrors += test_count(60);
43     /* one with no next-to-high-bits set */
44     nerrors += test_count(0x3654321f71234567);
45     /* masking after shift can help the count_high, but count_low is still
46      * wrong */
47     nerrors += test_count(0x7654321f71234567);
48     /* original problematic count reported by Artem Yalozo */
49     nerrors += test_count(0x7654321ff1234567);
50
51     if (nerrors != 0) {
52         fprintf(stderr, "found %d errors\n", nerrors);
53     }
54     else {
55         printf(" No Errors\n");
56     }
57     MPI_Finalize();
58     return 0;
59 }