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

Commit 036f55d

Browse files
committed
xml generation: introduce tests
Introduce basic tests for domainGenerator.py. No error case is covered yet. As it stood, the XML validity checking code wasn't covered. This new test also covers it. Same applies for <xi:include> tags: there wasn't any test suite using them. This one does. Each of these features should have their own test but this is a quick and easy solution. Signed-off-by: David Wagner <[email protected]>
1 parent fd8bfb3 commit 036f55d

15 files changed

+443
-0
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
)

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/xml-generator/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2015, Intel Corporation
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without modification,
5+
# are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation and/or
12+
# other materials provided with the distribution.
13+
#
14+
# 3. Neither the name of the copyright holder nor the names of its contributors
15+
# may be used to endorse or promote products derived from this software without
16+
# specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
if (BUILD_TESTING)
30+
31+
find_package(PythonInterp 2 REQUIRED)
32+
33+
add_test(NAME xml-generator
34+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tools/xmlGenerator
35+
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py)
36+
37+
# Custom function defined in the top-level CMakeLists
38+
set_test_env(xml-generator)
39+
endif()

test/xml-generator/Class.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<SystemClass Name="Test">
3+
<SubsystemInclude Path="Subsystem.xml"/>
4+
</SystemClass>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ParameterFrameworkConfiguration SystemClassName="Test" ServerPort="5066" TuningAllowed="false">
3+
<SubsystemPlugins>
4+
</SubsystemPlugins>
5+
<StructureDescriptionFileLocation Path="Class.xml"/>
6+
</ParameterFrameworkConfiguration>

test/xml-generator/Subsystem.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Subsystem Name="test" Type="Virtual" xmlns:xi="http://www.w3.org/2001/XInclude">
3+
<ComponentLibrary>
4+
<xi:include href="TuningStructure.xml"/>
5+
</ComponentLibrary>
6+
<InstanceDefinition>
7+
8+
<Component Type="Tuning" Name="tuning"/>
9+
10+
<ParameterBlock Name="block" ArrayLength="5">
11+
<FixedPointParameter Name="q2.5" Size="8" Integral="2" Fractional="5"/>
12+
<IntegerParameter Name="uint8" Signed="false" Size="8"/>
13+
<StringParameter Name="string" MaxLength="20"/>
14+
</ParameterBlock>
15+
16+
</InstanceDefinition>
17+
</Subsystem>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ConfigurableDomains SystemClassName="Test">
3+
<ConfigurableDomain Name="Calibration" SequenceAware="false">
4+
<Configurations>
5+
<Configuration Name="default">
6+
<CompoundRule Type="All">
7+
</CompoundRule>
8+
</Configuration>
9+
</Configurations>
10+
11+
<ConfigurableElements>
12+
<ConfigurableElement Path="/Test/test/tuning/bool"/>
13+
</ConfigurableElements>
14+
15+
<Settings>
16+
<Configuration Name="default">
17+
<ConfigurableElement Path="/Test/test/tuning/bool">
18+
<BooleanParameter Name="bool">1</BooleanParameter>
19+
</ConfigurableElement>
20+
</Configuration>
21+
</Settings>
22+
</ConfigurableDomain>
23+
</ConfigurableDomains>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ComponentLibrary>
3+
<ComponentType Name="Tuning">
4+
<BooleanParameter Name="bool"/>
5+
</ComponentType>
6+
</ComponentLibrary>

test/xml-generator/criteria.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
InclusiveCriterion Colors : Red Green Blue
2+
ExclusiveCriterion Switch : On Off

test/xml-generator/first.pfw

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
domainGroup: EddGroup
2+
Colors Includes Red
3+
4+
# Only inherits from "EddGroup" domainGroup
5+
domain: First
6+
Colors Includes Blue
7+
8+
confGroup: Green
9+
Colors Includes Green
10+
11+
# Inherits from "EddGroup" domainGroup, "First" domain
12+
# and from "Green" confGroup
13+
conf: On
14+
Switch Is On
15+
16+
component: /Test/test/block/1
17+
q2.5 = 1.2
18+
string = some string
19+
20+
# Inherits from "EddGroup" domainGroup, "First" domain
21+
# and from "Green" confGroup
22+
conf: Off
23+
Switch Is Off
24+
25+
component: /Test/test/block/1
26+
q2.5 = 1.2
27+
string = some string
28+
29+
# Inherits from "EddGroup" domainGroup and "First" domain
30+
conf: Default
31+
component: /Test/test/block/1
32+
q2.5 = 0
33+
string = some other string

0 commit comments

Comments
 (0)