GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_DAEMON/main.cpp
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 21 22 95.5%
Branches: 44 44 100.0%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6 ****************************************/
7
8 #include <iostream>
9 #include "phoenix_assert.h"
10 #include "phoenix_check.h"
11 #include "Daemon.h"
12
13 #include "DaemonEmptyBackend.h"
14
15 typedef Daemon<DaemonEmptyBackend> TestDaemon;
16
17 ///Test call of a function
18 /** @param arg : argument
19 * @return result
20 */
21 1 int testCallFunction(int arg){
22 1 return arg + 2;
23 }
24
25 ///Test call of a function
26 /** @param arg : argument
27 */
28 void testCallFunctionVoid(int arg){
29
30 }
31
32 ///Test the load configuration of a Daemon
33 /** @param fileName : name of the configuration toml file
34 */
35 1 void testBaseDaemonLoadConfig(const PPath & fileName){
36
1/1
✓ Branch 1 taken 1 times.
1 TestDaemon daemon;
37
1/1
✓ Branch 1 taken 1 times.
1 daemon.setSocketMode(PSocketMode::MOCK);
38
1/1
✓ Branch 1 taken 1 times.
1 daemon.setClockMode(PClockMode::MOCK);
39
4/4
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
1 daemon.getLog().setFileName(PPath("Daemon.log"));
40
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(daemon.getLog().open());
41
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(daemon.addCallableMethod(testCallFunction, "testCallFunction"));
42 //The function is added already
43
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(!daemon.addCallableMethod(testCallFunction, "testCallFunction"));
44
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(daemon.addCallableMethod(testCallFunctionVoid, "testCallFunctionVoid"));
45 1 int value(42);
46
1/1
✓ Branch 1 taken 1 times.
1 Data param(phoenix_createData(value));
47
48
1/1
✓ Branch 1 taken 1 times.
1 Data result;
49
2/2
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
1 daemon.callMethod(result, "testCallFunction", param);
50
51
1/1
✓ Branch 1 taken 1 times.
1 int resValue = phoenix_getValueFromData<int>(result);
52
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_check("resValue", resValue, 44));
53 1 }
54
55 1 int main(int argc, char** argv){
56
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 testBaseDaemonLoadConfig(PPath(DAEMON_CONFIG_OK));
57 1 return 0;
58 }
59
60
61