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

Commit 7ab5e95

Browse files
committed
Merge pull request #329 from dawagner/xmlgeneration-check-conflicting-elements
Xml generation: check conflicting elements Conflicting elements are elements belonging to more than one domain. The behaviour in such a case is unspecified. In the context of XML generation from user input, this denotes a mistake from the user. We now warn him and fail the generation.
2 parents 6946bc1 + 576f444 commit 7ab5e95

File tree

13 files changed

+74
-46
lines changed

13 files changed

+74
-46
lines changed

parameter/ConfigurableDomain.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,6 @@ bool CConfigurableDomain::deleteConfiguration(const string &strName, string &str
686686

687687
void CConfigurableDomain::listAssociatedToElements(string &strResult) const
688688
{
689-
strResult = "\n";
690-
691689
ConfigurableElementListIterator it;
692690

693691
// Browse all configurable elements

parameter/ConfigurableDomains.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ bool CConfigurableDomains::split(const string &domainName, CConfigurableElement
317317

318318
void CConfigurableDomains::listAssociatedElements(string &strResult) const
319319
{
320-
strResult = "\n";
321-
322320
std::set<const CConfigurableElement *> configurableElementSet;
323321

324322
// Get all owned configurable elements
@@ -341,8 +339,6 @@ void CConfigurableDomains::listAssociatedElements(string &strResult) const
341339

342340
void CConfigurableDomains::listConflictingElements(string &strResult) const
343341
{
344-
strResult = "\n";
345-
346342
std::set<const CConfigurableElement *> configurableElementSet;
347343

348344
// Get all owned configurable elements
@@ -369,8 +365,6 @@ void CConfigurableDomains::listConflictingElements(string &strResult) const
369365

370366
void CConfigurableDomains::listDomains(string &strResult) const
371367
{
372-
strResult = "\n";
373-
374368
// List domains
375369
size_t uiNbConfigurableDomains = getNbChildren();
376370

parameter/ConfigurableElement.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ void CConfigurableElement::listBelongingDomains(std::string &strResult, bool bVe
468468
// Elements with no domains
469469
void CConfigurableElement::listRogueElements(std::string &strResult) const
470470
{
471-
strResult = "\n";
472-
473471
// Get rogue element aggregate list (no associated domain)
474472
std::list<const CConfigurableElement *> rogueElementList;
475473

@@ -568,11 +566,6 @@ void CConfigurableElement::listDomains(
568566
const std::list<const CConfigurableDomain *> &configurableDomainList, std::string &strResult,
569567
bool bVertical) const
570568
{
571-
if (bVertical && configurableDomainList.empty()) {
572-
573-
strResult = "\n";
574-
}
575-
576569
// Fill list
577570
ConfigurableDomainListConstIterator it;
578571
bool bFirst = true;

parameter/Element.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ string CElement::dumpContent(utility::ErrorContext &errorContext, const size_t d
122122
// Element properties
123123
void CElement::showProperties(string &strResult) const
124124
{
125-
strResult = "\n";
126125
strResult += "Kind: " + getKind() + "\n";
127126
showDescriptionProperty(strResult);
128127
}
@@ -330,8 +329,6 @@ bool CElement::removeChild(CElement *pChild)
330329

331330
void CElement::listChildren(string &strChildList) const
332331
{
333-
strChildList = "\n";
334-
335332
// Get list of children names
336333
for (CElement *pChild : _childArray) {
337334

parameter/ParameterMgr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,6 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommand
13701370
return CCommandHandler::EFailed;
13711371
}
13721372

1373-
strResult = string("\n");
1374-
13751373
if (!pLocatedElement) {
13761374

13771375
// List from root folder
@@ -1399,8 +1397,6 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersComma
13991397
return CCommandHandler::EFailed;
14001398
}
14011399

1402-
strResult = string("\n");
1403-
14041400
if (!pLocatedElement) {
14051401

14061402
// List from root folder

remote-processor/RemoteCommandHandlerTemplate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ class TRemoteCommandHandlerTemplate : public IRemoteCommandHandler
194194
{
195195
initMaxCommandUsageLength();
196196

197-
strResult = "\n";
198-
199197
// Show usages
200198
for (const auto *pRemoteCommandParserItem : _remoteCommandParserVector) {
201199

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
InclusiveCriterion Duplicate : Foo Foo

test/xml-generator/PFConfig/structure.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<InstanceDefinition>
1111

1212
<Component Name="included" Type="Included"/>
13+
<ParameterBlock Name="inline">
14+
<BooleanParameter Name="bool"/>
15+
</ParameterBlock>
1316

1417
<ParameterBlock Name="block" ArrayLength="5">
1518
<FixedPointParameter Name="q2.5" Size="8" Integral="2" Fractional="5"/>

test/xml-generator/test.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,42 @@ def check(self, reference=None, expectedErrors=0):
9090
config_dir = os.path.join(basedir, "PFConfig")
9191
vector_dir = os.path.join(basedir, "testVector")
9292
class TestCase(unittest.TestCase):
93-
nominal_reference = open(os.path.join(vector_dir, "reference.xml")).read().splitlines()
94-
nominal_pfconfig = PfConfig(os.path.join(config_dir, "configuration.xml"),
95-
os.path.join(config_dir, "criteria.txt"),
96-
os.path.join(basedir, "../../schemas"))
97-
nominal_vector = TestVector(os.path.join(vector_dir, "initialSettings.xml"),
98-
[os.path.join(vector_dir, "first.pfw"),
99-
os.path.join(vector_dir, "second.pfw"),
100-
os.path.join(vector_dir, "complex.pfw")],
101-
[os.path.join(vector_dir, "third.xml"),
102-
os.path.join(vector_dir, "fourth.xml")])
93+
def setUp(self):
94+
self.nominal_reference = open(os.path.join(vector_dir, "reference.xml")).read().splitlines()
95+
self.nominal_pfconfig = PfConfig(os.path.join(config_dir, "configuration.xml"),
96+
os.path.join(config_dir, "criteria.txt"),
97+
os.path.join(basedir, "../../schemas"))
98+
self.nominal_vector = TestVector(os.path.join(vector_dir, "initialSettings.xml"),
99+
[os.path.join(vector_dir, "first.pfw"),
100+
os.path.join(vector_dir, "second.pfw"),
101+
os.path.join(vector_dir, "complex.pfw")],
102+
[os.path.join(vector_dir, "third.xml"),
103+
os.path.join(vector_dir, "fourth.xml")])
103104

104105
def test_nominal(self):
105106
tester = Tester(self.nominal_pfconfig, self.nominal_vector)
106107
tester.check(self.nominal_reference)
107108

108109
def test_nonfatalError(self):
109-
vector = copy.copy(self.nominal_vector)
110-
vector.edds.append(os.path.join(vector_dir, "duplicate.pfw"))
110+
self.nominal_vector.edds.append(os.path.join(vector_dir, "duplicate.pfw"))
111111

112-
tester = Tester(self.nominal_pfconfig, vector)
112+
tester = Tester(self.nominal_pfconfig, self.nominal_vector)
113113
tester.check(self.nominal_reference, expectedErrors=1)
114114

115+
def test_conflicting(self):
116+
vector = TestVector(edds=[os.path.join(vector_dir, "conflicting.pfw")])
117+
118+
tester = Tester(self.nominal_pfconfig, vector)
119+
tester.check(expectedErrors=1)
120+
121+
def test_fail_criteria(self):
122+
self.nominal_pfconfig.criteria = os.path.join(config_dir, "duplicate_criterion_value.txt")
123+
# Empty test vector: we want to make sure that the erroneous criterion
124+
# is the only source of error
125+
empty_vector = TestVector()
126+
127+
tester = Tester(self.nominal_pfconfig, empty_vector)
128+
tester.check(expectedErrors=1)
129+
115130
if __name__ == "__main__":
116131
unittest.main()

test/xml-generator/testVector/complex.pfw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ domainGroup: Red sequenceAware
3333
Colors Includes Blue
3434

3535
component: /Test/test
36-
component: block/3
36+
component: block/0
3737
q2.5 = 1.18750
3838
string = 12 ab @ <![CDATA[ < > \n \0 ✔ "'\
39-
component: included
39+
component: inline
4040
bool = 1

0 commit comments

Comments
 (0)