10 #ifndef ERRORHANDLINGFORTESTS_HPP
11 #define ERRORHANDLINGFORTESTS_HPP
13 #include <Zoltan2_config.h>
18 #include <Teuchos_RCP.hpp>
19 #include <Teuchos_Comm.hpp>
20 #include <Teuchos_CommHelpers.hpp>
24 using Teuchos::reduceAll;
26 #define TEST_FAIL_AND_THROW(comm, ok, s){ \
27 int gval, lval=( (ok) ? 0 : 1); \
28 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
30 throw std::runtime_error(std::string(s)); \
34 #define TEST_FAIL_AND_EXIT(comm, ok, s, code){ \
35 int gval, lval=( (ok) ? 0 : 1); \
36 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
38 if ((comm).getRank() == 0){\
39 std::cerr << "Error: " << s << std::endl;\
40 std::cout << "Error: " << s << std::endl;\
41 std::cout << "FAIL" << std::endl;\
47 #define TEST_FAIL_AND_RETURN(comm, ok, s){ \
48 int gval, lval=( (ok) ? 0 : 1); \
49 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
51 if ((comm).getRank() == 0){\
52 std::cerr << "Error: " << s << std::endl;\
53 std::cout << "Error: " << s << std::endl;\
54 std::cout << "FAIL" << std::endl;\
60 #define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc){ \
61 int gval, lval=( (ok) ? 0 : 1); \
62 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
64 if ((comm).getRank() == 0){\
65 std::cerr << "Error: " << s << std::endl;\
66 std::cout << "Error: " << s << std::endl;\
67 std::cout << "FAIL" << std::endl;\
76 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &
fail, &gfail);
82 int rank = comm.getRank();
83 int nprocs = comm.getSize();
85 for (
int p=0; p < nprocs; p++){
87 std::cout << rank <<
": " << fail << std::endl;
91 if (rank==0) std::cout <<
"FAIL" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
static const std::string fail
int globalFail(const Comm< int > &comm, int fail)