From 8bd2757c16afd5e31bf38c93ce09ba833bba8052 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 2 May 2012 11:53:59 +0200 Subject: 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 Reviewed-on: http://android.intel.com:8080/47499 Reviewed-by: De Chivre, Renaud Tested-by: Mendi, EduardoX Reviewed-by: buildbot Tested-by: buildbot --- test/test-platform/TestPlatform.cpp | 82 +++++++++++++++++++++++++++++++++++++ test/test-platform/TestPlatform.h | 6 +++ 2 files changed, 88 insertions(+) (limited to 'test/test-platform') 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 #include #include +#include #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, " ", "Create inclusive selection criterion from state name list"); + _pCommandHandler->addCommandParser("createInclusiveSelectionCriterionFromStateList", &CTestPlatform::createInclusiveSelectionCriterionFromStateListCommandProcess, 2, " ", "Create exclusive selection criterion from state name list"); + _pCommandHandler->addCommandParser("createExclusiveSelectionCriterion", &CTestPlatform::createExclusiveSelectionCriterionCommandProcess, 2, " ", "Create inclusive selection criterion"); _pCommandHandler->addCommandParser("createInclusiveSelectionCriterion", &CTestPlatform::createInclusiveSelectionCriterionCommandProcess, 2, " ", "Create exclusive selection criterion"); + _pCommandHandler->addCommandParser("start", &CTestPlatform::startParameterMgrCommandProcess, 0, "", "Start ParameterMgr"); _pCommandHandler->addCommandParser("setCriterionState", &CTestPlatform::setCriterionStateCommandProcess, 2, " ", "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); -- cgit v1.1