Blame test/mpi/attr/attrdeleteget.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *
Packit 0848f5
 *  (C) 2013 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include "mpi.h"
Packit 0848f5
#include "mpitest.h"
Packit 0848f5
Packit 0848f5
int key = MPI_KEYVAL_INVALID;
Packit 0848f5
char a[100];
Packit 0848f5
Packit 0848f5
int delete_fn(MPI_Comm, int, void *, void *);
Packit 0848f5
Packit 0848f5
int main(int argc, char **argv)
Packit 0848f5
{
Packit 0848f5
    MPI_Comm scomm;
Packit 0848f5
    int errs = 0;
Packit 0848f5
Packit 0848f5
    MTest_Init(&argc, &argv);
Packit 0848f5
    MPI_Comm_split(MPI_COMM_WORLD, 1, 0, &scomm);
Packit 0848f5
    MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &key, &errs);
Packit 0848f5
    MPI_Comm_set_attr(scomm, key, a);
Packit 0848f5
    MPI_Comm_free(&scomm);
Packit 0848f5
    MPI_Comm_free_keyval(&key);
Packit 0848f5
    MTest_Finalize(errs);
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
    return 0;
Packit 0848f5
}
Packit 0848f5
Packit 0848f5
int delete_fn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
Packit 0848f5
{
Packit 0848f5
    /* The standard is not explicit that the 'comm' argument of
Packit 0848f5
     * delete_fn must be valid, so this test is only in effect when
Packit 0848f5
     * !USE_STRICT_MPI. */
Packit 0848f5
#ifndef USE_STRICT_MPI
Packit 0848f5
    int err, flg, *errs = extra_state;
Packit 0848f5
    void *ptr;
Packit 0848f5
Packit 0848f5
    if (comm == MPI_COMM_NULL) {
Packit 0848f5
        printf("MPI_COMM_NULL passed to delete_fn\n");
Packit 0848f5
        (*errs)++;
Packit 0848f5
    }
Packit 0848f5
    err = MPI_Comm_get_attr(comm, key, &ptr, &flg;;
Packit 0848f5
    if (err != MPI_SUCCESS) {
Packit 0848f5
        printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n",
Packit 0848f5
               err);
Packit 0848f5
        (*errs)++;
Packit 0848f5
    }
Packit 0848f5
#endif
Packit 0848f5
    return 0;
Packit 0848f5
}