GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_MOCK_BACKEND_FILE_ERROR_CASES/main.cpp
Date: 2026-04-14 18:36:32
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 3 3 100.0%
Branches: 40 63 63.5%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6 #include <iostream>
7
8 #include "data_stream_assert.h"
9 #include "data_stream_check_value.h"
10 #include "PMockBackendFile.h"
11
12 ///Test creating a socket with an invalid file path
13 2 void testCreateSocketWithInvalidFile(){
14
1/1
✓ Branch 0 (2→3) taken 2 times.
2 PMockSocketFileGenerator backend;
15
1/1
✓ Branch 0 (3→4) taken 2 times.
2 PMockSocketFileGenerator::Socket socket;
16
8/11
✓ Branch 0 (6→7) taken 2 times.
✓ Branch 2 (7→8) taken 2 times.
✓ Branch 4 (8→9) taken 2 times.
✓ Branch 6 (11→12) taken 2 times.
✓ Branch 8 (14→15) taken 2 times.
✓ Branch 10 (17→18) taken 2 times.
✓ Branch 12 (18→19) taken 2 times.
✗ Branch 14 (26→27) not taken.
✓ Branch 15 (26→28) taken 2 times.
✗ Branch 16 (96→97) not taken.
✗ Branch 17 (96→98) not taken.
18 data_stream_assert(backend.createClientSocket(socket, PSocketParam{"localhost", 1234}, PMockSocketFileGenerator::client()));
17
2/2
✓ Branch 0 (31→32) taken 2 times.
✓ Branch 2 (32→33) taken 2 times.
2 socket.setMockPrefix("/invalid/path/that/does/not/exist/");
18
1/1
✓ Branch 0 (35→36) taken 2 times.
2 socket.setIsMockRecord(false);
19 2 PMockSocketFileGenerator::Message msg;
20 #ifdef RECV
21
5/10
✗ Branch 0 (37→38) not taken.
✗ Branch 2 (40→41) not taken.
✗ Branch 4 (43→44) not taken.
✗ Branch 6 (46→47) not taken.
✗ Branch 8 (47→48) not taken.
✓ Branch 10 (57→58) taken 1 times.
✓ Branch 12 (60→61) taken 1 times.
✓ Branch 14 (63→64) taken 1 times.
✓ Branch 16 (64→65) taken 1 times.
✓ Branch 18 (129→55) taken 1 times.
6 PHOENIX_ASSERT_EXCEPTION(data_stream_assert(socket.recvMsg(msg, PRecvFlag::BLOCK) != PRecvStatus::OK));
22 #endif
23 #ifdef SEND
24
5/10
✗ Branch 0 (37→38) not taken.
✗ Branch 2 (40→41) not taken.
✗ Branch 4 (43→44) not taken.
✗ Branch 6 (46→47) not taken.
✗ Branch 8 (47→48) not taken.
✓ Branch 10 (57→58) taken 1 times.
✓ Branch 12 (60→61) taken 1 times.
✓ Branch 14 (63→64) taken 1 times.
✓ Branch 16 (64→65) taken 1 times.
✓ Branch 18 (129→55) taken 1 times.
6 PHOENIX_ASSERT_EXCEPTION(data_stream_assert(socket.sendMsg(msg, PSendFlag::BLOCK) != PSendStatus::OK));
25 #endif
26 2 }
27
28 ///Test sending/receiving messages with a wrong path
29 2 void testWrongPath(){
30
1/1
✓ Branch 0 (2→3) taken 2 times.
2 PMockSocketFileGenerator::Socket socket;
31
2/2
✓ Branch 0 (5→6) taken 2 times.
✓ Branch 2 (6→7) taken 2 times.
2 socket.setMockPrefix("non/existing/file_");
32
1/1
✓ Branch 0 (9→10) taken 2 times.
2 socket.setIsMockRecord(false);
33
34 2 PMockSocketFileGenerator::Message msg;
35
1/1
✓ Branch 0 (11→12) taken 2 times.
2 msg.push_back(1lu);
36
1/1
✓ Branch 0 (12→13) taken 2 times.
2 msg.push_back(2lu);
37
1/1
✓ Branch 0 (13→14) taken 2 times.
2 msg.push_back(3lu);
38 #ifdef RECV
39
5/10
✗ Branch 0 (14→15) not taken.
✗ Branch 2 (17→18) not taken.
✗ Branch 4 (20→21) not taken.
✗ Branch 6 (23→24) not taken.
✗ Branch 8 (24→25) not taken.
✓ Branch 10 (34→35) taken 1 times.
✓ Branch 12 (37→38) taken 1 times.
✓ Branch 14 (40→41) taken 1 times.
✓ Branch 16 (41→42) taken 1 times.
✓ Branch 18 (80→32) taken 1 times.
6 PHOENIX_ASSERT_EXCEPTION(data_stream_assert(!socket.recvMsg(msg, PRecvFlag::BLOCK) != PRecvStatus::OK));
40 #endif
41 #ifdef SEND
42
5/10
✗ Branch 0 (14→15) not taken.
✗ Branch 2 (17→18) not taken.
✗ Branch 4 (20→21) not taken.
✗ Branch 6 (23→24) not taken.
✗ Branch 8 (24→25) not taken.
✓ Branch 10 (34→35) taken 1 times.
✓ Branch 12 (37→38) taken 1 times.
✓ Branch 14 (40→41) taken 1 times.
✓ Branch 16 (41→42) taken 1 times.
✓ Branch 18 (80→32) taken 1 times.
6 PHOENIX_ASSERT_EXCEPTION(data_stream_assert(!socket.sendMsg(msg, PSendFlag::BLOCK) != PSendStatus::OK));
43 #endif
44 2 }
45
46 6 int main(int argc, char **argv){
47 #ifdef INVALID_FILE
48 2 testCreateSocketWithInvalidFile();
49 #endif
50 #ifdef WRONG_PATH
51 2 testWrongPath();
52 #endif
53 6 return 0;
54 }
55