Directory: | ./ |
---|---|
File: | tmp_project/PhoenixString/TESTS/TEST_PHOENIX_POPEN/main.cpp |
Date: | 2024-07-27 10:53:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 27 | 27 | 100.0% |
Branches: | 86 | 86 | 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 <vector> | ||
10 | #include "phoenix_assert.h" | ||
11 | #include "string_system.h" | ||
12 | |||
13 | ///Test the phoenix popen function | ||
14 | 1 | void testPoenixPOpen(){ | |
15 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::string resCmd1(phoenix_popen("echo \"test command\"")); |
16 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cout << "testPoenixPOpen : resCmd1 = '" << resCmd1 << "'" << std::endl; |
17 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(resCmd1 == "test command\n"); |
18 |
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 21 taken 1 times.
|
1 | phoenix_assert(phoenix_popen("") == ""); |
19 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::string resCmd3(phoenix_popen("someUnexistingCommad")); |
20 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cout << "testPoenixPOpen : resCmd3 = '" << resCmd3 << "'" << std::endl; |
21 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(resCmd3 == "\0"); |
22 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | int exitStatus1 = phoenix_popen(resCmd1, "echo \"test command\""); |
23 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(resCmd1 == "test command\n"); |
24 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | phoenix_assert(exitStatus1 == 0); |
25 |
1/1✓ Branch 2 taken 1 times.
|
1 | std::string resEmptyCmd(""); |
26 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | int exitStatus2 = phoenix_popen(resEmptyCmd, ""); |
27 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(resEmptyCmd == ""); |
28 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | phoenix_assert(exitStatus2 == -1); |
29 |
1/1✓ Branch 2 taken 1 times.
|
1 | std::string resUnexistingCmd(""); |
30 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | int exitStatus3 = phoenix_popen(resUnexistingCmd, "someUnexistingCommad"); |
31 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(resUnexistingCmd == ""); |
32 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | phoenix_assert(exitStatus3 == 32512); |
33 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_popen("command.log", "echo \"test command\"", true)); |
34 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_popen("command.log", "echo \"test command\"", false)); |
35 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!phoenix_popen("command_unexistingCommand.log", "someUnexistingCommand", true)); |
36 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!phoenix_popen("command_unexistingCommand.log", "someUnexistingCommand", false)); |
37 | 1 | } | |
38 | |||
39 | 1 | int main(int argc, char** argv){ | |
40 | 1 | testPoenixPOpen(); | |
41 | 1 | return 0; | |
42 | } | ||
43 | |||
44 | |||
45 |