Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / attr / keyval_double_free.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 Keyval_free 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     MPI_Keyval_free(&keyval);
17     return MPI_SUCCESS;
18 }
19
20 int main (int argc, char **argv)
21 {
22     MPI_Comm duped;
23     int keyval = MPI_KEYVAL_INVALID;
24     int keyval_copy = MPI_KEYVAL_INVALID;
25     int errs=0;
26
27     MTest_Init( &argc, &argv );
28     MPI_Comm_dup(MPI_COMM_SELF, &duped);
29
30     MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn,  &keyval, NULL);
31     keyval_copy = keyval;
32
33     MPI_Attr_put(MPI_COMM_SELF, keyval, NULL);
34     MPI_Attr_put(duped, keyval, NULL);
35
36     MPI_Comm_free(&duped);         /* first MPI_Keyval_free */
37     MPI_Keyval_free(&keyval);      /* second MPI_Keyval_free */
38     MPI_Keyval_free(&keyval_copy); /* third MPI_Keyval_free */
39     MTest_Finalize( errs );
40     MPI_Finalize();                /* fourth MPI_Keyval_free */
41     return 0;
42 }