Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ctest/CTestCustom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ SET(CTEST_CUSTOM_MEMCHECK_IGNORE
# runing python based tests would be long and useless.
fix_point_parameter
functional-test-legacy
xml-generator
)
9 changes: 6 additions & 3 deletions parameter/FileIncluderElementBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@
class CFileIncluderElementBuilder : public CElementBuilder
{
public:
CFileIncluderElementBuilder(bool bValidateWithSchemas)
: CElementBuilder(), _bValidateWithSchemas(bValidateWithSchemas)
CFileIncluderElementBuilder(bool bValidateWithSchemas, const std::string &schemaBaseUri)
: CElementBuilder(),
_bValidateWithSchemas(bValidateWithSchemas),
_schemaBaseUri(schemaBaseUri)
{
}

virtual CElement *createElement(const CXmlElement &xmlElement) const
{
return new CXmlFileIncluderElement(xmlElement.getNameAttribute(), xmlElement.getType(),
_bValidateWithSchemas);
_bValidateWithSchemas, _schemaBaseUri);
}

private:
bool _bValidateWithSchemas;
const std::string _schemaBaseUri;
};
8 changes: 4 additions & 4 deletions parameter/ParameterMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,7 @@ bool CParameterMgr::xmlParse(CXmlElementSerializingContext &elementSerializingCo
CXmlDocSource docSource(doc, _bValidateSchemasOnStart, pRootElement->getXmlElementName(),
pRootElement->getName(), strNameAttributeName);

// Schema Uri
setSchemaUri(docSource.getSchemaUri());
docSource.setSchemaBaseUri(getSchemaUri());

// Start clean
auto clean = [replace, &pRootElement] {
Expand Down Expand Up @@ -2644,7 +2643,7 @@ bool CParameterMgr::serializeElement(std::ostream &output,

// Use a doc source by loading data from instantiated Configurable Domains
CXmlMemoryDocSource memorySource(&element, _bValidateSchemasOnStart,
element.getXmlElementName(), getSchemaUri(),
element.getXmlElementName(),
"parameter-framework", getVersion());

// Use a doc sink to write the doc data in a stream
Expand Down Expand Up @@ -2814,7 +2813,8 @@ void CParameterMgr::feedElementLibraries()
pParameterCreationLibrary->addElementBuilder(
"FloatingPointParameter", new TNamedElementBuilderTemplate<CFloatingPointParameterType>);
pParameterCreationLibrary->addElementBuilder(
"SubsystemInclude", new CFileIncluderElementBuilder(_bValidateSchemasOnStart));
"SubsystemInclude", new CFileIncluderElementBuilder(_bValidateSchemasOnStart,
getSchemaUri()));

_pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);

Expand Down
11 changes: 9 additions & 2 deletions parameter/XmlFileIncluderElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
#define base CKindElement
CXmlFileIncluderElement::CXmlFileIncluderElement(const std::string &strName,
const std::string &strKind,
bool bValidateWithSchemas)
: base(strName, strKind), _bValidateSchemasOnStart(bValidateWithSchemas)
bool bValidateWithSchemas,
const std::string &schemaBaseUri)
: base(strName, strKind),
_bValidateSchemasOnStart(bValidateWithSchemas),
_schemaBaseUri(schemaBaseUri)
{
}

Expand All @@ -63,6 +66,10 @@ bool CXmlFileIncluderElement::fromXml(const CXmlElement &xmlElement,

CXmlDocSource docSource(doc, _bValidateSchemasOnStart, strIncludedElementType);

if (not _schemaBaseUri.empty()) {
docSource.setSchemaBaseUri(_schemaBaseUri);
}

if (!docSource.isParsable()) {

elementSerializingContext.setError("Could not parse document \"" + strPath + "\"");
Expand Down
3 changes: 2 additions & 1 deletion parameter/XmlFileIncluderElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ class CXmlFileIncluderElement : public CKindElement
{
public:
CXmlFileIncluderElement(const std::string &strName, const std::string &strKind,
bool bValidateWithSchemas);
bool bValidateWithSchemas, const std::string &schemaBaseUri);
// From IXmlSink
virtual bool fromXml(const CXmlElement &xmlElement, CXmlSerializingContext &serializingContext);

private:
// Element type
std::string getIncludedElementType() const;
bool _bValidateSchemasOnStart;
const std::string _schemaBaseUri;
};
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ add_subdirectory(test-platform)
add_subdirectory(test-subsystem)
add_subdirectory(introspection-subsystem)
add_subdirectory(tokenizer)
add_subdirectory(xml-generator)
5 changes: 2 additions & 3 deletions test/functional-tests-legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ if(BUILD_TESTING)
set(PFW_ROOT ${PROJECT_BINARY_DIR}/tmp/test-parameters)
set(PFW_RESULT ${PFW_ROOT}/result)

file(COPY ${PROJECT_SOURCE_DIR}/schemas/ DESTINATION ${PFW_ROOT}/xml/schemas)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xml/configuration/Structure/Test/TestSubsystem.xml.in
${PFW_ROOT}/xml/configuration/Structure/Test/TestSubsystem.xml @ONLY)
Expand Down Expand Up @@ -62,5 +60,6 @@ if(BUILD_TESTING)
set_test_env(functional-test-legacy)
set_property(TEST functional-test-legacy APPEND PROPERTY ENVIRONMENT
PFW_ROOT=${PFW_ROOT}
PFW_RESULT=${PFW_RESULT})
PFW_RESULT=${PFW_RESULT}
PFW_SCHEMAS=${PROJECT_SOURCE_DIR}/schemas)
endif()
1 change: 1 addition & 0 deletions test/functional-tests-legacy/Util/PfwUnitTestLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def createExclusiveCriterion(self, name, nb):

# Starts the Pfw
def start(self):
self.sendCmd("setSchemaUri", os.environ["PFW_SCHEMAS"])
self.sendCmd("setValidateSchemasOnStart", "true")
self.sendCmd("start")
self.pfw.setRemoteProcess(self.remoteProcess)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd" SystemClassName="Test">
<ConfigurableDomains SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
<Configuration Name="Conf_1_0">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--DOMAIN 1 DEFINITION-->
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">

<ConfigurableDomain Name="Domain_0_1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../schemas/ConfigurableDomains.xsd" SystemClassName="Test">
<ConfigurableDomains SystemClassName="Test">
<ConfigurableDomain Name="Domain_1">
<Configurations>
<Configuration Name="Conf_1_0">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ParameterFrameworkConfiguration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ParameterFrameworkConfiguration.xsd"
SystemClassName="Test" ServerPort="5000" TuningAllowed="true">
<SubsystemPlugins>
<Location Folder="">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../schemas/ConfigurableDomains.xsd"
SystemClassName="Test">
<ConfigurableDomain Name="Domain_0">
<Configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<SystemClass
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../schemas/SystemClass.xsd"
Name="Test">
<SubsystemInclude Path="TestSubsystem.xml"/>
</SystemClass>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Subsystem
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../schemas/Subsystem.xsd"
Name="Test" Type="TEST">
<ComponentLibrary>
<ComponentType Name="TEST_DIR">
Expand Down
4 changes: 1 addition & 3 deletions test/functional-tests/Handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ struct AllParamsPF : public ParameterFramework

static string rootNode(string name, string attributes, string content)
{
return '<' + name + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
" xsi:noNamespaceSchemaLocation='" +
name + ".xsd'" + ' ' + attributes + '>' + content + "</" + name + '>';
return '<' + name + ' ' + attributes + '>' + content + "</" + name + '>';
}
};

Expand Down
19 changes: 19 additions & 0 deletions test/test-platform/TestPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ bool CTestPlatform::run(std::string &strError)
&CTestPlatform::getter<&CParameterMgrPlatformConnector::getValidateSchemasOnStart>, 0, "",
"Get policy for schema validation based on .xsd files.");

commandHandler.addCommandParser("getSchemaUri", &CTestPlatform::getSchemaUri, 0,
"", "Get the directory where schemas can be found.");
commandHandler.addCommandParser("setSchemaUri", &CTestPlatform::setSchemaUri, 1,
"<directory>", "Set the directory where schemas can be found.");

return mRemoteProcessorServer.process(commandHandler);
}

Expand Down Expand Up @@ -202,6 +207,20 @@ CTestPlatform::CommandReturn CTestPlatform::getter(const IRemoteCommand & /*comm
return CTestPlatform::CCommandHandler::ESucceeded;
}

CTestPlatform::CommandReturn CTestPlatform::getSchemaUri(const IRemoteCommand & /*remotecommand*/,
string &result)
{
result = mParameterMgrPlatformConnector.getSchemaUri();
return CTestPlatform::CCommandHandler::EDone;
}

CTestPlatform::CommandReturn CTestPlatform::setSchemaUri(const IRemoteCommand &remotecommand,
string & /*result*/)
{
mParameterMgrPlatformConnector.setSchemaUri(remotecommand.getArgument(0));
return CTestPlatform::CCommandHandler::EDone;
}

CTestPlatform::CommandReturn CTestPlatform::setCriterionState(const IRemoteCommand &remoteCommand,
string &strResult)
{
Expand Down
3 changes: 3 additions & 0 deletions test/test-platform/TestPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class CTestPlatform
CommandReturn createInclusiveSelectionCriterion(const IRemoteCommand &remoteCommand,
std::string &strResult);

CommandReturn getSchemaUri(const IRemoteCommand &remotecommand, std::string &result);
CommandReturn setSchemaUri(const IRemoteCommand &remotecommand, std::string &result);

/** Callback to set a criterion's value, see ISelectionCriterionInterface::setCriterionState.
* @see CCommandHandler::RemoteCommandParser for detail on each arguments and return
*
Expand Down
27 changes: 9 additions & 18 deletions tools/xmlGenerator/portAllocator.py → test/xml-generator/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/python2
#
# Copyright (c) 2011-2014, Intel Corporation
# Copyright (c) 2015, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -28,21 +26,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys, socket

serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Create a listening socket on a random available port on localhost
serversock.bind(('127.0.0.1',0))
serversock.listen(0)
if (BUILD_TESTING AND PYTHON_BINDINGS)

# Print the chosen port
print(serversock.getsockname()[1])
serversock.close()
find_package(PythonInterp 2 REQUIRED)

except socket.error, (errno,message):
sys.stderr.write("portAllocator: Socket creation error " + str(errno) + ": " + message + '\n')
if serversock:
serversock.close()
sys.exit(1)
add_test(NAME xml-generator
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tools/xmlGenerator
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py)

# Custom function defined in the top-level CMakeLists
set_test_env(xml-generator)
endif()
4 changes: 4 additions & 0 deletions test/xml-generator/Class.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<SystemClass Name="Test">
<SubsystemInclude Path="Subsystem.xml"/>
</SystemClass>
6 changes: 6 additions & 0 deletions test/xml-generator/ParameterFrameworkConfiguration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ParameterFrameworkConfiguration SystemClassName="Test" ServerPort="5066" TuningAllowed="false">
<SubsystemPlugins>
</SubsystemPlugins>
<StructureDescriptionFileLocation Path="Class.xml"/>
</ParameterFrameworkConfiguration>
17 changes: 17 additions & 0 deletions test/xml-generator/Subsystem.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Subsystem Name="test" Type="Virtual" xmlns:xi="http://www.w3.org/2001/XInclude">
<ComponentLibrary>
<xi:include href="TuningStructure.xml"/>
</ComponentLibrary>
<InstanceDefinition>

<Component Type="Tuning" Name="tuning"/>

<ParameterBlock Name="block" ArrayLength="5">
<FixedPointParameter Name="q2.5" Size="8" Integral="2" Fractional="5"/>
<IntegerParameter Name="uint8" Signed="false" Size="8"/>
<StringParameter Name="string" MaxLength="20"/>
</ParameterBlock>

</InstanceDefinition>
</Subsystem>
23 changes: 23 additions & 0 deletions test/xml-generator/TuningSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurableDomains SystemClassName="Test">
<ConfigurableDomain Name="Calibration" SequenceAware="false">
<Configurations>
<Configuration Name="default">
<CompoundRule Type="All">
</CompoundRule>
</Configuration>
</Configurations>

<ConfigurableElements>
<ConfigurableElement Path="/Test/test/tuning/bool"/>
</ConfigurableElements>

<Settings>
<Configuration Name="default">
<ConfigurableElement Path="/Test/test/tuning/bool">
<BooleanParameter Name="bool">1</BooleanParameter>
</ConfigurableElement>
</Configuration>
</Settings>
</ConfigurableDomain>
</ConfigurableDomains>
6 changes: 6 additions & 0 deletions test/xml-generator/TuningStructure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ComponentLibrary>
<ComponentType Name="Tuning">
<BooleanParameter Name="bool"/>
</ComponentType>
</ComponentLibrary>
2 changes: 2 additions & 0 deletions test/xml-generator/criteria.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
InclusiveCriterion Colors : Red Green Blue
ExclusiveCriterion Switch : On Off
Loading