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

Commit 73ce970

Browse files
committed
Merge pull request #320 from dawagner/xml-generation-fixes-and-tests
Xml generation/validation fixes and tests - change how schema are found and XML files validated - fix the XML generation script - add XML generation tests
2 parents cf68468 + 27d0dad commit 73ce970

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+499
-411
lines changed

ctest/CTestCustom.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ SET(CTEST_CUSTOM_MEMCHECK_IGNORE
44
# runing python based tests would be long and useless.
55
fix_point_parameter
66
functional-test-legacy
7+
xml-generator
78
)

parameter/FileIncluderElementBuilder.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@
4141
class CFileIncluderElementBuilder : public CElementBuilder
4242
{
4343
public:
44-
CFileIncluderElementBuilder(bool bValidateWithSchemas)
45-
: CElementBuilder(), _bValidateWithSchemas(bValidateWithSchemas)
44+
CFileIncluderElementBuilder(bool bValidateWithSchemas, const std::string &schemaBaseUri)
45+
: CElementBuilder(),
46+
_bValidateWithSchemas(bValidateWithSchemas),
47+
_schemaBaseUri(schemaBaseUri)
4648
{
4749
}
4850

4951
virtual CElement *createElement(const CXmlElement &xmlElement) const
5052
{
5153
return new CXmlFileIncluderElement(xmlElement.getNameAttribute(), xmlElement.getType(),
52-
_bValidateWithSchemas);
54+
_bValidateWithSchemas, _schemaBaseUri);
5355
}
5456

5557
private:
5658
bool _bValidateWithSchemas;
59+
const std::string _schemaBaseUri;
5760
};

parameter/ParameterMgr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ bool CParameterMgr::xmlParse(CXmlElementSerializingContext &elementSerializingCo
636636
CXmlDocSource docSource(doc, _bValidateSchemasOnStart, pRootElement->getXmlElementName(),
637637
pRootElement->getName(), strNameAttributeName);
638638

639-
// Schema Uri
640-
setSchemaUri(docSource.getSchemaUri());
639+
docSource.setSchemaBaseUri(getSchemaUri());
641640

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

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

26502649
// Use a doc sink to write the doc data in a stream
@@ -2814,7 +2813,8 @@ void CParameterMgr::feedElementLibraries()
28142813
pParameterCreationLibrary->addElementBuilder(
28152814
"FloatingPointParameter", new TNamedElementBuilderTemplate<CFloatingPointParameterType>);
28162815
pParameterCreationLibrary->addElementBuilder(
2817-
"SubsystemInclude", new CFileIncluderElementBuilder(_bValidateSchemasOnStart));
2816+
"SubsystemInclude", new CFileIncluderElementBuilder(_bValidateSchemasOnStart,
2817+
getSchemaUri()));
28182818

28192819
_pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
28202820

parameter/XmlFileIncluderElement.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@
3838
#define base CKindElement
3939
CXmlFileIncluderElement::CXmlFileIncluderElement(const std::string &strName,
4040
const std::string &strKind,
41-
bool bValidateWithSchemas)
42-
: base(strName, strKind), _bValidateSchemasOnStart(bValidateWithSchemas)
41+
bool bValidateWithSchemas,
42+
const std::string &schemaBaseUri)
43+
: base(strName, strKind),
44+
_bValidateSchemasOnStart(bValidateWithSchemas),
45+
_schemaBaseUri(schemaBaseUri)
4346
{
4447
}
4548

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

6467
CXmlDocSource docSource(doc, _bValidateSchemasOnStart, strIncludedElementType);
6568

69+
if (not _schemaBaseUri.empty()) {
70+
docSource.setSchemaBaseUri(_schemaBaseUri);
71+
}
72+
6673
if (!docSource.isParsable()) {
6774

6875
elementSerializingContext.setError("Could not parse document \"" + strPath + "\"");

parameter/XmlFileIncluderElement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ class CXmlFileIncluderElement : public CKindElement
3838
{
3939
public:
4040
CXmlFileIncluderElement(const std::string &strName, const std::string &strKind,
41-
bool bValidateWithSchemas);
41+
bool bValidateWithSchemas, const std::string &schemaBaseUri);
4242
// From IXmlSink
4343
virtual bool fromXml(const CXmlElement &xmlElement, CXmlSerializingContext &serializingContext);
4444

4545
private:
4646
// Element type
4747
std::string getIncludedElementType() const;
4848
bool _bValidateSchemasOnStart;
49+
const std::string _schemaBaseUri;
4950
};

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ add_subdirectory(test-platform)
3535
add_subdirectory(test-subsystem)
3636
add_subdirectory(introspection-subsystem)
3737
add_subdirectory(tokenizer)
38+
add_subdirectory(xml-generator)

test/functional-tests-legacy/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ if(BUILD_TESTING)
3232
set(PFW_ROOT ${PROJECT_BINARY_DIR}/tmp/test-parameters)
3333
set(PFW_RESULT ${PFW_ROOT}/result)
3434

35-
file(COPY ${PROJECT_SOURCE_DIR}/schemas/ DESTINATION ${PFW_ROOT}/xml/schemas)
36-
3735
configure_file(
3836
${CMAKE_CURRENT_SOURCE_DIR}/xml/configuration/Structure/Test/TestSubsystem.xml.in
3937
${PFW_ROOT}/xml/configuration/Structure/Test/TestSubsystem.xml @ONLY)
@@ -62,5 +60,6 @@ if(BUILD_TESTING)
6260
set_test_env(functional-test-legacy)
6361
set_property(TEST functional-test-legacy APPEND PROPERTY ENVIRONMENT
6462
PFW_ROOT=${PFW_ROOT}
65-
PFW_RESULT=${PFW_RESULT})
63+
PFW_RESULT=${PFW_RESULT}
64+
PFW_SCHEMAS=${PROJECT_SOURCE_DIR}/schemas)
6665
endif()

test/functional-tests-legacy/Util/PfwUnitTestLib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def createExclusiveCriterion(self, name, nb):
113113

114114
# Starts the Pfw
115115
def start(self):
116+
self.sendCmd("setSchemaUri", os.environ["PFW_SCHEMAS"])
116117
self.sendCmd("setValidateSchemasOnStart", "true")
117118
self.sendCmd("start")
118119
self.pfw.setRemoteProcess(self.remoteProcess)

test/functional-tests-legacy/xml/XML_Test/Reference_Compliant.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ConfigurableDomains
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd"
43
SystemClassName="Test">
54
<ConfigurableDomain Name="Domain_1">
65
<Configurations>

test/functional-tests-legacy/xml/XML_Test/Reference_Criteria.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<ConfigurableDomains xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schemas/ConfigurableDomains.xsd" SystemClassName="Test">
2+
<ConfigurableDomains SystemClassName="Test">
33
<ConfigurableDomain Name="Domain_1">
44
<Configurations>
55
<Configuration Name="Conf_1_0">

0 commit comments

Comments
 (0)