GCC Code Coverage Report


Directory: ./
File: src/PClockMock.cpp
Date: 2026-01-26 14:45:44
Exec Total Coverage
Lines: 33 33 100.0%
Functions: 10 11 90.9%
Branches: 8 8 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7
8 #include "PClockMock.h"
9
10 ///Create a mock backend for clock
11 /** @param[out] mock : clock mock backend to be used
12 * @param prefix : prefix of the mock file
13 * @return true on success, false otherwise
14 */
15 2 bool phoenix_createMockBackend(PClockMock & mock, const std::string & prefix){
16 2 mock.setMockPrefix(prefix);
17 2 return true;
18 }
19
20 ///Default constructor of PClockMock
21
1/1
✓ Branch 0 (5→6) taken 4 times.
8 PClockMock::PClockMock(){
22
1/1
✓ Branch 0 (8→9) taken 4 times.
4 initialisationPClockMock();
23 4 }
24
25 ///Destructor of PClockMock
26 4 PClockMock::~PClockMock(){
27 4 close();
28 4 }
29
30 ///Get the mocked current time
31 /** @return mocked current time
32 */
33 16 time_t PClockMock::now(){
34 16 p_mock.setIsRecord(false);
35 16 time_t currentTime = 0lu;
36
1/1
✓ Branch 0 (3→4) taken 16 times.
16 p_mock.getCurrentValue(currentTime);
37 16 return currentTime;
38 }
39
40 ///Sleep for the given time
41 /** @param sleepTime : time to sleep
42 */
43 4 void PClockMock::sleep(EllapsedTime sleepTime) const{
44 //Do nothing for the mock
45 4 }
46
47 ///Set the current time to be recorded
48 /** @param currentTime : current time to be recorded
49 */
50 8 void PClockMock::setCurrentTime(time_t currentTime){
51 8 p_mock.setIsRecord(true);
52 //Let's record the given time
53 8 p_mock.append(currentTime);
54 8 }
55
56 ///Set the mock directory
57 /** @param mockDirectory : mock directory
58 */
59 4 void PClockMock::setMockPrefix(const std::string & mockPrefix){
60
1/1
✓ Branch 0 (2→3) taken 4 times.
4 std::stringstream socketFileName;
61
2/2
✓ Branch 0 (3→4) taken 4 times.
✓ Branch 2 (4→5) taken 4 times.
4 socketFileName << mockPrefix << "clock.pclockmock";
62
2/2
✓ Branch 0 (5→6) taken 4 times.
✓ Branch 2 (6→7) taken 4 times.
4 p_mock.setFileName(socketFileName.str());
63 4 }
64
65 ///Reset the mock index to the beginning
66 2 void PClockMock::resetIndex(){
67 2 p_mock.resetIndex();
68 2 }
69
70 ///Close the mock
71 6 void PClockMock::close(){
72 6 p_mock.close();
73 6 }
74
75 ///Initialisation function of the class PClockMock
76 4 void PClockMock::initialisationPClockMock(){
77
78 4 }
79
80
81
82
83
84