NEURON
catch2_main.cpp
Go to the documentation of this file.
1
#include <catch2/catch_session.hpp>
2
#include <catch2/catch_test_macros.hpp>
3
4
#include "
code.h
"
5
#include "
neuron.h
"
6
#include "nrnmpi.h"
7
#include "
ocfunc.h
"
8
#include "
section.h
"
9
#include "
multicore.h
"
10
11
#include <exception>
12
13
int
ivocmain_session
(
int
,
const
char
**,
const
char
**,
int
);
14
extern
int
nrn_main_launch
;
15
extern
int
nrn_nobanner_
;
16
17
/// Needed for compilation
18
extern
"C"
void
modl_reg
() {}
19
#if NRNMPI_DYNAMICLOAD
20
void
nrnmpi_stubs();
21
#endif
22
23
namespace
nrn::test
{
24
int
PROCESSORS
{0};
25
int
MAX_PROCESSORS
{
nrn_how_many_processors
()};
26
}
// namespace nrn::test
27
28
#ifdef NRN_COVERAGE_ENABLED
29
// works with AppleClang 14, other sources suggest __gcov_flush.
30
extern
"C"
void
__gcov_dump();
31
#endif
32
namespace
{
33
void
new_handler() {
34
#ifdef NRN_COVERAGE_ENABLED
35
__gcov_dump();
36
#endif
37
}
38
}
// namespace
39
40
int
main
(
int
argc
,
char
*
argv
[]) {
41
std::set_terminate(new_handler);
42
43
// global setup...
44
nrn_main_launch
= 2;
45
int
argc_nompi = 2;
46
const
char
* argv_nompi[] = {
"NEURON"
,
"-nogui"
,
nullptr
};
47
nrn_nobanner_
= 1;
48
49
#if NRNMPI && NRNMPI_DYNAMICLOAD
50
if
(!
nrnmpi_use
) {
51
nrnmpi_stubs();
52
}
53
#endif
54
55
Catch::Session
session{};
56
57
using namespace
Catch::Clara;
58
auto
cli = session.cli() |
59
Opt(
nrn::test::PROCESSORS
,
"number of PROCESSORS to consider"
)[
"--processors"
](
60
"How many processors are available for perf tests"
);
61
62
session.cli(cli);
63
64
int
returnCode = session.applyCommandLine(
argc
,
argv
);
65
if
(returnCode != 0)
// Indicates a command line error
66
return
returnCode;
67
68
if
(
nrn::test::PROCESSORS
> 0) {
69
std::cout <<
"[cli][input] --processors="
<<
nrn::test::PROCESSORS
<< std::endl;
70
nrn::test::MAX_PROCESSORS
= std::min(
nrn::test::PROCESSORS
,
nrn_how_many_processors
());
71
}
72
std::cout <<
"MAX_PROCESSORS="
<<
nrn::test::MAX_PROCESSORS
<< std::endl;
73
74
ivocmain_session
(argc_nompi, argv_nompi,
nullptr
, 0);
75
#undef run
76
return
session.run();
77
}
main
int main(int argc, char *argv[])
Definition:
catch2_main.cpp:40
modl_reg
void modl_reg()
Needed for compilation.
Definition:
catch2_main.cpp:18
nrn_nobanner_
int nrn_nobanner_
Definition:
hoc.cpp:119
nrn_main_launch
int nrn_main_launch
Definition:
hoc_init.cpp:333
ivocmain_session
int ivocmain_session(int, const char **, const char **, int)
This used to be ivocmain, the main entrypoint to the HOC interpreter.
Definition:
ivocmain.cpp:361
code.h
argc
static int argc
Definition:
inithoc.cpp:45
argv
static char ** argv
Definition:
inithoc.cpp:46
Session
#define Session
Definition:
ivocmain.cpp:9
multicore.h
nrnmpi_use
static int nrnmpi_use
Definition:
multisplit.cpp:41
nrn::test
Definition:
test_multicore.h:7
nrn::test::MAX_PROCESSORS
int MAX_PROCESSORS
Definition:
catch2_main.cpp:25
nrn::test::PROCESSORS
int PROCESSORS
Definition:
catch2_main.cpp:24
neuron.h
nrn_how_many_processors
int nrn_how_many_processors()
Definition:
multicore.cpp:1038
ocfunc.h
section.h
test
common
catch2_main.cpp