Directory: | ./ |
---|---|
File: | TESTS/TEST_PROGRAM_CALL/main.cpp |
Date: | 2025-05-16 18:34:22 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 55 | 55 | 100.0% |
Branches: | 43 | 43 | 100.0% |
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 "phoenix_program_call.h" | ||
10 | |||
11 | ///Check ProgramCall const reference | ||
12 | /** @return true on success, false otherwise | ||
13 | */ | ||
14 | 2 | bool checkProgramCallConst(const ProgramCall & call){ | |
15 | 2 | bool b(true); | |
16 | 2 | b &= call.getName() == "name"; | |
17 | 2 | b &= call.getCommand() == "command"; | |
18 | 2 | b &= call.getWorkingDirectory() == "workingDirectory"; | |
19 | 2 | b &= call.getExitStatus() == 1; | |
20 | 2 | b &= call.getLogFile() == "logFile"; | |
21 | 2 | std::cout << "checkProgramCallRef : b = " << b << std::endl; | |
22 | 2 | return b; | |
23 | } | ||
24 | |||
25 | ///Check ProgramCall reference | ||
26 | /** @return true on success, false otherwise | ||
27 | */ | ||
28 | 2 | bool checkProgramCallRef(ProgramCall & call){ | |
29 | 2 | bool b(true); | |
30 | 2 | b &= call.getName() == "name"; | |
31 | 2 | b &= call.getCommand() == "command"; | |
32 | 2 | b &= call.getWorkingDirectory() == "workingDirectory"; | |
33 | 2 | b &= call.getExitStatus() == 1; | |
34 | 2 | b &= call.getLogFile() == "logFile"; | |
35 | 2 | std::cout << "checkProgramCallRef : b = " << b << std::endl; | |
36 | 2 | return b; | |
37 | } | ||
38 | |||
39 | ///Check basic ProgramCall | ||
40 | /** @return true on success, false otherwise | ||
41 | */ | ||
42 | 1 | bool testBaseProgramCall(){ | |
43 |
1/1✓ Branch 1 taken 1 times.
|
1 | ProgramCall call; |
44 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | call.setName("name"); |
45 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | call.setCommand("command"); |
46 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | call.setWorkingDirectory(PPath("workingDirectory")); |
47 |
1/1✓ Branch 1 taken 1 times.
|
1 | call.setExitStatus(1); |
48 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | call.setLogFile(PPath("logFile")); |
49 | |||
50 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | ProgramCall callCopy(call), callEqual; |
51 |
1/1✓ Branch 1 taken 1 times.
|
1 | callEqual = call; |
52 | |||
53 | 1 | bool b(true); | |
54 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= checkProgramCallConst(callCopy); |
55 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= checkProgramCallRef(callCopy); |
56 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= checkProgramCallConst(callEqual); |
57 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= checkProgramCallRef(callEqual); |
58 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "testBaseProgramCall : b = " << b << std::endl; |
59 | 1 | return b; | |
60 | 1 | } | |
61 | |||
62 | ///Test program call | ||
63 | /** @return true on success, false otherwise | ||
64 | */ | ||
65 | 1 | bool testProgramCall(){ | |
66 | 1 | VecProgramCall vecCall; | |
67 | |||
68 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_program_addcall(vecCall, "simple ls", "ls", PPath("")); |
69 |
7/7✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
|
1 | phoenix_program_addcall(vecCall, "simple ls", "ls", PPath("./"), PPath("someLogFile.log")); |
70 | |||
71 |
1/1✓ Branch 1 taken 1 times.
|
1 | phoenix_program_callVec(vecCall); |
72 | 1 | bool b(true); | |
73 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= phoenix_program_getNbSuccessCall(vecCall) == 2lu; |
74 | 1 | VecVecProgramCall vecVecCall; | |
75 |
1/1✓ Branch 1 taken 1 times.
|
1 | vecVecCall.push_back(vecCall); |
76 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= phoenix_program_getNbSuccessCall(vecVecCall) == 2lu; |
77 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= phoenix_program_getNbCall(vecVecCall) == 2lu; |
78 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | std::cout << "testProgramCall : b = " << b << std::endl; |
79 | 1 | return true; | |
80 | 1 | } | |
81 | |||
82 | 1 | int main(int argc, char **argv){ | |
83 | 1 | bool b(true); | |
84 | 1 | b &= testBaseProgramCall(); | |
85 | 1 | b &= testProgramCall(); | |
86 | 1 | std::cout << "final : b = " << b << std::endl; | |
87 | 1 | return b - 1; | |
88 | } | ||
89 | |||
90 | |||
91 | |||
92 | |||
93 |