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_type.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2015 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_Type_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_Type_free_keyval(&keyval);
18     return MPI_SUCCESS;
19 }
20
21 int main(int argc, char **argv)
22 {
23     MPI_Datatype type;
24     MPI_Datatype type_dup;
25     int keyval = MPI_KEYVAL_INVALID;
26     int keyval_copy = MPI_KEYVAL_INVALID;
27     int errs = 0;
28
29     MTest_Init(&argc, &argv);
30     MPI_Type_dup(MPI_INT, &type);
31     MPI_Type_dup(MPI_INT, &type_dup);
32
33     MPI_Type_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
34     keyval_copy = keyval;
35     MPI_Type_set_attr(type, keyval, NULL);
36     MPI_Type_set_attr(type_dup, keyval, NULL);
37
38     MPI_Type_free(&type);      /* first MPI_Type_free_keyval */
39     MPI_Type_free_keyval(&keyval);   /* second MPI_Type_free_keyval */
40     MPI_Type_free_keyval(&keyval_copy);      /* third MPI_Type_free_keyval */
41     MPI_Type_free(&type_dup);      /* fourth MPI_Type_free_keyval */
42     MTest_Finalize(errs);
43     MPI_Finalize();
44     return 0;
45 }