Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / attr / attrdeleteget.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 <stdio.h>
9 #include "mpi.h"
10 #include "mpitest.h"
11
12 int key = MPI_KEYVAL_INVALID;
13 char a[100];
14
15 int delete_fn(MPI_Comm, int, void *, void *);
16
17 int main(int argc, char **argv)
18 {
19     MPI_Comm scomm;
20     int errs = 0;
21
22     MTest_Init(&argc, &argv);
23     MPI_Comm_split(MPI_COMM_WORLD, 1, 0, &scomm);
24     MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &key, &errs);
25     MPI_Comm_set_attr(scomm, key, a);
26     MPI_Comm_free(&scomm);
27     MPI_Comm_free_keyval(&key);
28     MTest_Finalize(errs);
29     MPI_Finalize();
30     return 0;
31 }
32
33 int delete_fn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
34 {
35     /* The standard is not explicit that the 'comm' argument of
36      * delete_fn must be valid, so this test is only in effect when
37      * !USE_STRICT_MPI. */
38 #ifndef USE_STRICT_MPI
39     int err, flg, *errs = extra_state;
40     void *ptr;
41
42     if (comm == MPI_COMM_NULL) {
43         printf("MPI_COMM_NULL passed to delete_fn\n");
44         (*errs)++;
45     }
46     err = MPI_Comm_get_attr(comm, key, &ptr, &flg);
47     if (err != MPI_SUCCESS) {
48         printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n",
49                err);
50         (*errs)++;
51     }
52 #endif
53     return 0;
54 }