46 #ifndef ERRORHANDLINGFORTESTS_HPP
47 #define ERRORHANDLINGFORTESTS_HPP
49 #include <Zoltan2_config.h>
54 #include <Teuchos_RCP.hpp>
55 #include <Teuchos_Comm.hpp>
56 #include <Teuchos_CommHelpers.hpp>
60 using Teuchos::reduceAll;
62 #define TEST_FAIL_AND_THROW(comm, ok, s){ \
63 int gval, lval=( (ok) ? 0 : 1); \
64 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
66 throw std::runtime_error(std::string(s)); \
70 #define TEST_FAIL_AND_EXIT(comm, ok, s, code){ \
71 int gval, lval=( (ok) ? 0 : 1); \
72 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
74 if ((comm).getRank() == 0){\
75 std::cerr << "Error: " << s << std::endl;\
76 std::cout << "Error: " << s << std::endl;\
77 std::cout << "FAIL" << std::endl;\
83 #define TEST_FAIL_AND_RETURN(comm, ok, s){ \
84 int gval, lval=( (ok) ? 0 : 1); \
85 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
87 if ((comm).getRank() == 0){\
88 std::cerr << "Error: " << s << std::endl;\
89 std::cout << "Error: " << s << std::endl;\
90 std::cout << "FAIL" << std::endl;\
96 #define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc){ \
97 int gval, lval=( (ok) ? 0 : 1); \
98 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &lval, &gval);\
100 if ((comm).getRank() == 0){\
101 std::cerr << "Error: " << s << std::endl;\
102 std::cout << "Error: " << s << std::endl;\
103 std::cout << "FAIL" << std::endl;\
112 reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &
fail, &gfail);
118 int rank = comm.getRank();
119 int nprocs = comm.getSize();
121 for (
int p=0; p < nprocs; p++){
123 std::cout << rank <<
": " << fail << std::endl;
127 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)