ENABLE_TESTING()
+
FOREACH(_build ${DEAL_II_BUILD_TYPES})
STRING(TOLOWER ${_build} _build_lowercase)
DEAL_II_INSOURCE_SETUP_TARGET(${_target} ${_build})
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK
- COMMAND ${_target} > ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK 2>&1 && echo "${_target}: PASSED." || (rm ${_target}-OK && exit 1)
+ COMMAND ${_target} > ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK 2>&1 || (rm ${_target}-OK && exit 1)
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ ADD_CUSTOM_TARGET(${_target}.run
+ DEPENDS ${_target}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK
+ COMMAND echo "${_target}: PASSED.")
+
+ ADD_TEST(NAME ${_target}
+ COMMAND ${CMAKE_COMMAND} -DTRGT=${_target}.run -DTEST=${_target}
+ -DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
+ -P ${CMAKE_SOURCE_DIR}/cmake/scripts/run_test.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ SET_TESTS_PROPERTIES(${_target} PROPERTIES LABEL "sanity checks")
+
+
+ # test MPI
+ SET(_target mpi.${_build_lowercase})
+
+ ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL mpi.cc)
+ DEAL_II_INSOURCE_SETUP_TARGET(${_target} ${_build})
+
+ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK
+ COMMAND mpirun -n 2 ${_target} > ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK 2>&1 && echo "${_target}: PASSED." || (rm ${_target}-OK && exit 1)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
- ADD_CUSTOM_TARGET(${_target}.run DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK)
+ ADD_CUSTOM_TARGET(${_target}.run
+ DEPENDS ${_target}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_target}-OK
+ COMMAND echo "${_target}: PASSED.")
ADD_TEST(NAME ${_target}
COMMAND ${CMAKE_COMMAND} -DTRGT=${_target}.run -DTEST=${_target}
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// test that MPI is working correctly. Note that this test expects to
+// be executed with exactly two threads.
+
+#include <deal.II/grid/tria.h>
+#include <stdio.h>
+#include <sched.h>
+#include <mpi.h>
+#include <iostream>
+
+int main(int argc, char *argv[] )
+{
+ MPI_Init( &argc, &argv );
+
+ int myrank, nproc;
+ MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+ if (nproc != 2)
+ {
+ std::cerr << "ERROR: process does not see nproc=2!" << std::endl;
+ return -1;
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ int err;
+ int value = myrank;
+
+ if (myrank==1)
+ err = MPI_Send(&value, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+ else if (myrank==0)
+ err = MPI_Recv(&value, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, NULL);
+
+ if (myrank==0 && value!=1)
+ {
+ std::cerr << "ERROR: MPI_Send/Recv did not work!" << std::endl;
+ return -1;
+ }
+
+ value = 1;
+ int output = 0;
+
+ MPI_Allreduce(&value, &output, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ if (output != nproc)
+ {
+ std::cerr << "ERROR: MPI_Allreduce doesn't seem to work!" << std::endl;
+ return -1;
+ }
+
+ // we need this, otherwise gcc will not link against deal.II
+ dealii::Triangulation<2> test;
+
+ MPI_Finalize();
+}