Zoltan2
Loading...
Searching...
No Matches
test
core
helpers
ErrorHandlingForTests.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Zoltan2: A package of combinatorial algorithms for scientific computing
4
//
5
// Copyright 2012 NTESS and the Zoltan2 contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef ERRORHANDLINGFORTESTS_HPP
11
#define ERRORHANDLINGFORTESTS_HPP
12
13
#include <Zoltan2_config.h>
14
#include <iostream>
15
#include <string>
16
#include <exception>
17
18
#include <Teuchos_RCP.hpp>
19
#include <Teuchos_Comm.hpp>
20
#include <Teuchos_CommHelpers.hpp>
21
22
using
Teuchos::RCP;
23
using
Teuchos::Comm;
24
using
Teuchos::reduceAll;
25
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);\
29
if (gval){ \
30
throw std::runtime_error(std::string(s)); \
31
} \
32
}
33
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);\
37
if (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;\
42
} \
43
exit(code);\
44
} \
45
}
46
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);\
50
if (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;\
55
} \
56
return; \
57
} \
58
}
59
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);\
63
if (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;\
68
} \
69
return (rc); \
70
} \
71
}
72
73
int
globalFail
(
const
Comm<int> &comm,
int
fail
)
74
{
75
int
gfail=0;
76
reduceAll<int,int>(comm, Teuchos::REDUCE_SUM, 1, &
fail
, &gfail);
77
return
gfail;
78
}
79
80
void
printFailureCode
(
const
Comm<int> &comm,
int
fail
)
81
{
82
int
rank = comm.getRank();
83
int
nprocs = comm.getSize();
84
comm.barrier();
85
for
(
int
p=0; p < nprocs; p++){
86
if
(p == rank)
87
std::cout << rank <<
": "
<<
fail
<< std::endl;
88
comm.barrier();
89
}
90
comm.barrier();
91
if
(rank==0) std::cout <<
"FAIL"
<< std::endl;
92
exit(1);
93
}
94
95
#endif
globalFail
int globalFail(const Comm< int > &comm, int fail)
Definition
ErrorHandlingForTests.hpp:73
printFailureCode
void printFailureCode(const Comm< int > &comm, int fail)
Definition
ErrorHandlingForTests.hpp:80
fail
static const std::string fail
Definition
findUniqueGids.cpp:45
Generated by
1.9.8