| 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 <functional> | ||
| 10 | #include "phoenix_assert.h" | ||
| 11 | #include "phoenix_check.h" | ||
| 12 | |||
| 13 | #include "Shadok.h" | ||
| 14 | #include "ProcessClass.h" | ||
| 15 | #include "Daemon.h" | ||
| 16 | #include "DaemonSlot.h" | ||
| 17 | |||
| 18 | #include "DaemonEmptyBackend.h" | ||
| 19 | |||
| 20 | typedef Daemon<DaemonEmptyBackend> TestDaemon; | ||
| 21 | |||
| 22 | ///Process a Shadok | ||
| 23 | /** @param shadok : Shadok to be processed | ||
| 24 | * @return true on success, false otherwise | ||
| 25 | */ | ||
| 26 | 1 | PUncastableBool testShadokProcessing(const Shadok & shadok){ | |
| 27 | //Let's do something | ||
| 28 | 1 | std::cout << "testShadokProcessing : we are processing a Shadok" << std::endl; | |
| 29 | //I do not know what it was, but is was OK | ||
| 30 | 1 | return UNCASTABLE_TRUE; | |
| 31 | } | ||
| 32 | |||
| 33 | ///Process a Shadok | ||
| 34 | /** @param shadok : Shadok to be processed | ||
| 35 | * @return true on success, false otherwise | ||
| 36 | */ | ||
| 37 | 1 | PUncastableBool testIntProcessing(const int & value){ | |
| 38 | //Let's do something | ||
| 39 | 1 | std::cout << "testIntProcessing : we are processing an int" << std::endl; | |
| 40 | //I do not know what it was, but is was OK | ||
| 41 | 1 | return UNCASTABLE_TRUE; | |
| 42 | } | ||
| 43 | |||
| 44 | ///Test the load configuration of a Daemon | ||
| 45 | /** @param fileName : name of the configuration toml file | ||
| 46 | */ | ||
| 47 | 1 | void testBaseDaemonLoadConfig(const PPath & fileName){ | |
| 48 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | TestDaemon daemon; |
| 49 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | daemon.setSocketMode(PSocketMode::MOCK); |
| 50 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | daemon.setClockMode(PClockMode::MOCK); |
| 51 |
2/2✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
|
1 | daemon.getLog().setLogLevel(PLog::DEBUG); |
| 52 |
4/4✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
✓ Branch 6 (10→11) taken 1 times.
|
1 | daemon.getLog().setFileName(PPath("Daemon.log")); |
| 53 |
6/6✓ Branch 0 (15→16) taken 1 times.
✓ Branch 2 (18→19) taken 1 times.
✓ Branch 4 (21→22) taken 1 times.
✓ Branch 6 (22→23) taken 1 times.
✓ Branch 8 (23→24) taken 1 times.
✓ Branch 10 (24→25) taken 1 times.
|
6 | phoenix_assert(daemon.getLog().open()); |
| 54 |
5/5✓ Branch 0 (33→34) taken 1 times.
✓ Branch 2 (36→37) taken 1 times.
✓ Branch 4 (39→40) taken 1 times.
✓ Branch 6 (40→41) taken 1 times.
✓ Branch 8 (41→42) taken 1 times.
|
6 | phoenix_assert(daemon.addDataCallableMethod(testShadokProcessing, 0, 0.f, 0.f)); |
| 55 |
5/5✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (56→57) taken 1 times.
✓ Branch 6 (57→58) taken 1 times.
✓ Branch 8 (58→59) taken 1 times.
|
5 | phoenix_assert(daemon.addDataCallableMethod(testIntProcessing, 0, 0.f, 0.f)); |
| 56 | //Add a non static method | ||
| 57 |
1/1✓ Branch 0 (65→66) taken 1 times.
|
1 | ProcessClass processClass; |
| 58 |
5/5✓ Branch 0 (68→69) taken 1 times.
✓ Branch 2 (71→72) taken 1 times.
✓ Branch 4 (74→75) taken 1 times.
✓ Branch 6 (75→76) taken 1 times.
✓ Branch 8 (76→77) taken 1 times.
|
6 | phoenix_assert(daemon.addDataCallableMethod(ProcessClass::SWARM_SLOT(fillLong), processClass, 10lu, 0.0, 1e6)); |
| 59 |
5/5✓ Branch 0 (85→86) taken 1 times.
✓ Branch 2 (88→89) taken 1 times.
✓ Branch 4 (91→92) taken 1 times.
✓ Branch 6 (92→93) taken 1 times.
✓ Branch 8 (93→94) taken 1 times.
|
5 | phoenix_assert(daemon.addDataCallableMethod(ProcessClass::SWARM_SLOT(fillShort), processClass, 0, 0.f, 0.f)); |
| 60 | //The function is added already | ||
| 61 | // phoenix_assert(!daemon.addCallableMethod(testCallFunction, "testCallFunction")); | ||
| 62 | |||
| 63 | 1 | int value(42); | |
| 64 |
1/1✓ Branch 0 (100→101) taken 1 times.
|
1 | Data dataInt(phoenix_createData(value)); |
| 65 |
5/5✓ Branch 0 (103→104) taken 1 times.
✓ Branch 2 (106→107) taken 1 times.
✓ Branch 4 (109→110) taken 1 times.
✓ Branch 6 (110→111) taken 1 times.
✓ Branch 8 (111→112) taken 1 times.
|
5 | phoenix_assert(daemon.processData(dataInt)); |
| 66 | |||
| 67 |
1/1✓ Branch 0 (118→119) taken 1 times.
|
1 | Shadok shadok; |
| 68 |
1/1✓ Branch 0 (119→120) taken 1 times.
|
1 | shadok.setAge(42); |
| 69 |
2/2✓ Branch 0 (122→123) taken 1 times.
✓ Branch 2 (123→124) taken 1 times.
|
1 | shadok.setName("Shadoko"); |
| 70 |
1/1✓ Branch 0 (126→127) taken 1 times.
|
1 | Data data(phoenix_createData(shadok)); |
| 71 |
5/5✓ Branch 0 (129→130) taken 1 times.
✓ Branch 2 (132→133) taken 1 times.
✓ Branch 4 (135→136) taken 1 times.
✓ Branch 6 (136→137) taken 1 times.
✓ Branch 8 (137→138) taken 1 times.
|
5 | phoenix_assert(daemon.processData(data)); |
| 72 | |||
| 73 | 1 | long longValue(42); | |
| 74 |
1/1✓ Branch 0 (144→145) taken 1 times.
|
1 | Data dataLong(phoenix_createData(longValue)); |
| 75 |
5/5✓ Branch 0 (147→148) taken 1 times.
✓ Branch 2 (150→151) taken 1 times.
✓ Branch 4 (153→154) taken 1 times.
✓ Branch 6 (154→155) taken 1 times.
✓ Branch 8 (155→156) taken 1 times.
|
5 | phoenix_assert(daemon.processData(dataLong)); |
| 76 | |||
| 77 | 1 | short shortValue(42); | |
| 78 |
1/1✓ Branch 0 (162→163) taken 1 times.
|
1 | Data dataShort(phoenix_createData(shortValue)); |
| 79 |
5/5✓ Branch 0 (165→166) taken 1 times.
✓ Branch 2 (168→169) taken 1 times.
✓ Branch 4 (171→172) taken 1 times.
✓ Branch 6 (172→173) taken 1 times.
✓ Branch 8 (173→174) taken 1 times.
|
5 | phoenix_assert(daemon.processData(dataShort)); |
| 80 | 1 | } | |
| 81 | |||
| 82 | ///Test the DaemonSlot | ||
| 83 | 1 | void testDaemonSlot(){ | |
| 84 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | DaemonSlot daemon; |
| 85 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | daemon.setSocketMode(PSocketMode::MOCK); |
| 86 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | daemon.setClockMode(PClockMode::MOCK); |
| 87 |
2/2✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
|
1 | daemon.getLog().setLogLevel(PLog::DEBUG); |
| 88 |
4/4✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
✓ Branch 6 (10→11) taken 1 times.
|
1 | daemon.getLog().setFileName(PPath("DaemonSlot.log")); |
| 89 |
6/6✓ Branch 0 (15→16) taken 1 times.
✓ Branch 2 (18→19) taken 1 times.
✓ Branch 4 (21→22) taken 1 times.
✓ Branch 6 (22→23) taken 1 times.
✓ Branch 8 (23→24) taken 1 times.
✓ Branch 10 (24→25) taken 1 times.
|
5 | phoenix_assert(daemon.getLog().open()); |
| 90 |
1/1✓ Branch 0 (31→32) taken 1 times.
|
1 | daemon.addCallMethod(); |
| 91 | 1 | int value(42); | |
| 92 |
1/1✓ Branch 0 (32→33) taken 1 times.
|
1 | Data dataInt(phoenix_createData(value)); |
| 93 |
5/5✓ Branch 0 (35→36) taken 1 times.
✓ Branch 2 (38→39) taken 1 times.
✓ Branch 4 (41→42) taken 1 times.
✓ Branch 6 (42→43) taken 1 times.
✓ Branch 8 (43→44) taken 1 times.
|
5 | phoenix_assert(daemon.processData(dataInt)); |
| 94 | 1 | } | |
| 95 | |||
| 96 | 1 | int main(int argc, char** argv){ | |
| 97 |
3/3✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
✓ Branch 4 (4→5) taken 1 times.
|
1 | testBaseDaemonLoadConfig(PPath(DAEMON_CONFIG_OK)); |
| 98 | 1 | testDaemonSlot(); | |
| 99 | 1 | return 0; | |
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 |