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

Commit caa584c

Browse files
committed
Auto-sync feature functional test
This feature was not test. This patch introduces a functional test that uses the instrospection subsystem to check the auto-sync feature. Two sequences are tested: - when auto-sync is activated, parameter sync occurs when a parameter is changed in the blackboard. - when auto-sync is off, parameter sync occurs when tha auto-sync is turned to on. Signed-off-by: Thomas Cahuzac <[email protected]>
1 parent edb6c97 commit caa584c

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

test/functional-tests/AutoSync.cpp

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* Copyright (c) 2015, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation and/or
13+
* other materials provided with the distribution.
14+
*
15+
* 3. Neither the name of the copyright holder nor the names of its contributors
16+
* may be used to endorse or promote products derived from this software without
17+
* specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
#include "Config.hpp"
32+
#include "ParameterFramework.hpp"
33+
#include <SubsystemObject.h>
34+
#include <IntrospectionEntryPoint.h>
35+
#include "Test.hpp"
36+
#include <catch.hpp>
37+
#include <string>
38+
39+
using std::string;
40+
41+
namespace parameterFramework
42+
{
43+
44+
struct BoolPF : public ParameterFramework
45+
{
46+
BoolPF()
47+
: ParameterFramework{ createConfig() } {}
48+
49+
/** Set the boolean parameter value within the "Conf" configuration,
50+
* which is always applicable. */
51+
void setParameterValue(bool value)
52+
{
53+
std::string valueStr = value ? "1" : "0";
54+
setConfigurationParameter("Domain", "Conf", "/test/test/param", valueStr);
55+
}
56+
57+
private:
58+
static Config createConfig()
59+
{
60+
Config config;
61+
config.instances = R"(<BooleanParameter Name="param" Mapping="Object"/>)";
62+
config.plugins = { { "", {"introspection-subsystem"} } };
63+
config.subsystemType = "INTROSPECTION";
64+
65+
config.domains = R"(<ConfigurableDomain Name="Domain">
66+
<Configurations>
67+
<Configuration Name="Conf">
68+
<CompoundRule Type="All"/>
69+
</Configuration>
70+
</Configurations>
71+
72+
<ConfigurableElements>
73+
<ConfigurableElement Path="/test/test/param"/>
74+
</ConfigurableElements>
75+
76+
<Settings>
77+
<Configuration Name="Conf">
78+
<ConfigurableElement Path="/test/test/param">
79+
<BooleanParameter Name="param">0</BooleanParameter>
80+
</ConfigurableElement>
81+
</Configuration>
82+
</Settings>
83+
</ConfigurableDomain>)";
84+
85+
return config;
86+
}
87+
};
88+
89+
SCENARIO_METHOD(BoolPF, "Auto sync") {
90+
GIVEN("A Pfw that starts") {
91+
REQUIRE_NOTHROW(start());
92+
93+
THEN("Parameter value is false according to the settings") {
94+
REQUIRE_FALSE(introspectionSubsystem::getParameterValue());
95+
96+
AND_THEN("Tuning is off") {
97+
REQUIRE_FALSE(isTuningModeOn());
98+
99+
WHEN("Turning autosync on") {
100+
REQUIRE_NOTHROW(setAutoSync(true));
101+
102+
AND_WHEN("A parameter is set") {
103+
REQUIRE_NOTHROW(setParameterValue(true));
104+
105+
THEN("Sync is done") {
106+
CHECK(introspectionSubsystem::getParameterValue());
107+
}
108+
}
109+
}
110+
WHEN("Turning autosync off") {
111+
REQUIRE_NOTHROW(setAutoSync(false));
112+
113+
AND_WHEN("A parameter is set") {
114+
REQUIRE_NOTHROW(setParameterValue(true));
115+
116+
THEN("Sync should not have occurred yet") {
117+
REQUIRE_FALSE(introspectionSubsystem::getParameterValue());
118+
119+
WHEN("Turning autosync on") {
120+
REQUIRE_NOTHROW(setAutoSync(true));
121+
122+
THEN("Sync is done") {
123+
CHECK(introspectionSubsystem::getParameterValue());
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}
130+
}
131+
}
132+
}
133+
134+
}

test/functional-tests/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ if(BUILD_TESTING)
3636
add_executable(parameterFunctionalTest
3737
Basic.cpp
3838
FloatingPoint.cpp
39-
Handle.cpp)
39+
Handle.cpp
40+
AutoSync.cpp)
4041

4142
find_package(LibXml2 REQUIRED)
4243

4344
target_link_libraries(parameterFunctionalTest
44-
PRIVATE parameter catch tmpfile LibXml2::libxml2)
45+
PRIVATE parameter catch tmpfile LibXml2::libxml2 introspection-subsystem)
4546

4647
add_test(NAME parameterFunctionalTest
4748
COMMAND parameterFunctionalTest)

0 commit comments

Comments
 (0)