1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2001 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 static char MTestDescrip[] = "Test creating and inserting attributes in \
13 different orders to ensure that the list management code handles all cases.";
16 int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] );
17 int checkNoAttrs( MPI_Comm comm, int n, int key[] );
19 int main( int argc, char *argv[] )
22 int key[3], attrval[3];
26 MTest_Init( &argc, &argv );
29 comm = MPI_COMM_WORLD;
30 /* Create key values */
32 MPI_Keyval_create( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
34 attrval[i] = 1024 * i;
37 /* Insert attribute in several orders. Test after put with get,
38 then delete, then confirm delete with get. */
40 MPI_Attr_put( comm, key[2], &attrval[2] );
41 MPI_Attr_put( comm, key[1], &attrval[1] );
42 MPI_Attr_put( comm, key[0], &attrval[0] );
44 errs += checkAttrs( comm, 3, key, attrval );
46 MPI_Attr_delete( comm, key[0] );
47 MPI_Attr_delete( comm, key[1] );
48 MPI_Attr_delete( comm, key[2] );
50 errs += checkNoAttrs( comm, 3, key );
52 MPI_Attr_put( comm, key[1], &attrval[1] );
53 MPI_Attr_put( comm, key[2], &attrval[2] );
54 MPI_Attr_put( comm, key[0], &attrval[0] );
56 errs += checkAttrs( comm, 3, key, attrval );
58 MPI_Attr_delete( comm, key[2] );
59 MPI_Attr_delete( comm, key[1] );
60 MPI_Attr_delete( comm, key[0] );
62 errs += checkNoAttrs( comm, 3, key );
64 MPI_Attr_put( comm, key[0], &attrval[0] );
65 MPI_Attr_put( comm, key[1], &attrval[1] );
66 MPI_Attr_put( comm, key[2], &attrval[2] );
68 errs += checkAttrs( comm, 3, key, attrval );
70 MPI_Attr_delete( comm, key[1] );
71 MPI_Attr_delete( comm, key[2] );
72 MPI_Attr_delete( comm, key[0] );
74 errs += checkNoAttrs( comm, 3, key );
77 MPI_Keyval_free( &key[i] );
81 MTest_Finalize( errs );
87 int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] )
93 MPI_Attr_get( comm, key[i], &val_p, &flag );
96 fprintf( stderr, "Attribute for key %d not set\n", i );
98 else if (val_p != &attrval[i]) {
100 fprintf( stderr, "Attribute value for key %d not correct\n",
108 int checkNoAttrs( MPI_Comm comm, int n, int key[] )
113 for (i=0; i<n; i++) {
114 MPI_Attr_get( comm, key[i], &val_p, &flag );
117 fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );