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_Win win, int n, int key[], int attrval[] );
17 int checkNoAttrs( MPI_Win win, int n, int key[] );
19 int main( int argc, char *argv[] )
22 int key[3], attrval[3];
28 MTest_Init( &argc, &argv );
31 comm = MPI_COMM_WORLD;
32 MPI_Win_create( buf, sizeof(int), sizeof(int), MPI_INFO_NULL,
35 /* Create key values */
37 MPI_Win_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
39 attrval[i] = 1024 * i;
42 /* Insert attribute in several orders. Test after put with get,
43 then delete, then confirm delete with get. */
45 MPI_Win_set_attr( win, key[2], &attrval[2] );
46 MPI_Win_set_attr( win, key[1], &attrval[1] );
47 MPI_Win_set_attr( win, key[0], &attrval[0] );
49 errs += checkAttrs( win, 3, key, attrval );
51 MPI_Win_delete_attr( win, key[0] );
52 MPI_Win_delete_attr( win, key[1] );
53 MPI_Win_delete_attr( win, key[2] );
55 errs += checkNoAttrs( win, 3, key );
57 MPI_Win_set_attr( win, key[1], &attrval[1] );
58 MPI_Win_set_attr( win, key[2], &attrval[2] );
59 MPI_Win_set_attr( win, key[0], &attrval[0] );
61 errs += checkAttrs( win, 3, key, attrval );
63 MPI_Win_delete_attr( win, key[2] );
64 MPI_Win_delete_attr( win, key[1] );
65 MPI_Win_delete_attr( win, key[0] );
67 errs += checkNoAttrs( win, 3, key );
69 MPI_Win_set_attr( win, key[0], &attrval[0] );
70 MPI_Win_set_attr( win, key[1], &attrval[1] );
71 MPI_Win_set_attr( win, key[2], &attrval[2] );
73 errs += checkAttrs( win, 3, key, attrval );
75 MPI_Win_delete_attr( win, key[1] );
76 MPI_Win_delete_attr( win, key[2] );
77 MPI_Win_delete_attr( win, key[0] );
79 errs += checkNoAttrs( win, 3, key );
82 MPI_Win_free_keyval( &key[i] );
87 MTest_Finalize( errs );
93 int checkAttrs( MPI_Win win, int n, int key[], int attrval[] )
99 MPI_Win_get_attr( win, key[i], &val_p, &flag );
102 fprintf( stderr, "Attribute for key %d not set\n", i );
104 else if (val_p != &attrval[i]) {
106 fprintf( stderr, "Atribute value for key %d not correct\n",
114 int checkNoAttrs( MPI_Win win, int n, int key[] )
119 for (i=0; i<n; i++) {
120 MPI_Win_get_attr( win, key[i], &val_p, &flag );
123 fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );