From b0c7c3b9f700301c21c5da79f3ab05933ff8f038 Mon Sep 17 00:00:00 2001 From: Thomas Cahuzac Date: Wed, 2 Dec 2015 09:28:07 +0100 Subject: [PATCH 1/5] Decorrelating auto-sync and tuning-mode Currently auto-sync can be disabled in tuning mode only. This patch decorrelates auto-sync and tnuning mode features: they can be activated independently. Signed-off-by: Thomas Cahuzac --- parameter/ParameterMgr.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index 1534e1e02..4e4360e41 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -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 @@ -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) { @@ -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) { From a796245bc52482993a310ba536c6151d7306c1c8 Mon Sep 17 00:00:00 2001 From: Thomas Cahuzac Date: Wed, 2 Dec 2015 09:34:01 +0100 Subject: [PATCH 2/5] Introducing introspection subsystem Functional testing auto-sync feature requires a fake subsystem that allows to retrieve parameter value set by the parameter-framework. This patch introduces the introspection-subsystem, it provides the ability to retrieve the value of a boolean parameter. Signed-off-by: Thomas Cahuzac --- test/CMakeLists.txt | 1 + test/introspection-subsystem/CMakeLists.txt | 58 ++++++++++++ .../IntrospectionEntryPoint.cpp | 45 +++++++++ .../IntrospectionSubsystem.cpp | 47 ++++++++++ .../IntrospectionSubsystem.h | 51 +++++++++++ .../IntrospectionSubsystemBuilder.cpp | 42 +++++++++ .../IntrospectionSubsystemObject.cpp | 87 ++++++++++++++++++ .../IntrospectionSubsystemObject.h | 91 +++++++++++++++++++ .../include/IntrospectionEntryPoint.h | 42 +++++++++ 9 files changed, 464 insertions(+) create mode 100644 test/introspection-subsystem/CMakeLists.txt create mode 100644 test/introspection-subsystem/IntrospectionEntryPoint.cpp create mode 100644 test/introspection-subsystem/IntrospectionSubsystem.cpp create mode 100644 test/introspection-subsystem/IntrospectionSubsystem.h create mode 100644 test/introspection-subsystem/IntrospectionSubsystemBuilder.cpp create mode 100644 test/introspection-subsystem/IntrospectionSubsystemObject.cpp create mode 100644 test/introspection-subsystem/IntrospectionSubsystemObject.h create mode 100644 test/introspection-subsystem/include/IntrospectionEntryPoint.h diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d081e4e05..1fdbb6c55 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/introspection-subsystem/CMakeLists.txt b/test/introspection-subsystem/CMakeLists.txt new file mode 100644 index 000000000..faccab348 --- /dev/null +++ b/test/introspection-subsystem/CMakeLists.txt @@ -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() diff --git a/test/introspection-subsystem/IntrospectionEntryPoint.cpp b/test/introspection-subsystem/IntrospectionEntryPoint.cpp new file mode 100644 index 000000000..19bc5185b --- /dev/null +++ b/test/introspection-subsystem/IntrospectionEntryPoint.cpp @@ -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(); +} + +} +} diff --git a/test/introspection-subsystem/IntrospectionSubsystem.cpp b/test/introspection-subsystem/IntrospectionSubsystem.cpp new file mode 100644 index 000000000..e1ff8aadf --- /dev/null +++ b/test/introspection-subsystem/IntrospectionSubsystem.cpp @@ -0,0 +1,47 @@ +/* + * 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 "IntrospectionSubsystem.h" +#include "IntrospectionSubsystemObject.h" +#include + +namespace parameterFramework +{ +namespace introspectionSubsystem +{ + +Subsystem::Subsystem(const std::string& name, core::log::Logger& logger) + : base(name, logger) +{ + addSubsystemObjectFactory(new TSubsystemObjectFactory("Object", 0)); +} + +} +} diff --git a/test/introspection-subsystem/IntrospectionSubsystem.h b/test/introspection-subsystem/IntrospectionSubsystem.h new file mode 100644 index 000000000..92b229cf1 --- /dev/null +++ b/test/introspection-subsystem/IntrospectionSubsystem.h @@ -0,0 +1,51 @@ +/* + * 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. + */ +#pragma once + +#include + +namespace parameterFramework +{ +namespace introspectionSubsystem +{ + +/** This subsystem allows to retrieve parameter value set by the + * parameter-framework */ +class Subsystem : public CSubsystem +{ +public: + Subsystem(const std::string& name, core::log::Logger& logger); + +private: + using base = CSubsystem; +}; + +} +} diff --git a/test/introspection-subsystem/IntrospectionSubsystemBuilder.cpp b/test/introspection-subsystem/IntrospectionSubsystemBuilder.cpp new file mode 100644 index 000000000..28d7061df --- /dev/null +++ b/test/introspection-subsystem/IntrospectionSubsystemBuilder.cpp @@ -0,0 +1,42 @@ +/* + * 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 +#include +#include "IntrospectionSubsystem.h" + + +void PARAMETER_FRAMEWORK_PLUGIN_ENTRYPOINT_V1(CSubsystemLibrary* subsystemLibrary, + core::log::Logger& logger) +{ + using Subsystem = parameterFramework::introspectionSubsystem::Subsystem; + subsystemLibrary->addElementBuilder("INTROSPECTION", + new TLoggingElementBuilderTemplate( + logger)); +} diff --git a/test/introspection-subsystem/IntrospectionSubsystemObject.cpp b/test/introspection-subsystem/IntrospectionSubsystemObject.cpp new file mode 100644 index 000000000..ba6ca8dd4 --- /dev/null +++ b/test/introspection-subsystem/IntrospectionSubsystemObject.cpp @@ -0,0 +1,87 @@ +/* + * 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 "IntrospectionSubsystemObject.h" +#include +#include + +namespace parameterFramework +{ +namespace introspectionSubsystem +{ + +const SubsystemObject *SubsystemObject::mSingletonInstance = nullptr; + +/* Helper function */ +const CParameterType *geParameterType(CInstanceConfigurableElement *element) +{ + return static_cast(element->getTypeElement()); +} + +SubsystemObject::SubsystemObject(const std::string& /*mappingValue*/, + CInstanceConfigurableElement* instanceConfigurableElement, + const CMappingContext& /*context*/, + core::log::Logger& logger) : + base(instanceConfigurableElement, logger), + mParameter(false) +{ + /* Checking that structure matches the internal parameter */ + ALWAYS_ASSERT(geParameterType(instanceConfigurableElement)->getSize() == parameterSize, + "Wrong parameter size"); + ALWAYS_ASSERT((instanceConfigurableElement->getFootPrint() / parameterSize) == 1, + "Parameter shall not be an array"); + ALWAYS_ASSERT(geParameterType(instanceConfigurableElement)->isScalar(), + "Parameter shall be scalar"); + + /* Registering the instance into a singleton */ + registerInstance(*this); +} + +SubsystemObject::~SubsystemObject() +{ + /* Unregistering the instance from the singleton */ + unregisterInstance(*this); +} + +bool SubsystemObject::sendToHW(std::string& /*error*/) +{ + blackboardRead(&mParameter, parameterSize); + return true; +} + + +bool SubsystemObject::receiveFromHW(std::string& /*error*/) +{ + blackboardRead(&mParameter, parameterSize); + return true; +} + +} +} diff --git a/test/introspection-subsystem/IntrospectionSubsystemObject.h b/test/introspection-subsystem/IntrospectionSubsystemObject.h new file mode 100644 index 000000000..8e3d9e62f --- /dev/null +++ b/test/introspection-subsystem/IntrospectionSubsystemObject.h @@ -0,0 +1,91 @@ +/* + * 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. + */ +#pragma once + +#include +#include +#include + +class CMappingContext; + +namespace parameterFramework +{ +namespace introspectionSubsystem +{ + +/** This subsystem object exposes a boolean parameter. The value of this parameter + * can be retrieved by an external code that calls the getSingletonInstanceValue() + * static method. + */ +class SubsystemObject final : public CSubsystemObject +{ +public: + SubsystemObject(const std::string& mappingValue, + CInstanceConfigurableElement* instanceConfigurableElement, + const CMappingContext& context, + core::log::Logger& logger); + ~SubsystemObject(); + + static bool getSingletonInstanceValue() + { + ALWAYS_ASSERT(mSingletonInstance != nullptr, "Singleton value has not been registered"); + return mSingletonInstance->mParameter; + } + +private: + using base = CSubsystemObject; + + virtual bool sendToHW(std::string& error) override; + virtual bool receiveFromHW(std::string& error) override; + + static void registerInstance(const SubsystemObject &instance) + { + ALWAYS_ASSERT(mSingletonInstance == nullptr, "An instance is already registered"); + mSingletonInstance = &instance; + } + + static void unregisterInstance(const SubsystemObject &instance) + { + //instance parameter is only used by assertion, so unused in release mode + (void)instance; + + ALWAYS_ASSERT(mSingletonInstance == &instance, "This instance was not registered."); + mSingletonInstance = nullptr; + } + + static const std::size_t parameterSize = sizeof(bool); + + static const SubsystemObject *mSingletonInstance; + + bool mParameter; +}; + +} +} diff --git a/test/introspection-subsystem/include/IntrospectionEntryPoint.h b/test/introspection-subsystem/include/IntrospectionEntryPoint.h new file mode 100644 index 000000000..1869ab5fe --- /dev/null +++ b/test/introspection-subsystem/include/IntrospectionEntryPoint.h @@ -0,0 +1,42 @@ +/* + * 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. + */ +#pragma once + +#include "introspection_subsystem_export.h" + +namespace parameterFramework +{ +namespace introspectionSubsystem +{ + +INTROSPECTION_SUBSYSTEM_EXPORT bool getParameterValue(); + +} +} From 69f41d6a43fe26aca774ea4f9a6410f8affac82b Mon Sep 17 00:00:00 2001 From: Thomas Cahuzac Date: Wed, 2 Dec 2015 11:08:45 +0100 Subject: [PATCH 3/5] Adding the ability to set configuration value to the pfw test wrapper. This patch allows the pfw test wrapper to set configuration values. Signed-off-by: Thomas Cahuzac --- .../include/ParameterFramework.hpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/functional-tests/include/ParameterFramework.hpp b/test/functional-tests/include/ParameterFramework.hpp index ac70b578a..f0a487e52 100644 --- a/test/functional-tests/include/ParameterFramework.hpp +++ b/test/functional-tests/include/ParameterFramework.hpp @@ -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. */ @@ -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. From f2490dbdce664af3f436286337f932396d70d298 Mon Sep 17 00:00:00 2001 From: Thomas Cahuzac Date: Wed, 2 Dec 2015 11:10:41 +0100 Subject: [PATCH 4/5] Allowing to choose the subsystem type when using the pfw test wrapper Currently the subsystem type used by the functional test framework is always "Virtual". This patch provides the ability to change it. Signed-off-by: Thomas Cahuzac --- test/functional-tests/include/Config.hpp | 3 +++ test/functional-tests/include/ConfigFiles.hpp | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/functional-tests/include/Config.hpp b/test/functional-tests/include/Config.hpp index f8532e0ec..4ee5b6897 100644 --- a/test/functional-tests/include/Config.hpp +++ b/test/functional-tests/include/Config.hpp @@ -67,6 +67,9 @@ struct Config { }; using Plugins = Plugin::Collection; Plugins plugins; + + /** Subsystem type. Virtual by default. */ + std::string subsystemType = "Virtual"; }; } // parameterFramework diff --git a/test/functional-tests/include/ConfigFiles.hpp b/test/functional-tests/include/ConfigFiles.hpp index 513a52fe7..15d18a10a 100644 --- a/test/functional-tests/include/ConfigFiles.hpp +++ b/test/functional-tests/include/ConfigFiles.hpp @@ -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() }, @@ -101,7 +102,7 @@ class ConfigFiles )"; const char *mStructureTemplate = R"( - + {components} From 6aa22a1641509e49e0ce8710617e77a433c9792a Mon Sep 17 00:00:00 2001 From: Thomas Cahuzac Date: Tue, 1 Dec 2015 12:45:35 +0100 Subject: [PATCH 5/5] 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 --- test/functional-tests/AutoSync.cpp | 134 +++++++++++++++++++++++++++ test/functional-tests/CMakeLists.txt | 5 +- 2 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 test/functional-tests/AutoSync.cpp diff --git a/test/functional-tests/AutoSync.cpp b/test/functional-tests/AutoSync.cpp new file mode 100644 index 000000000..7ca8afb69 --- /dev/null +++ b/test/functional-tests/AutoSync.cpp @@ -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 +#include +#include "Test.hpp" +#include +#include + +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"()"; + config.plugins = { { "", {"introspection-subsystem"} } }; + config.subsystemType = "INTROSPECTION"; + + config.domains = R"( + + + + + + + + + + + + + + 0 + + + + )"; + + 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()); + } + } + } + } + } + } + } + } +} + +} diff --git a/test/functional-tests/CMakeLists.txt b/test/functional-tests/CMakeLists.txt index e727f22d2..1ab0449c8 100644 --- a/test/functional-tests/CMakeLists.txt +++ b/test/functional-tests/CMakeLists.txt @@ -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)