| 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 | PMockBackendFile backend; |
| 15 |
1/1✓ Branch 0 (3→4) taken 2 times.
|
2 | PMockBackendFile::Socket socket; |
| 16 |
8/11✓ Branch 0 (6→7) taken 2 times.
✓ Branch 2 (9→10) taken 2 times.
✓ Branch 4 (12→13) taken 2 times.
✓ Branch 6 (13→14) taken 2 times.
✓ Branch 8 (16→17) taken 2 times.
✓ Branch 10 (17→18) taken 2 times.
✓ Branch 12 (18→19) taken 2 times.
✗ Branch 14 (20→21) not taken.
✓ Branch 15 (20→22) taken 2 times.
✗ Branch 16 (77→78) not taken.
✗ Branch 17 (77→79) not taken.
|
16 | data_stream_assert(backend.createClientSocket(socket, PSocketParam{"localhost", 1234}, PMockBackendFile::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 | PMockBackendFile::Message msg; | |
| 20 | #ifdef RECV | ||
| 21 |
8/10✓ Branch 0 (39→40) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
✓ Branch 4 (45→46) taken 1 times.
✗ 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.
|
12 | PHOENIX_ASSERT_EXCEPTION(data_stream_assert(socket.recvMsg(msg, PRecvFlag::BLOCK) != PRecvStatus::OK)); |
| 22 | #endif | ||
| 23 | #ifdef SEND | ||
| 24 |
8/10✓ Branch 0 (39→40) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
✓ Branch 4 (45→46) taken 1 times.
✗ 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.
|
12 | 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 | PMockBackendFile::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 | PMockBackendFile::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 |
8/10✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (22→23) taken 1 times.
✗ 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.
|
12 | PHOENIX_ASSERT_EXCEPTION(data_stream_assert(!socket.recvMsg(msg, PRecvFlag::BLOCK) != PRecvStatus::OK)); |
| 40 | #endif | ||
| 41 | #ifdef SEND | ||
| 42 |
8/10✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (22→23) taken 1 times.
✗ 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.
|
12 | 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 |