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

Commit 360a6be

Browse files
committed
Merge pull request #317 from tcahuzax/autosync_update
Decorrelating auto-sync and tuning mode Auto-sync and tuning mode can now be activated independently.
2 parents 705008b + 6aa22a1 commit 360a6be

15 files changed

+628
-19
lines changed

parameter/ParameterMgr.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,9 +2055,6 @@ bool CParameterMgr::setTuningMode(bool bOn, string& strError)
20552055
// Ensure application of currently selected configurations
20562056
// Force-apply configurations
20572057
doApplyConfigurations(true);
2058-
2059-
// Turn auto sync back on
2060-
_bAutoSyncOn = true;
20612058
}
20622059

20632060
// Store
@@ -2097,11 +2094,6 @@ bool CParameterMgr::outputRawFormatIsHex()
20972094
// Automatic hardware synchronization control (during tuning session)
20982095
bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
20992096
{
2100-
// Check tuning mode
2101-
if (!checkTuningModeOn(strError)) {
2102-
2103-
return false;
2104-
}
21052097
// Warn domains about turning auto sync back on
21062098
if (bAutoSyncOn && !_bAutoSyncOn) {
21072099

@@ -2126,11 +2118,6 @@ bool CParameterMgr::autoSyncOn() const
21262118
// Manual hardware synchronization control (during tuning session)
21272119
bool CParameterMgr::sync(string& strError)
21282120
{
2129-
// Check tuning mode
2130-
if (!checkTuningModeOn(strError)) {
2131-
2132-
return false;
2133-
}
21342121
// Warn domains about turning auto sync back on
21352122
if (_bAutoSyncOn) {
21362123

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ add_subdirectory(functional-tests-legacy)
3333
add_subdirectory(test-fixed-point-parameter)
3434
add_subdirectory(test-platform)
3535
add_subdirectory(test-subsystem)
36+
add_subdirectory(introspection-subsystem)
3637
add_subdirectory(tokenizer)

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)

test/functional-tests/include/Config.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ struct Config {
6767
};
6868
using Plugins = Plugin::Collection;
6969
Plugins plugins;
70+
71+
/** Subsystem type. Virtual by default. */
72+
std::string subsystemType = "Virtual";
7073
};
7174

7275
} // parameterFramework

test/functional-tests/include/ConfigFiles.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ class ConfigFiles
4444
public:
4545
ConfigFiles(const Config &config) :
4646
mStructureFile(format(mStructureTemplate,
47-
{ { "instances", config.instances },
48-
{ "components", config.components } })),
47+
{ { "type", config.subsystemType },
48+
{ "instances", config.instances },
49+
{ "components", config.components } })),
4950
mDomainsFile(format(mDomainsTemplate, { { "domains", config.domains } })),
5051
mConfigFile(format(mConfigTemplate,
5152
{ { "structurePath", mStructureFile.getPath() },
@@ -101,7 +102,7 @@ class ConfigFiles
101102
)";
102103
const char *mStructureTemplate = R"(<?xml version='1.0' encoding='UTF-8'?>
103104
<SystemClass Name='test'>
104-
<Subsystem Name='test' Type='Virtual'>
105+
<Subsystem Name='test' Type='{type}'>
105106
<ComponentLibrary>
106107
{components}
107108
</ComponentLibrary>

test/functional-tests/include/ParameterFramework.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace parameterFramework
3939
{
4040

4141
/** This forward declaration is an implementation detail, client should expect its presence.
42-
* @note This forward definition should not be needed as the `friend class ElementHandle`
42+
* @note This forward definition should not be needed as the `friend class ElementHandle`
4343
* declaration in ParameterFramework is itself a forward declaration.
4444
* Unfortunately there seem to be a bug in visual studio 2013, it is required.
4545
*/
@@ -132,6 +132,25 @@ class ParameterFramework : private parameterFramework::ConfigFiles,
132132
{
133133
mayFailCall(&PF::accessParameterValue, path, value, false);
134134
}
135+
136+
/** Wrap PF::accessConfigurationValue in "set" mode (and rename it) to throw an
137+
* exception on failure
138+
*/
139+
void setConfigurationParameter(const std::string domain,
140+
const std::string &configuration, const std::string& path, std::string& value)
141+
{
142+
mayFailCall(&PF::accessConfigurationValue, domain, configuration, path, value, true);
143+
}
144+
145+
/** Wrap PF::accessConfigurationValue in "get" mode (and rename it) to throw an
146+
* exception on failure
147+
*/
148+
void getConfigurationParameter(const std::string &domain,
149+
const std::string &configuration, const std::string& path, std::string& value)
150+
{
151+
mayFailCall(&PF::accessConfigurationValue, domain, configuration, path, value,
152+
false);
153+
}
135154
private:
136155

137156
/** Create an unwrapped element handle.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
# The introspection-subsystem provides ability to retrieve
30+
# a boolean parameter value set by the parameter-framework
31+
# at subsystem level.
32+
#
33+
# To get the boolean value, include the "IntrospectionEntryPoint.h"
34+
# header and use the getParameterValue() function.
35+
36+
37+
if (BUILD_TESTING)
38+
add_library(introspection-subsystem SHARED
39+
IntrospectionSubsystem.cpp
40+
IntrospectionSubsystemObject.cpp
41+
IntrospectionSubsystemBuilder.cpp
42+
IntrospectionEntryPoint.cpp)
43+
44+
# generating header used to export shared library symbols
45+
include(GenerateExportHeader)
46+
generate_export_header(introspection-subsystem
47+
BASE_NAME introspection_subsystem)
48+
49+
# exporting public headers:
50+
# - the header that contains the introspection function
51+
# - the header generated by cmake used to export symbols in shared library.
52+
#
53+
# Note : headers located in root project directory remain private.
54+
target_include_directories(introspection-subsystem
55+
PUBLIC "include" "${CMAKE_CURRENT_BINARY_DIR}")
56+
57+
target_link_libraries(introspection-subsystem PRIVATE parameter)
58+
endif()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 "IntrospectionEntryPoint.h"
32+
#include "IntrospectionSubsystemObject.h"
33+
34+
namespace parameterFramework
35+
{
36+
namespace introspectionSubsystem
37+
{
38+
39+
bool getParameterValue()
40+
{
41+
return SubsystemObject::getSingletonInstanceValue();
42+
}
43+
44+
}
45+
}

0 commit comments

Comments
 (0)