From: Augustin Degomme Date: Fri, 17 Nov 2023 22:12:39 +0000 (+0100) Subject: one more test for attr X-Git-Tag: v3.35~23 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8bd25d18b5b13783fe7fa8e1c7b3961f2bf5e0dc one more test for attr --- diff --git a/teshsuite/smpi/mpich3-test/attr/CMakeLists.txt b/teshsuite/smpi/mpich3-test/attr/CMakeLists.txt index 05d62546cd..c8b178dbe5 100644 --- a/teshsuite/smpi/mpich3-test/attr/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/attr/CMakeLists.txt @@ -5,7 +5,7 @@ if(enable_smpi AND enable_testsuite_smpi_MPICH3) include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/") - foreach(file attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt + foreach(file attr2type attrdelete attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt baseattr2 baseattrcomm fkeyval fkeyvalcomm fkeyvaltype keyval_double_free) #attric add_executable(${file} EXCLUDE_FROM_ALL ${file}.c) add_dependencies(tests ${file}) @@ -18,7 +18,7 @@ if (enable_testsuite_smpi_MPICH3 AND HAVE_RAW_CONTEXTS) SET_TESTS_PROPERTIES(test-smpi-mpich3-attr-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!") endif() -foreach(file attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt +foreach(file attr2type attrdelete attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt baseattr2 baseattrcomm fkeyval attric fkeyvalcomm fkeyvaltype keyval_double_free keyval_double_free_comm keyval_double_free_type keyval_double_free_win) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c) endforeach() diff --git a/teshsuite/smpi/mpich3-test/attr/attrdelete.c b/teshsuite/smpi/mpich3-test/attr/attrdelete.c new file mode 100644 index 0000000000..05f03e973b --- /dev/null +++ b/teshsuite/smpi/mpich3-test/attr/attrdelete.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +/* + Having attr delete function to delete another attribute. + */ +#include "mpi.h" +#include "mpitest.h" +#include + +int key1, key2, key3; + +int test_communicator(MPI_Comm comm); + +int main(int argc, char **argv) +{ + int errs; + MTest_Init(&argc, &argv); + errs = test_communicator(MPI_COMM_WORLD); + MTest_Finalize(errs); + return MTestReturnValue(errs); +} + +static int key2_delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state) +{ + MPI_Comm_delete_attr(comm, key1); + MPI_Comm_delete_attr(comm, key3); + return MPI_SUCCESS; +} + +int test_communicator(MPI_Comm comm) +{ + int errs = 0; + int rank, size; + + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + + MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key1, NULL); + MPI_Comm_create_keyval(MPI_NULL_COPY_FN, key2_delete_fn, &key2, NULL); + MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key3, NULL); + + MPI_Comm_set_attr(comm, key1, (void *) (MPI_Aint) rank); + MPI_Comm_set_attr(comm, key2, (void *) (MPI_Aint) (rank + 100)); + MPI_Comm_set_attr(comm, key3, (void *) (MPI_Aint) (rank + 200)); + + MPI_Comm_delete_attr(comm, key2); + + MPI_Comm_free_keyval(&key1); + MPI_Comm_free_keyval(&key2); + MPI_Comm_free_keyval(&key3); + + return errs; +} diff --git a/teshsuite/smpi/mpich3-test/attr/testlist b/teshsuite/smpi/mpich3-test/attr/testlist index 56fb8c5c9b..e8577c67b7 100644 --- a/teshsuite/smpi/mpich3-test/attr/testlist +++ b/teshsuite/smpi/mpich3-test/attr/testlist @@ -13,6 +13,7 @@ attrerr 1 #attrend2 5 attrerrcomm 1 attrerrtype 1 +attrdelete 1 attrdeleteget 1 attr2type 1 attrorder 1 diff --git a/teshsuite/smpi/mpich3-test/coll/allred_float.c b/teshsuite/smpi/mpich3-test/coll/allred_float.c index c8d4354f06..6b6ebc610f 100644 --- a/teshsuite/smpi/mpich3-test/coll/allred_float.c +++ b/teshsuite/smpi/mpich3-test/coll/allred_float.c @@ -64,7 +64,7 @@ int main(int argc, char **argv) MPI_Allreduce(MPI_IN_PLACE, buf, N, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD); - float *check_buf; + float *check_buf=NULL; if (rank == 0) { check_buf = malloc(N * size * sizeof(float)); }