Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
this tests actually does not conform to the standard and crashed now, but it's OK...
[simgrid.git] / teshsuite / smpi / mpich3-test / attr / keyval_double_free_comm.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2009 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include <mpi.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include "mpitest.h"
11
12 /* tests multiple invocations of MPI_Comm_free_keyval on the same keyval */
13
14 int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra);
15 int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra)
16 {
17     MPI_Comm_free_keyval(&keyval);
18     return MPI_SUCCESS;
19 }
20
21 int main(int argc, char **argv)
22 {
23     MPI_Comm duped;
24     int keyval = MPI_KEYVAL_INVALID;
25     int keyval_copy = MPI_KEYVAL_INVALID;
26     int errs = 0;
27
28     MTest_Init(&argc, &argv);
29     MPI_Comm_dup(MPI_COMM_SELF, &duped);
30
31     MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
32     keyval_copy = keyval;
33
34     MPI_Comm_set_attr(MPI_COMM_SELF, keyval, NULL);
35     MPI_Comm_set_attr(duped, keyval, NULL);
36
37     MPI_Comm_free(&duped);      /* first MPI_Comm_free_keyval */
38     MPI_Comm_free_keyval(&keyval);   /* second MPI_Comm_free_keyval */
39     MPI_Comm_free_keyval(&keyval_copy);      /* third MPI_Comm_free_keyval */
40     MTest_Finalize(errs);
41     MPI_Finalize();     /* fourth MPI_Comm_free_keyval */
42     return 0;
43 }