diff options
author | Kevin Rocard <kevinx.rocard@intel.com> | 2012-05-02 11:53:59 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:03:09 +0100 |
commit | 8bd2757c16afd5e31bf38c93ce09ba833bba8052 (patch) | |
tree | 9999725f64464ed1f99df45d9b0c73b38b1037df /test/test-platform | |
parent | 3124230f268f949b67ac68a85ced771f8da716ab (diff) | |
download | external_parameter-framework-8bd2757c16afd5e31bf38c93ce09ba833bba8052.zip external_parameter-framework-8bd2757c16afd5e31bf38c93ce09ba833bba8052.tar.gz external_parameter-framework-8bd2757c16afd5e31bf38c93ce09ba833bba8052.tar.bz2 |
PFW: Add CriterionFromStateList to test-platform
BZ: 34881
Add commands : createExclusiveSelectionCriterionFromStateList and createInclusiveSelectionCriterionFromStateList
For routing testing purpose, the PFW test program "test-platform" need
commands to create criterion from a state list, so that each criterion state
could have a specific name.
Change-Id: Ibf4214723e085069ea9513efb099034478fa3b73
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/47499
Reviewed-by: De Chivre, Renaud <renaud.de.chivre@intel.com>
Tested-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'test/test-platform')
-rw-r--r-- | test/test-platform/TestPlatform.cpp | 82 | ||||
-rw-r--r-- | test/test-platform/TestPlatform.h | 6 |
2 files changed, 88 insertions, 0 deletions
diff --git a/test/test-platform/TestPlatform.cpp b/test/test-platform/TestPlatform.cpp index 3e6148b..b353cc1 100644 --- a/test/test-platform/TestPlatform.cpp +++ b/test/test-platform/TestPlatform.cpp @@ -31,6 +31,7 @@ #include <iostream> #include <stdlib.h> #include <sstream> +#include <assert.h> #include "TestPlatform.h" #include "ParameterMgrPlatformConnector.h" #include "RemoteProcessorServer.h" @@ -54,8 +55,12 @@ CTestPlatform::CTestPlatform(const string& strClass) : _pCommandHandler = new CCommandHandler(this); // Add command parsers + _pCommandHandler->addCommandParser("createExclusiveSelectionCriterionFromStateList", &CTestPlatform::createExclusiveSelectionCriterionFromStateListCommandProcess, 2, "<name> <stateList>", "Create inclusive selection criterion from state name list"); + _pCommandHandler->addCommandParser("createInclusiveSelectionCriterionFromStateList", &CTestPlatform::createInclusiveSelectionCriterionFromStateListCommandProcess, 2, "<name> <stateList>", "Create exclusive selection criterion from state name list"); + _pCommandHandler->addCommandParser("createExclusiveSelectionCriterion", &CTestPlatform::createExclusiveSelectionCriterionCommandProcess, 2, "<name> <nbStates>", "Create inclusive selection criterion"); _pCommandHandler->addCommandParser("createInclusiveSelectionCriterion", &CTestPlatform::createInclusiveSelectionCriterionCommandProcess, 2, "<name> <nbStates>", "Create exclusive selection criterion"); + _pCommandHandler->addCommandParser("start", &CTestPlatform::startParameterMgrCommandProcess, 0, "", "Start ParameterMgr"); _pCommandHandler->addCommandParser("setCriterionState", &CTestPlatform::setCriterionStateCommandProcess, 2, "<name> <state>", "Set the current state of a selection criterion"); _pCommandHandler->addCommandParser("applyConfigurations", &CTestPlatform::applyConfigurationsCommandProcess, 0, "", "Apply configurations selected by current selection criteria states"); @@ -89,6 +94,16 @@ bool CTestPlatform::load(std::string& strError) //////////////// Remote command parsers /// Selection Criterion +CTestPlatform::CCommandHandler::CommandStatus CTestPlatform::createExclusiveSelectionCriterionFromStateListCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return createExclusiveSelectionCriterionFromStateList(remoteCommand.getArgument(0), remoteCommand, strResult) ? CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; +} + +CTestPlatform::CCommandHandler::CommandStatus CTestPlatform::createInclusiveSelectionCriterionFromStateListCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) +{ + return createInclusiveSelectionCriterionFromStateList(remoteCommand.getArgument(0), remoteCommand, strResult) ? CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; +} + CTestPlatform::CCommandHandler::CommandStatus CTestPlatform::createExclusiveSelectionCriterionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) { return createExclusiveSelectionCriterion(remoteCommand.getArgument(0), strtoul(remoteCommand.getArgument(1).c_str(), NULL, 0), strResult) ? CTestPlatform::CCommandHandler::EDone : CTestPlatform::CCommandHandler::EFailed; @@ -118,6 +133,73 @@ CTestPlatform::CCommandHandler::CommandStatus CTestPlatform::applyConfigurations } //////////////// Remote command handlers + +bool CTestPlatform::createExclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult) +{ + + assert (_pParameterMgrPlatformConnector != NULL); + + ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(false); + + assert(pCriterionType != NULL); + + uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1 ; + uint32_t uiState; + + for (uiState = 0; uiState < uiNbStates; uiState++) { + + const std::string& strValue = remoteCommand.getArgument(uiState + 1); + + if (!pCriterionType->addValuePair(uiState, strValue)) { + + strResult = "Unable to add value: " + strValue; + + return false; + } + } + + _pParameterMgrPlatformConnector->createSelectionCriterion(strName, pCriterionType); + + return true; +} + +bool CTestPlatform::createInclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult) +{ + assert (_pParameterMgrPlatformConnector != NULL); + + ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(true); + + assert(pCriterionType != NULL); + + uint32_t uiNbStates = remoteCommand.getArgumentCount() - 1 ; + + if (uiNbStates > 32) { + + strResult = "Maximum number of states for inclusive criterion is 32"; + + return false; + } + + uint32_t uiState; + + for (uiState = 0; uiState < uiNbStates; uiState++) { + + const std::string& strValue = remoteCommand.getArgument(uiState + 1); + + if (!pCriterionType->addValuePair(0x1 << uiState, strValue)) { + + strResult = "Unable to add value: " + strValue; + + return false; + } + } + + _pParameterMgrPlatformConnector->createSelectionCriterion(strName, pCriterionType); + + return true; +} + + bool CTestPlatform::createExclusiveSelectionCriterion(const string& strName, uint32_t uiNbStates, string& strResult) { ISelectionCriterionTypeInterface* pCriterionType = _pParameterMgrPlatformConnector->createSelectionCriterionType(false); diff --git a/test/test-platform/TestPlatform.h b/test/test-platform/TestPlatform.h index f169cce..1d7fcbb 100644 --- a/test/test-platform/TestPlatform.h +++ b/test/test-platform/TestPlatform.h @@ -53,6 +53,9 @@ public: private: //////////////// Remote command parsers /// Selection Criterion + CCommandHandler::CommandStatus createExclusiveSelectionCriterionFromStateListCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus createInclusiveSelectionCriterionFromStateListCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); + CCommandHandler::CommandStatus createExclusiveSelectionCriterionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); CCommandHandler::CommandStatus createInclusiveSelectionCriterionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); CCommandHandler::CommandStatus startParameterMgrCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); @@ -60,6 +63,9 @@ private: CCommandHandler::CommandStatus applyConfigurationsCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); // Commands + bool createExclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult); + bool createInclusiveSelectionCriterionFromStateList(const string& strName, const IRemoteCommand& remoteCommand, string& strResult); + bool createExclusiveSelectionCriterion(const string& strName, uint32_t uiNbValues, string& strResult); bool createInclusiveSelectionCriterion(const string& strName, uint32_t uiNbValues, string& strResult); bool setCriterionState(const string& strName, uint32_t uiState, string& strResult); |