Directory: | ./ |
---|---|
File: | TESTS/TEST_DAEMON_RUN/main.cpp |
Date: | 2025-03-14 12:18:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 20 | 20 | 100.0% |
Branches: | 35 | 35 | 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 | ///Create the mock file to be used by the Daemon | ||
18 | /** @param mockName : name of the mock file of the current test | ||
19 | */ | ||
20 | 1 | void createMockFile(const PString & mockName){ | |
21 | 1 | PVecMockMessage vecOutput; | |
22 | |||
23 |
1/1✓ Branch 1 taken 1 times.
|
1 | Message message; |
24 |
1/1✓ Branch 1 taken 1 times.
|
1 | message.setId(0lu); |
25 |
1/1✓ Branch 1 taken 1 times.
|
1 | message.setType(MessageType::STOP); |
26 | |||
27 |
5/5✓ 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.
|
1 | phoenix_assert(phoenix_addMockMessage(vecOutput, message)); |
28 | |||
29 |
5/5✓ 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.
|
1 | phoenix_assert(phoenix_closeMockSocket(vecOutput, mockName)); |
30 | 1 | } | |
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 |
8/8✓ 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 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
|
1 | phoenix_assert(phoenix_check("Message type name", phoenix_getTypeName<Message>(), "Message")); |
37 | |||
38 | //Let's create the mock file | ||
39 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | createMockFile("localhost_3390.pmockbackend"); |
40 | //Let's create and start the Daemon | ||
41 |
1/1✓ Branch 1 taken 1 times.
|
1 | TestDaemon daemon; |
42 |
1/1✓ Branch 1 taken 1 times.
|
1 | daemon.setSocketMode(PSocketMode::MOCK); |
43 |
1/1✓ Branch 1 taken 1 times.
|
1 | daemon.setClockMode(PClockMode::MOCK); |
44 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | daemon.load(fileName, "main"); |
45 |
5/5✓ 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.
|
1 | phoenix_assert(daemon.run()); |
46 | 1 | } | |
47 | |||
48 | 1 | int main(int argc, char** argv){ | |
49 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | testBaseDaemonLoadConfig(PPath(DAEMON_CONFIG_OK)); |
50 | 1 | return 0; | |
51 | } | ||
52 | |||
53 | |||
54 |