Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 8e90aca

Browse files
committed
test-platform: Shift to the new naming convention
Signed-off-by: Jules Clero <julesx.clero@intel.com>
1 parent f19f6c7 commit 8e90aca

File tree

5 files changed

+65
-54
lines changed

5 files changed

+65
-54
lines changed

test/test-platform/TestPlatform.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,38 @@ namespace test
3939
namespace platform
4040
{
4141

42-
CTestPlatform::CTestPlatform(const string& strClass, int iPortNumber, sem_t& exitSemaphore) :
43-
_parameterMgrPlatformConnector(strClass),
44-
_parameterMgrPlatformConnectorLogger(),
45-
_commandParser(*this),
46-
_remoteProcessorServer(iPortNumber, _commandParser.getCommandHandler()),
47-
_exitSemaphore(exitSemaphore)
42+
TestPlatform::TestPlatform(const string& configurationFile, int portNumber, sem_t& exitSemaphore) :
43+
mParameterMgrPlatformConnector(configurationFile),
44+
mParameterMgrPlatformConnectorLogger(),
45+
mCommandParser(*this),
46+
mRemoteProcessorServer(portNumber, mCommandParser.getCommandHandler()),
47+
mExitSemaphore(exitSemaphore)
4848
{
49-
_parameterMgrPlatformConnector.setLogger(&_parameterMgrPlatformConnectorLogger);
49+
mParameterMgrPlatformConnector.setLogger(&mParameterMgrPlatformConnectorLogger);
5050
}
5151

52-
bool CTestPlatform::load(std::string& strError)
52+
bool TestPlatform::load(std::string& error)
5353
{
5454
// Start remote processor server
55-
if (!_remoteProcessorServer.start(strError)) {
55+
if (!mRemoteProcessorServer.start(error)) {
5656

57-
strError = "TestPlatform: Unable to start remote processor server: " + strError;
57+
error = "TestPlatform: Unable to start remote processor server: " + error;
5858
return false;
5959
}
6060

6161
return true;
6262
}
6363

64-
bool CTestPlatform::setCriterionState(std::string criterionName,
64+
bool TestPlatform::setCriterionState(std::string criterionName,
6565
const IRemoteCommand& remoteCommand,
66-
string& strResult)
66+
string& result)
6767
{
6868
core::criterion::Criterion* pCriterion =
69-
_parameterMgrPlatformConnector.getCriterion(criterionName);
69+
mParameterMgrPlatformConnector.getCriterion(criterionName);
7070

7171
if (!pCriterion) {
7272

73-
strResult = "Unable to retrieve selection criterion: " + criterionName;
73+
result = "Unable to retrieve selection criterion: " + criterionName;
7474
return false;
7575
}
7676

@@ -83,7 +83,7 @@ bool CTestPlatform::setCriterionState(std::string criterionName,
8383
}
8484

8585
// Set criterion new state
86-
if (!pCriterion->setState(state, strResult)) {
86+
if (!pCriterion->setState(state, result)) {
8787
return false;
8888
}
8989
return true;

test/test-platform/TestPlatform.h

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ namespace log
4646
{
4747

4848
/** Logger exposed to the parameter-framework */
49-
class CParameterMgrPlatformConnectorLogger : public CParameterMgrPlatformConnector::ILogger
49+
class ParameterMgrPlatformConnectorLogger : public CParameterMgrPlatformConnector::ILogger
5050
{
5151
public:
52-
CParameterMgrPlatformConnectorLogger() {}
52+
ParameterMgrPlatformConnectorLogger() {}
5353

5454
virtual void info(const std::string& log)
5555
{
@@ -64,17 +64,27 @@ class CParameterMgrPlatformConnectorLogger : public CParameterMgrPlatformConnect
6464

6565
} /** log namespace */
6666

67-
class CTestPlatform
67+
class TestPlatform
6868
{
6969

7070
/** Remote command parser has access to private command handle function */
7171
friend class command::Parser;
7272

7373
public:
74-
CTestPlatform(const std::string &strclass, int iPortNumber, sem_t& exitSemaphore);
7574

76-
// Init
77-
bool load(std::string& strError);
75+
/**
76+
* @param[in] configurationFile the Parameter-Framework configuration file
77+
* @param[in] portNumber the tcp port used by the command server
78+
* @param[in] exitSemaphore the semaphore to notify closing event to the parent thread
79+
*/
80+
TestPlatform(const std::string &configurationFile, int portNumber, sem_t& exitSemaphore);
81+
82+
/** Start the test platform
83+
*
84+
* @param[out] error the error description if needed
85+
* @return true if success false otherwise
86+
*/
87+
bool load(std::string& error);
7888

7989
private:
8090

@@ -141,8 +151,8 @@ class CTestPlatform
141151
std::string& result)
142152
{
143153
core::criterion::Criterion* criterion = (isInclusive ?
144-
_parameterMgrPlatformConnector.createInclusiveCriterion(name, values, result) :
145-
_parameterMgrPlatformConnector.createExclusiveCriterion(name, values, result));
154+
mParameterMgrPlatformConnector.createInclusiveCriterion(name, values, result) :
155+
mParameterMgrPlatformConnector.createExclusiveCriterion(name, values, result));
146156

147157
if (criterion == nullptr) {
148158
return false;
@@ -162,22 +172,22 @@ class CTestPlatform
162172
*/
163173
bool setCriterionState(std::string criterionName,
164174
const IRemoteCommand& remoteCommand,
165-
std::string& strResult);
175+
std::string& result);
166176

167177
/** Parameter-Framework Connector */
168-
CParameterMgrPlatformConnector _parameterMgrPlatformConnector;
178+
CParameterMgrPlatformConnector mParameterMgrPlatformConnector;
169179

170180
/** Parameter-Framework Logger */
171-
log::CParameterMgrPlatformConnectorLogger _parameterMgrPlatformConnectorLogger;
181+
log::ParameterMgrPlatformConnectorLogger mParameterMgrPlatformConnectorLogger;
172182

173183
/** Command Parser delegate */
174-
command::Parser _commandParser;
184+
command::Parser mCommandParser;
175185

176186
/** Remote Processor Server */
177-
CRemoteProcessorServer _remoteProcessorServer;
187+
CRemoteProcessorServer mRemoteProcessorServer;
178188

179-
// Semaphore used by calling thread to avoid exiting
180-
sem_t& _exitSemaphore;
189+
/** Semaphore used by calling thread to avoid exiting */
190+
sem_t& mExitSemaphore;
181191
};
182192

183193
} /** platform namespace */

test/test-platform/command/include/command/Parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace test
3838
namespace platform
3939
{
4040

41-
class CTestPlatform;
41+
class TestPlatform;
4242

4343
namespace command
4444
{
@@ -56,7 +56,7 @@ class Parser
5656
*
5757
* @param test-platform reference
5858
*/
59-
Parser(CTestPlatform& testPlatform);
59+
Parser(TestPlatform& testPlatform);
6060

6161
/** Internal command handler getter
6262
*
@@ -161,7 +161,7 @@ class Parser
161161
static CommandHandler::RemoteCommandParserItems gRemoteCommandParserItems;
162162

163163
/** Test PLatform used to delegate parsed commands */
164-
CTestPlatform& mTestPlatform;
164+
TestPlatform& mTestPlatform;
165165

166166
/** Command Handler */
167167
CommandHandler mCommandHandler;

test/test-platform/command/src/Parser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Parser::CommandHandler::RemoteCommandParserItems Parser::gRemoteCommandParserIte
9191
"Get policy for schema validation based on .xsd files." } }
9292
};
9393

94-
Parser::Parser(CTestPlatform& testPlatform) :
94+
Parser::Parser(TestPlatform& testPlatform) :
9595
mTestPlatform(testPlatform), mCommandHandler(CommandHandler(*this, gRemoteCommandParserItems))
9696
{
9797
}
@@ -104,7 +104,7 @@ Parser::CommandHandler* Parser::getCommandHandler()
104104
Parser::CommandReturn Parser::exit(const IRemoteCommand&, std::string&)
105105
{
106106
// Release the main blocking semaphore to quit application
107-
sem_post(&mTestPlatform._exitSemaphore);
107+
sem_post(&mTestPlatform.mExitSemaphore);
108108

109109
return Parser::CommandHandler::EDone;
110110
}
@@ -131,7 +131,7 @@ Parser::createCriterionFromStateList(const IRemoteCommand& remoteCommand, std::s
131131

132132
Parser::CommandReturn Parser::startParameterMgr(const IRemoteCommand&, std::string& result)
133133
{
134-
return mTestPlatform._parameterMgrPlatformConnector.start(result) ?
134+
return mTestPlatform.mParameterMgrPlatformConnector.start(result) ?
135135
Parser::CommandHandler::EDone : Parser::CommandHandler::EFailed;
136136
}
137137

@@ -142,14 +142,14 @@ Parser::CommandReturn Parser::setter(const IRemoteCommand& remoteCommand, std::s
142142
if(!convertTo(remoteCommand.getArgument(0), fail)) {
143143
return Parser::CommandHandler::EShowUsage;
144144
}
145-
return (mTestPlatform._parameterMgrPlatformConnector.*setFunction)(fail, result) ?
145+
return (mTestPlatform.mParameterMgrPlatformConnector.*setFunction)(fail, result) ?
146146
Parser::CommandHandler::EDone : Parser::CommandHandler::EFailed;
147147
}
148148

149149
template <Parser::getter_t getFunction>
150150
Parser::CommandReturn Parser::getter(const IRemoteCommand&, std::string& result)
151151
{
152-
result = (mTestPlatform._parameterMgrPlatformConnector.*getFunction)() ? "true" : "false";
152+
result = (mTestPlatform.mParameterMgrPlatformConnector.*getFunction)() ? "true" : "false";
153153
return Parser::CommandHandler::ESucceeded;
154154
}
155155

@@ -164,7 +164,7 @@ Parser::CommandReturn Parser::setCriterionState(const IRemoteCommand& remoteComm
164164

165165
Parser::CommandReturn Parser::applyConfigurations(const IRemoteCommand&, std::string&)
166166
{
167-
mTestPlatform._parameterMgrPlatformConnector.applyConfigurations();
167+
mTestPlatform.mParameterMgrPlatformConnector.applyConfigurations();
168168

169169
return Parser::CommandHandler::EDone;
170170
}

test/test-platform/main.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using namespace std;
4444
const int iDefaultPortNumber = 5001;
4545

4646
// Starts test-platform in blocking mode
47-
static bool startBlockingTestPlatform(const char *filePath, int portNumber, string &strError)
47+
static bool startBlockingTestPlatform(const char *filePath, int portNumber, string &error)
4848
{
4949

5050
// Init semaphore
@@ -53,10 +53,10 @@ static bool startBlockingTestPlatform(const char *filePath, int portNumber, stri
5353
sem_init(&sem, false, 0);
5454

5555
// Create param mgr
56-
test::platform::CTestPlatform testPlatform(filePath, portNumber, sem);
56+
test::platform::TestPlatform testPlatform(filePath, portNumber, sem);
5757

5858
// Start platformmgr
59-
if (!testPlatform.load(strError)) {
59+
if (!testPlatform.load(error)) {
6060

6161
sem_destroy(&sem);
6262

@@ -82,14 +82,14 @@ static void notifyParent(int parentFd, bool success)
8282
}
8383

8484
// Starts test-platform in daemon mode
85-
static bool startDaemonTestPlatform(const char *filePath, int portNumber, string &strError)
85+
static bool startDaemonTestPlatform(const char *filePath, int portNumber, string &error)
8686
{
8787
// Pipe used for communication between the child and the parent processes
8888
int pipefd[2];
8989

9090
if (pipe(pipefd) == -1) {
9191

92-
strError = "pipe failed";
92+
error = "pipe failed";
9393
return false;
9494
}
9595

@@ -100,7 +100,7 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string
100100

101101
if (pid < 0) {
102102

103-
strError = "fork failed!";
103+
error = "fork failed!";
104104
return false;
105105

106106
} else if (pid == 0) {
@@ -116,14 +116,14 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string
116116
sem_init(&sem, false, 0);
117117

118118
// Create param mgr
119-
test::platform::CTestPlatform testPlatform(filePath, portNumber, sem);
119+
test::platform::TestPlatform testPlatform(filePath, portNumber, sem);
120120

121121
// Message to send to parent process
122-
bool loadSuccess = testPlatform.load(strError);
122+
bool loadSuccess = testPlatform.load(error);
123123

124124
if (!loadSuccess) {
125125

126-
cerr << strError << endl;
126+
cerr << error << endl;
127127

128128
// Notify parent of failure;
129129
notifyParent(pipefd[1], false);
@@ -152,7 +152,7 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string
152152
bool msgFromChild = false;
153153

154154
if (not utility::fullRead(pipefd[0], &msgFromChild, sizeof(msgFromChild))) {
155-
strError = "Read pipe failed";
155+
error = "Read pipe failed";
156156
return false;
157157
}
158158

@@ -176,7 +176,8 @@ static void showInvalidUsage()
176176
static void showHelp()
177177
{
178178
showUsage();
179-
cerr << "<file path> must be a valid .xml file, oftenly ParameterFrameworkConfiguration.xml" << endl;
179+
cerr << "<file path> must be a valid .xml file, oftenly ParameterFrameworkConfiguration.xml"
180+
<< endl;
180181
cerr << "Arguments:" << endl
181182
<< " -d starts as a deamon" << endl
182183
<< " -h display this help and exit" << endl;
@@ -224,19 +225,19 @@ int main(int argc, char *argv[])
224225

225226
// Choose either blocking or daemon test-platform
226227
bool startError;
227-
string strError;
228+
string error;
228229

229230
if (isDaemon) {
230231

231-
startError = startDaemonTestPlatform(filePath, portNumber, strError);
232+
startError = startDaemonTestPlatform(filePath, portNumber, error);
232233
} else {
233234

234-
startError = startBlockingTestPlatform(filePath, portNumber, strError);
235+
startError = startBlockingTestPlatform(filePath, portNumber, error);
235236
}
236237

237238
if (!startError) {
238239

239-
cerr << "Test-platform error:" << strError.c_str() << endl;
240+
cerr << "Test-platform error:" << error.c_str() << endl;
240241
return -1;
241242
}
242243
return 0;

0 commit comments

Comments
 (0)