Blame view

test/DD_Client/CSlimFixtures/TestCommandLine.hh 1.95 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * TestCommandLine.hh
 *
 *  Created on: Jan 10, 2013
 *      Author: f.casimir
 */

#ifndef TESTCOMMANDLINE_HH_
#define TESTCOMMANDLINE_HH_

#include <vector>
#include <string>

namespace AMDA {
namespace CSlimFixtures {

class PgmResult;
/**
 * @class TestCommandLine
 * @detail This class is used into script table test. It stores all result of program execution for a later used.
 * To recall a result or a log, it must use expressions of type '${alias:RESULT}' or '${alias:OUTPUT}'.
 * Alias is the name of programm when you call "executeCommandAlias".
 * example of used:
 * !|script|TestCommandLine|
 * |reference|US 64: id 127|id test|
 * |note|!-Exécution du programme SimpleTest-!|
 * |check|execute|SimpleTest|command|cmd1|alias|1|
 * |note|La sortie standard de la commande 1 doit contenir 25 lignes|
 * |check|execute|!-test `wc -l ${cmd1:OUTPUT} | awk '{print $1}'` -eq 25-!|command|count1|alias|0|
 */
class TestCommandLine {
public:
	typedef std::vector<PgmResult*> PgmResultList;
	/**
	 * Constructor
	 */
	TestCommandLine();
	/**
	 * Destructor
	 */
	virtual ~TestCommandLine();

	// Getter methods
	/**
	 * @return last PgmResult of _pgmResultList or NULL if empty.
	 */
	PgmResult* getLastPgmResult();
	/**
	 * @return push a new PgmResult into _pgmResultList and return it.
	 */
	PgmResult* getNewPgmResult(const char* pAlias, const char* pCommand);
	/**
	 * @return a PgmResult* of the _pgmResultList with the alias pAlias or NULL.
	 */
	PgmResult* getPgmResult(const char* alias);

	// Other methods
	static TestCommandLine* from(void *fixtureStorage);

	/**
	 * @details replace into pOriginalCommand the pattern ${alias:variable} with its correspondence from the alias PgmResult.
	 * @return the new reinterpreted string.
	 */
	std::string interpret(std::string pOriginalCommand);

	std::string _currentNameTest;
	PgmResultList _pgmResultList;
	char* _logToDisplay = NULL;
};

} /* namespace CSlimFixtures */
} /* namespace AMDA */
#endif /* TESTCOMMANDLINE_HH_ */