GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/StringUtils/TESTS/TEST_PHOENIX_POPEN/main.cpp Lines: 27 27 100.0 %
Date: 2024-12-09 15:30:52 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
3
	std::string resCmd1(phoenix_popen("echo \"test command\""));
16

1
	std::cout << "testPoenixPOpen : resCmd1 = '" << resCmd1 << "'" << std::endl;
17

1
	phoenix_assert(resCmd1 == "test command\n");
18

1
	phoenix_assert(phoenix_popen("") == "");
19
3
	std::string resCmd3(phoenix_popen("someUnexistingCommad"));
20

1
	std::cout << "testPoenixPOpen : resCmd3 = '" << resCmd3 << "'" << std::endl;
21

1
	phoenix_assert(resCmd3 == "\0");
22
1
	int exitStatus1 = phoenix_popen(resCmd1, "echo \"test command\"");
23

1
	phoenix_assert(resCmd1 == "test command\n");
24

1
	phoenix_assert(exitStatus1 == 0);
25
2
	std::string resEmptyCmd("");
26
1
	int exitStatus2 = phoenix_popen(resEmptyCmd, "");
27

1
	phoenix_assert(resEmptyCmd == "");
28

1
	phoenix_assert(exitStatus2 == -1);
29
1
	std::string resUnexistingCmd("");
30
1
	int exitStatus3 = phoenix_popen(resUnexistingCmd, "someUnexistingCommad");
31

1
	phoenix_assert(resUnexistingCmd == "");
32

1
	phoenix_assert(exitStatus3 == 32512);
33

1
	phoenix_assert(phoenix_popen("command.log", "echo \"test command\"", true));
34

1
	phoenix_assert(phoenix_popen("command.log", "echo \"test command\"", false));
35

1
	phoenix_assert(!phoenix_popen("command_unexistingCommand.log", "someUnexistingCommand", true));
36

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