GCC Code Coverage Report


Directory: ./
File: utils/main-utests.cc
Date: 2025-09-01 06:19:01
Exec Total Coverage
Lines: 14 18 77.8%
Functions: 1 1 100.0%
Branches: 6 15 40.0%

Line Branch Exec Source
1 #include "na64calib/manager.hh"
2 #include "na64sw-config.h"
3 #include "na64util/gsl-integration.hh"
4
5 #include "na64utest/testing-environment.hh"
6
7 //#include "log4cpp/Category.hh"
8 //#include "log4cpp/Appender.hh"
9 //#include "log4cpp/FileAppender.hh"
10 //#include "log4cpp/OstreamAppender.hh"
11 //#include "log4cpp/Layout.hh"
12 //#include "log4cpp/BasicLayout.hh"
13 //#include "log4cpp/Priority.hh"
14
15 #include <gtest/gtest.h>
16 #include <list>
17
18 #include <gsl/gsl_errno.h>
19
20 #if defined(ROOT_FOUND) && ROOT_FOUND
21 # include "na64util/ROOT-sighandlers.hh"
22 #endif
23
24 /**\file main.cc
25 * \brief Unit tests launcher
26 *
27 * Besides of usual GTest options (printed with -h option given to executable),
28 * this program check for two environment variables that are useful during
29 * development and/or CI/CD:
30 * * LOGLEVEL -- is provided to logging subsystem global NA64DP severity. It
31 * effectively accepts only "DEBUG" option making output extremely loquations
32 * (though, desirable during debugging).
33 * * LOGFILE -- should refer to file where log must be printed. Useful for
34 * generating automated reports on remote deployment or testing environment.
35 * */
36
37 int
38 1 main(int argc, char* argv[]) {
39 // disable ROOT signal handlers if ROOT has been found (it will unavoidably
40 // pollute sighandler table on the linkage stage)
41 #if defined(ROOT_FOUND) && ROOT_FOUND
42 {
43 1 const char * v = getenv("KEEP_ROOT_SIGHANDLERS");
44
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
1 if( !v || !(v && ('1' == v[0] && '\0' == v[1] )) ) {
45 1 disable_ROOT_sighandlers();
46 } else {
47 std::cerr << "ROOT signal handlers are kept." << std::endl;
48 }
49 }
50 #endif
51
52 1 /*old_handler = */ gsl_set_error_handler( na64dp::errors::GSLError::na64sw_gsl_error_handler );
53
54 1 ::testing::InitGoogleTest(&argc, argv);
55 // NOTE: argc/argv got modified here, so tests can retrieve their arguments
56 // ...?
57
58 1 const char * pLvlStr = getenv("LOGLEVEL");
59 1 log4cpp::Priority::PriorityLevel pLvl = log4cpp::Priority::FATAL;
60
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
1 if( NULL == pLvlStr || !strcmp("FATAL", pLvlStr) ) {
61 1 pLvl = log4cpp::Priority::FATAL;
62 } else if( !strcmp("DEBUG", pLvlStr) ) {
63 pLvl = log4cpp::Priority::DEBUG;
64 } else {
65 std::cerr << "Ignoring $LOGLEVEL=\"" << pLvlStr
66 << "\" -- only DEBUG and FATAL are allowed. Log level kept"
67 " as FATAL." << std::endl;
68 }
69
70 1 const char * oFile = getenv("LOGFILE");
71
72 // gtest takes ownership of the TestEnvironment ptr - we don't delete it.
73
1/2
✓ Branch 1 taken 1 times.
✗ Branch 4 not taken.
1 ::testing::AddGlobalTestEnvironment( new na64dp::test::Environment( pLvl,
74
3/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
3 oFile ? oFile : "") );
75 1 return RUN_ALL_TESTS();
76 }
77
78