Directory: | ./ |
---|---|
File: | TESTS/TEST_PULL_CONNECTOR_MANAGER/main.cpp |
Date: | 2024-12-09 11:00:39 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 30 | 30 | 100.0% |
Branches: | 80 | 80 | 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 | #include "phoenix_assert.h" | ||
8 | #include "phoenix_control.h" | ||
9 | |||
10 | typedef PAbstractControlManager<std::string, PMockControlBackend, PMockControlBackend> ConnectorManager; | ||
11 | |||
12 | ///Basic test of a PAbstractConnectorManager for Pull | ||
13 | 1 | void testBaseAbtractConnectorManagerServerSimplePull(){ | |
14 | //Let's create the mock file | ||
15 |
1/1✓ Branch 1 taken 1 times.
|
1 | PMockConnectorVar mock; |
16 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | mock.setType(phoenix_getComposeType<size_t>()); |
17 |
6/6✓ 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 20 taken 1 times.
|
1 | phoenix_mockCreate(mock, phoenix_getControlMockFileVar("mock_pull", "localhost", "pull", "shadok")); |
18 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0lu); i < 10lu; ++i){ //Let's push 10 values |
19 |
1/1✓ Branch 1 taken 10 times.
|
10 | phoenix_mockVarAppendData(i, mock, i); |
20 | } | ||
21 |
1/1✓ Branch 1 taken 1 times.
|
1 | phoenix_mockSave(mock); |
22 | |||
23 | //Let's use it | ||
24 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
✓ Branch 30 taken 1 times.
|
2 | ConnectorManager manager; |
25 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | manager.addClientConnector("Alice", "localhost", phoenix_mockControlParam(false, "mock_pull", PLog::DEBUG)); |
26 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 12 taken 1 times.
|
1 | manager.registerVar("Alice", phoenix_getComposeVar<size_t>("shadok")); |
27 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0lu); i < 10lu; ++i){ //Let's push 10 values |
28 |
7/7✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 14 taken 10 times.
✓ Branch 18 taken 10 times.
✓ Branch 21 taken 10 times.
✓ Branch 24 taken 10 times.
|
10 | phoenix_assert(manager.pullData("Alice", "shadok", i)); |
29 | } | ||
30 | 1 | } | |
31 | |||
32 | ///Basic test of a PAbstractConnectorManager for Pull in record mode | ||
33 | 1 | void testBaseAbtractConnectorManagerServerSimplePullRecord(){ | |
34 | //Let's create the mock file | ||
35 |
1/1✓ Branch 1 taken 1 times.
|
1 | PMockConnectorVar mock; |
36 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | mock.setType(phoenix_getComposeType<size_t>()); |
37 |
6/6✓ 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 20 taken 1 times.
|
1 | phoenix_mockCreate(mock, phoenix_getControlMockFileVar("mock_pull_for_record", "localhost", "pull", "shadok")); |
38 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0lu); i < 10lu; ++i){ //Let's push 10 values |
39 |
1/1✓ Branch 1 taken 10 times.
|
10 | phoenix_mockVarAppendData(i, mock, i); |
40 | } | ||
41 |
1/1✓ Branch 1 taken 1 times.
|
1 | phoenix_mockSave(mock); |
42 | |||
43 | //Let's use it | ||
44 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
✓ Branch 30 taken 1 times.
|
2 | ConnectorManager manager(ConnectorMode::MOCK_RECORD, PMockControlBackend::defaultMgrParam(), phoenix_mockControlParam(true, "mock_pull_recorded", PLog::DEBUG)); |
45 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | manager.addClientConnector("Alice", "localhost", phoenix_mockControlParam(false, "mock_pull_for_record", PLog::DEBUG)); |
46 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 12 taken 1 times.
|
1 | manager.registerVar("Alice", phoenix_getComposeVar<size_t>("shadok")); |
47 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for(size_t i(0lu); i < 10lu; ++i){ //Let's push 10 values |
48 |
7/7✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 14 taken 10 times.
✓ Branch 18 taken 10 times.
✓ Branch 21 taken 10 times.
✓ Branch 24 taken 10 times.
|
10 | phoenix_assert(manager.pullData("Alice", "shadok", i)); |
49 | } | ||
50 | 1 | } | |
51 | |||
52 | |||
53 | 1 | int main(int argc, char** argv){ | |
54 | 1 | testBaseAbtractConnectorManagerServerSimplePull(); | |
55 | 1 | testBaseAbtractConnectorManagerServerSimplePullRecord(); | |
56 | 1 | return 0; | |
57 | } | ||
58 | |||
59 | |||
60 |