Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions parameter/ParameterMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,9 +2055,6 @@ bool CParameterMgr::setTuningMode(bool bOn, string& strError)
// Ensure application of currently selected configurations
// Force-apply configurations
doApplyConfigurations(true);

// Turn auto sync back on
_bAutoSyncOn = true;
}

// Store
Expand Down Expand Up @@ -2097,11 +2094,6 @@ bool CParameterMgr::outputRawFormatIsHex()
// Automatic hardware synchronization control (during tuning session)
bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
{
// Check tuning mode
if (!checkTuningModeOn(strError)) {

return false;
}
// Warn domains about turning auto sync back on
if (bAutoSyncOn && !_bAutoSyncOn) {

Expand All @@ -2126,11 +2118,6 @@ bool CParameterMgr::autoSyncOn() const
// Manual hardware synchronization control (during tuning session)
bool CParameterMgr::sync(string& strError)
{
// Check tuning mode
if (!checkTuningModeOn(strError)) {

return false;
}
// Warn domains about turning auto sync back on
if (_bAutoSyncOn) {

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ add_subdirectory(functional-tests-legacy)
add_subdirectory(test-fixed-point-parameter)
add_subdirectory(test-platform)
add_subdirectory(test-subsystem)
add_subdirectory(introspection-subsystem)
add_subdirectory(tokenizer)
134 changes: 134 additions & 0 deletions test/functional-tests/AutoSync.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "Config.hpp"
#include "ParameterFramework.hpp"
#include <SubsystemObject.h>
#include <IntrospectionEntryPoint.h>
#include "Test.hpp"
#include <catch.hpp>
#include <string>

using std::string;

namespace parameterFramework
{

struct BoolPF : public ParameterFramework
{
BoolPF()
: ParameterFramework{ createConfig() } {}

/** Set the boolean parameter value within the "Conf" configuration,
* which is always applicable. */
void setParameterValue(bool value)
{
std::string valueStr = value ? "1" : "0";
setConfigurationParameter("Domain", "Conf", "/test/test/param", valueStr);
}

private:
static Config createConfig()
{
Config config;
config.instances = R"(<BooleanParameter Name="param" Mapping="Object"/>)";
config.plugins = { { "", {"introspection-subsystem"} } };
config.subsystemType = "INTROSPECTION";

config.domains = R"(<ConfigurableDomain Name="Domain">
<Configurations>
<Configuration Name="Conf">
<CompoundRule Type="All"/>
</Configuration>
</Configurations>

<ConfigurableElements>
<ConfigurableElement Path="/test/test/param"/>
</ConfigurableElements>

<Settings>
<Configuration Name="Conf">
<ConfigurableElement Path="/test/test/param">
<BooleanParameter Name="param">0</BooleanParameter>
</ConfigurableElement>
</Configuration>
</Settings>
</ConfigurableDomain>)";

return config;
}
};

SCENARIO_METHOD(BoolPF, "Auto sync") {
GIVEN("A Pfw that starts") {
REQUIRE_NOTHROW(start());

THEN("Parameter value is false according to the settings") {
REQUIRE_FALSE(introspectionSubsystem::getParameterValue());

AND_THEN("Tuning is off") {
REQUIRE_FALSE(isTuningModeOn());

WHEN("Turning autosync on") {
REQUIRE_NOTHROW(setAutoSync(true));

AND_WHEN("A parameter is set") {
REQUIRE_NOTHROW(setParameterValue(true));

THEN("Sync is done") {
CHECK(introspectionSubsystem::getParameterValue());
}
}
}
WHEN("Turning autosync off") {
REQUIRE_NOTHROW(setAutoSync(false));

AND_WHEN("A parameter is set") {
REQUIRE_NOTHROW(setParameterValue(true));

THEN("Sync should not have occurred yet") {
REQUIRE_FALSE(introspectionSubsystem::getParameterValue());

WHEN("Turning autosync on") {
REQUIRE_NOTHROW(setAutoSync(true));

THEN("Sync is done") {
CHECK(introspectionSubsystem::getParameterValue());
}
}
}
}
}
}
}
}
}

}
5 changes: 3 additions & 2 deletions test/functional-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ if(BUILD_TESTING)
add_executable(parameterFunctionalTest
Basic.cpp
FloatingPoint.cpp
Handle.cpp)
Handle.cpp
AutoSync.cpp)

find_package(LibXml2 REQUIRED)

target_link_libraries(parameterFunctionalTest
PRIVATE parameter catch tmpfile LibXml2::libxml2)
PRIVATE parameter catch tmpfile LibXml2::libxml2 introspection-subsystem)

add_test(NAME parameterFunctionalTest
COMMAND parameterFunctionalTest)
Expand Down
3 changes: 3 additions & 0 deletions test/functional-tests/include/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct Config {
};
using Plugins = Plugin::Collection;
Plugins plugins;

/** Subsystem type. Virtual by default. */
std::string subsystemType = "Virtual";
};

} // parameterFramework
7 changes: 4 additions & 3 deletions test/functional-tests/include/ConfigFiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class ConfigFiles
public:
ConfigFiles(const Config &config) :
mStructureFile(format(mStructureTemplate,
{ { "instances", config.instances },
{ "components", config.components } })),
{ { "type", config.subsystemType },
{ "instances", config.instances },
{ "components", config.components } })),
mDomainsFile(format(mDomainsTemplate, { { "domains", config.domains } })),
mConfigFile(format(mConfigTemplate,
{ { "structurePath", mStructureFile.getPath() },
Expand Down Expand Up @@ -101,7 +102,7 @@ class ConfigFiles
)";
const char *mStructureTemplate = R"(<?xml version='1.0' encoding='UTF-8'?>
<SystemClass Name='test'>
<Subsystem Name='test' Type='Virtual'>
<Subsystem Name='test' Type='{type}'>
<ComponentLibrary>
{components}
</ComponentLibrary>
Expand Down
21 changes: 20 additions & 1 deletion test/functional-tests/include/ParameterFramework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace parameterFramework
{

/** This forward declaration is an implementation detail, client should expect its presence.
* @note This forward definition should not be needed as the `friend class ElementHandle`
* @note This forward definition should not be needed as the `friend class ElementHandle`
* declaration in ParameterFramework is itself a forward declaration.
* Unfortunately there seem to be a bug in visual studio 2013, it is required.
*/
Expand Down Expand Up @@ -132,6 +132,25 @@ class ParameterFramework : private parameterFramework::ConfigFiles,
{
mayFailCall(&PF::accessParameterValue, path, value, false);
}

/** Wrap PF::accessConfigurationValue in "set" mode (and rename it) to throw an
* exception on failure
*/
void setConfigurationParameter(const std::string domain,
const std::string &configuration, const std::string& path, std::string& value)
{
mayFailCall(&PF::accessConfigurationValue, domain, configuration, path, value, true);
}

/** Wrap PF::accessConfigurationValue in "get" mode (and rename it) to throw an
* exception on failure
*/
void getConfigurationParameter(const std::string &domain,
const std::string &configuration, const std::string& path, std::string& value)
{
mayFailCall(&PF::accessConfigurationValue, domain, configuration, path, value,
false);
}
private:

/** Create an unwrapped element handle.
Expand Down
58 changes: 58 additions & 0 deletions test/introspection-subsystem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (c) 2015, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# The introspection-subsystem provides ability to retrieve
# a boolean parameter value set by the parameter-framework
# at subsystem level.
#
# To get the boolean value, include the "IntrospectionEntryPoint.h"
# header and use the getParameterValue() function.


if (BUILD_TESTING)
add_library(introspection-subsystem SHARED
IntrospectionSubsystem.cpp
IntrospectionSubsystemObject.cpp
IntrospectionSubsystemBuilder.cpp
IntrospectionEntryPoint.cpp)

# generating header used to export shared library symbols
include(GenerateExportHeader)
generate_export_header(introspection-subsystem
BASE_NAME introspection_subsystem)

# exporting public headers:
# - the header that contains the introspection function
# - the header generated by cmake used to export symbols in shared library.
#
# Note : headers located in root project directory remain private.
target_include_directories(introspection-subsystem
PUBLIC "include" "${CMAKE_CURRENT_BINARY_DIR}")

target_link_libraries(introspection-subsystem PRIVATE parameter)
endif()
45 changes: 45 additions & 0 deletions test/introspection-subsystem/IntrospectionEntryPoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "IntrospectionEntryPoint.h"
#include "IntrospectionSubsystemObject.h"

namespace parameterFramework
{
namespace introspectionSubsystem
{

bool getParameterValue()
{
return SubsystemObject::getSingletonInstanceValue();
}

}
}
Loading