diff options
author | Sebastien Guiriec <sebastien.guiriec@renault.com> | 2017-05-02 14:22:24 +0200 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2019-03-12 17:49:28 -0700 |
commit | f10df4cb971d0626ce8d6ec062e73d23a2d33882 (patch) | |
tree | d87189fd6b67f250457ca6cc5b499b75faa379b6 | |
parent | d5cdd5fb5966ac9d0f06f61b721b8e5fb12d7ee4 (diff) | |
download | parameter-framework-f10df4cb971d0626ce8d6ec062e73d23a2d33882.tar.gz |
[PFW] Integrate PFW core version 3.2.8 release
PFW 3.2.8 release notes:
https://github.com/intel/parameter-framework/releases/tag/v3.2.8
This release contains the following changes:
- Fix dumpElement remote-process command issue
- Update Unit tests for the different parameter types using catch framework
- Fix windows Wix Installer issue
- Fix build issue for Fedora
- Clean up Client Simulator tool install part
Bug: 124767636
Test: build
Change-Id: If5ed1340b301b8d11a03df94f56c0d2b62b21bf7
Signed-off-by: Sebastien Guiriec <sebastien.guiriec@renault.com>
19 files changed, 1013 insertions, 20 deletions
diff --git a/support/android/parameter/version.h b/support/android/parameter/version.h index 589a33f..15d9a7d 100644 --- a/support/android/parameter/version.h +++ b/support/android/parameter/version.h @@ -27,4 +27,4 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define PARAMETER_FRAMEWORK_VERSION "v3.2.7" +#define PARAMETER_FRAMEWORK_VERSION "v3.2.8" diff --git a/upstream/.travis.yml b/upstream/.travis.yml index cdf4167..89a0fae 100644 --- a/upstream/.travis.yml +++ b/upstream/.travis.yml @@ -14,6 +14,7 @@ env: global: - PREFIX=$HOME/prefix - MY_CMAKE_OPTIONS="-DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$HOME/install" + - OSX_CMAKE_OPTIONS="-DBUILD_TESTING=OFF -DPYTHON_BINDINGS=OFF -DCLIENT_SIMULATOR=OFF" - CTEST_OUTPUT_ON_FAILURE=1 - LINUX=false - OSX=false diff --git a/upstream/.version b/upstream/.version index 02a5dbc..f7b0e75 100644 --- a/upstream/.version +++ b/upstream/.version @@ -1 +1 @@ -tag: v3.2.7 +tag: v3.2.8 diff --git a/upstream/CMakeLists.txt b/upstream/CMakeLists.txt index c29a8e3..3130016 100644 --- a/upstream/CMakeLists.txt +++ b/upstream/CMakeLists.txt @@ -50,6 +50,7 @@ option(PYTHON_BINDINGS "Python library to use the Parameter Framework from pytho option(C_BINDINGS "Library to use the Parameter Framework using a C API" ON) option(FATAL_WARNINGS "Turn warnings into errors (-Werror flag)" ON) option(NETWORKING "Set to OFF in order to stub networking code" ON) +option(CLIENT_SIMULATOR "Set to OFF to disable client simulator" ON) include(SetVersion.cmake) @@ -126,6 +127,9 @@ endif() add_subdirectory(tools/xmlGenerator) add_subdirectory(tools/xmlValidator) +if (CLIENT_SIMULATOR) + add_subdirectory(tools/clientSimulator) +endif() add_subdirectory(bindings) diff --git a/upstream/appveyor.yml b/upstream/appveyor.yml index 8ea45a4..eecba68 100644 --- a/upstream/appveyor.yml +++ b/upstream/appveyor.yml @@ -30,6 +30,10 @@ init: install: - cinst cmake.portable wget 7zip.commandline # Install Windows Installer XML (WiX) to create installer with cpack + # This package is currently broken because of a missing checksum. Since we + # are not distributing the packages, we don't care about that and can + # override the checksum: + - choco feature enable -n allowEmptyChecksums - cinst wixtoolset # Download and install external dependency if they are not in the cache @@ -66,7 +70,7 @@ build_script: - mkdir 64bits-debug && cd 64bits-debug # Add debug libxml2.dll in the path so that tests can find it - set TEST_PATH=%DEBUG_LIBXML2_PATH%\bin - - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%DEBUG_LIBXML2_PATH%" ..\.. + - cmake -G "NMake Makefiles" -DPYTHON_BINDINGS=OFF -DCLIENT_SIMULATOR=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%DEBUG_LIBXML2_PATH%" ..\.. - cmake --build . --config debug - ctest --build-config debug %CTEST_PARAMS% - cd .. @@ -74,7 +78,7 @@ build_script: - mkdir 64bits-release & cd 64bits-release # Add debug libxml2.dll in the path so that tests can find it - set TEST_PATH=%RELEASE_LIBXML2_PATH%\bin - - cmake -G "Visual Studio 14 2015 Win64" -DPYTHON_BINDINGS=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%RELEASE_LIBXML2_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. + - cmake -G "Visual Studio 14 2015 Win64" -DPYTHON_BINDINGS=OFF -DCLIENT_SIMULATOR=OFF -DCMAKE_PREFIX_PATH="%PREFIX_PATH%;%RELEASE_LIBXML2_PATH%" -DCMAKE_INSTALL_PREFIX=%INSTALL% ..\.. # Build, test and install - cmake --build . --config release - ctest --build-config release %CTEST_PARAMS% diff --git a/upstream/parameter/ArrayParameter.cpp b/upstream/parameter/ArrayParameter.cpp index 83ffe04..91ea448 100644 --- a/upstream/parameter/ArrayParameter.cpp +++ b/upstream/parameter/ArrayParameter.cpp @@ -171,7 +171,7 @@ bool CArrayParameter::access(std::vector<string> &astrValues, bool bSet, string CArrayParameter::logValue(CParameterAccessContext &context) const { // Dump values - return getValues(0, context); + return getValues(getOffset() - context.getBaseOffset(), context); } // Used for simulation and virtual subsystems diff --git a/upstream/parameter/BooleanParameterType.cpp b/upstream/parameter/BooleanParameterType.cpp index 66556d3..c6a5be4 100644 --- a/upstream/parameter/BooleanParameterType.cpp +++ b/upstream/parameter/BooleanParameterType.cpp @@ -108,6 +108,7 @@ bool CBooleanParameterType::toBlackboard(uint32_t uiUserValue, uint32_t &uiValue if (uiUserValue > 1) { parameterAccessContext.setError("Value out of range"); + return false; } uiValue = uiUserValue; diff --git a/upstream/test/catch/CMakeLists.txt b/upstream/test/catch/CMakeLists.txt index 14b9afa..4e7d68f 100644 --- a/upstream/test/catch/CMakeLists.txt +++ b/upstream/test/catch/CMakeLists.txt @@ -30,7 +30,7 @@ if(BUILD_TESTING) # TODO Use gtest as it is the team recommendation # Unfortunately gtest is very hard to setup as not binary distributed # catch is only one header so it is very easy - find_path(CATCH_HEADER catch.hpp) + find_path(CATCH_HEADER catch.hpp PATH_SUFFIXES catch) set_property(CACHE CATCH_HEADER PROPERTY ADVANCED TRUE) if(NOT CATCH_HEADER) message(SEND_ERROR diff --git a/upstream/test/functional-tests-legacy/PfwTestCase/Types/tINT16_ARRAY.py b/upstream/test/functional-tests-legacy/PfwTestCase/Types/tINT16_ARRAY.py index d280c07..74dbf6c 100644 --- a/upstream/test/functional-tests-legacy/PfwTestCase/Types/tINT16_ARRAY.py +++ b/upstream/test/functional-tests-legacy/PfwTestCase/Types/tINT16_ARRAY.py @@ -157,6 +157,42 @@ class TestCases(PfwTestCase): indexed_files_system_array_value = open(self.param_short_name).read().splitlines()[index] assert indexed_files_system_array_value == hex_indexed_array_value, log.F("FILESSYSTEM : %s[%s] update error" % (self.param_name, str(index))) + def test_dump_Values(self): + """ + Testing INT16_ARRAY dump value + --------------------------------- + Test case description : + ~~~~~~~~~~~~~~~~~~~~~~~ + - Set every INT16_ARRAY elements to values : 1 0 -50 0 0 + Tested commands : + ~~~~~~~~~~~~~~~~~ + - [setParameter] function + Used commands : + ~~~~~~~~~~~~~~~ + - [getParameter] function + Expected result : + ~~~~~~~~~~~~~~~~~ + - INT16_ARRAY array elements correctly recorded + - Blackboard and filesystem values checked + """ + log.D(self.test_dump_Values.__doc__) + index = 2 + indexed_array_value = self.array_min + indexed_array_value_path = "".join([self.param_name, "/", str(index)]) + hex_indexed_array_value = hex(c_uint16(indexed_array_value).value) + #Check parameter value setting + out, err = self.pfw.sendCmd("setParameter", str(indexed_array_value_path), str(indexed_array_value)) + assert err == None, log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), err)) + assert out == "Done", log.E("when setting parameter %s[%s]: %s" + % (self.param_name, str(index), out)) + #Check parameter value on blackboard + out, err = self.pfw.sendCmd("dumpElement", str(self.param_name), "") + #out, err = self.pfw.sendCmd("getParameter", str(indexed_array_value_path), "") + assert err == None, log.E("when setting parameter %s[%s] : %s" + % (self.param_name, str(index), err)) + assert out == str("- IntegerParameter: INT16_ARRAY = 1 0 -50 0 0"), log.F("BLACKBOARD : Incorrect value for %s, expected: %s, found: %s" + % (self.param_name, str("- IntegerParameter: INT16_ARRAY = 1 0 -50 0 0"), out)) def test_Min_Value_Overflow(self): """ diff --git a/upstream/test/functional-tests/BitParameter.cpp b/upstream/test/functional-tests/BitParameter.cpp new file mode 100644 index 0000000..0a0fb95 --- /dev/null +++ b/upstream/test/functional-tests/BitParameter.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2017, 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 "ElementHandle.hpp" +#include "Test.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validBitParameterInstances = Config{ + &Config::instances, + // Default for integers is unsigned/32bits + R"(<BitParameterBlock Name="nominal" Size="16"><BitParameter Pos="0" Size="1" Name="bool"/><BitParameter Pos="1" Size="2" Name="twobits"/><BitParameter Pos="3" Size="3" Max="6" Name="treebits"/></BitParameterBlock>)"}; + +const auto &invalidBitParameterParameters = + Tests<string>{{"Too much bits", "<BitParameterBlock Name='toomuchbits' Size='8'><BitParameter " + "Pos='1' Size='2' Name='twobits'/><BitParameter Pos='3' " + "Size='7' Name='toobits'/></BitParameterBlock>"}, + {"Max too high", "<BitParameterBlock Name='maxtoohigh' Size='8'><BitParameter " + "Pos='1' Size='2' Name='twobits'/><BitParameter Pos='3' " + "Size='2' Max='5' Name='toohigh'/></BitParameterBlock>"}}; + +struct BitParameterPF : public ParameterFramework +{ + BitParameterPF() : ParameterFramework{std::move(validBitParameterInstances)} {} +}; + +SCENARIO_METHOD(LazyPF, "Invalid BitParameter types XML structure", "[BitParameter types]") +{ + for (auto &vec : invalidBitParameterParameters) { + GIVEN ("intentional error: " + vec.title) { + create(Config{&Config::instances, vec.payload}); + THEN ("Start should fail") { + CHECK_THROWS_AS(mPf->start(), Exception); + } + } + } +} + +SCENARIO_METHOD(BitParameterPF, "BitParameter types", "[BitParameter types]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal/treebits"; + + AND_THEN ("Set/Get a BitParameter type parameter in real value space") { + + for (auto &vec : Tests<string>{ + {"(too high)", "7"}, {"(too low)", "-1"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "6"}, {"(lower limit)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get a BitParameter type parameter in real value space") { + ElementHandle handle{*this, path}; + REQUIRE_NOTHROW(setRawValueSpace(true)); + REQUIRE_NOTHROW(setHexOutputFormat(true)); + + for (auto &vec : Tests<string>{ + {"(too high)", "0x7"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "0x6"}, {"(lower limit)", "0x0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get a BitParameter type parameter in boolean") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<bool>{ + {"(upper limit)", true}, {"(lower limit)", false}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(handle.setAsBoolean(vec.payload), Exception); + } + } + } + + AND_THEN ("Set/Get a BitParameter type parameter in boolean") { + path = "/test/test/nominal/bool"; + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<bool>{ + {"(upper limit)", true}, {"(lower limit)", false}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(handle.setAsBoolean(vec.payload)); + bool getValueBack; + REQUIRE_NOTHROW(handle.getAsBoolean(getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + } + } +} +} diff --git a/upstream/test/functional-tests/Boolean.cpp b/upstream/test/functional-tests/Boolean.cpp new file mode 100644 index 0000000..c485aba --- /dev/null +++ b/upstream/test/functional-tests/Boolean.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2017, 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 "ElementHandle.hpp" +#include "Test.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validBooleanInstances = Config{&Config::instances, + // Default for integers is unsigned/32bits + R"(<BooleanParameter Name="Empty"/> + <BooleanParameter Name="nominal"/>)"}; + +struct BooleanPF : public ParameterFramework +{ + BooleanPF() : ParameterFramework{std::move(validBooleanInstances)} {} +}; + +SCENARIO_METHOD(BooleanPF, "Boolean types", "[Boolean types]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal"; + + AND_THEN ("Set/Get a Boolean type parameter in real value space") { + + for (auto &vec : Tests<string>{ + {"(too high)", "2"}, {"(too low)", "-1"}, {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "1"}, {"(lower limit)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get boolean type parameter handle") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<bool>{ + {"(upper limit)", true}, {"(lower limit)", false}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(handle.setAsBoolean(vec.payload)); + bool getValueBack; + REQUIRE_NOTHROW(handle.getAsBoolean(getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get integer type parameter handle") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<uint32_t>{ + {"(upper limit)", 1}, {"(lower limit)", 0}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(handle.setAsInteger(vec.payload)); + uint32_t getValueBack; + REQUIRE_NOTHROW(handle.getAsInteger(getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + for (auto &vec : Tests<uint32_t>{ + {"(too high)", 2}, + }) { + GIVEN ("An invalid value " + vec.title) { + CHECK_THROWS_AS(handle.setAsInteger(vec.payload), Exception); + } + } + } + + AND_THEN ("Set/Get a Boolean type parameter in real value space") { + ElementHandle handle{*this, path}; + REQUIRE_NOTHROW(setRawValueSpace(true)); + + for (auto &vec : Tests<string>{ + {"(too high hexa)", "0x2"}, + {"(too high dec)", "2"}, + {"(too low hexa )", "0xFF"}, + {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(TRUE hexa)", "0x1"}, {"(TRUE dec)", "1"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == "1"); + } + } + for (auto &vec : Tests<string>{ + {"(FALSE hexa)", "0x0"}, {"(FALSE dec)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == "0"); + } + } + } + } + } +} +} diff --git a/upstream/test/functional-tests/CMakeLists.txt b/upstream/test/functional-tests/CMakeLists.txt index bece75f..c3d02d0 100644 --- a/upstream/test/functional-tests/CMakeLists.txt +++ b/upstream/test/functional-tests/CMakeLists.txt @@ -35,8 +35,14 @@ if(BUILD_TESTING) # Add unit test add_executable(parameterFunctionalTest Basic.cpp + Boolean.cpp + BitParameter.cpp + EnumParameter.cpp FloatingPoint.cpp + FixedPoint.cpp Integer.cpp + Linear.cpp + Logarithmic.cpp Handle.cpp AutoSync.cpp) diff --git a/upstream/test/functional-tests/EnumParameter.cpp b/upstream/test/functional-tests/EnumParameter.cpp new file mode 100644 index 0000000..5d17837 --- /dev/null +++ b/upstream/test/functional-tests/EnumParameter.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2017, 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 "ElementHandle.hpp" +#include "Test.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validEnumParameterInstances = Config{ + &Config::instances, + // Default for integers is unsigned/32bits + R"(<EnumParameter Name="nominal" Size="8"><ValuePair Literal="on" Numerical="3"/><ValuePair Literal="off" Numerical="0"/></EnumParameter>)"}; + +const auto &invalidEnumParameterParameters = Tests<string>{ + {"No Size", "<EnumParameter Name='nosize'><ValuePair Literal='on' Numerical='3'/><ValuePair " + "Literal='off' Numerical='0'/></EnumParameter>"}}; + +struct EnumParameterPF : public ParameterFramework +{ + EnumParameterPF() : ParameterFramework{std::move(validEnumParameterInstances)} {} +}; + +SCENARIO_METHOD(LazyPF, "Invalid EnumParameter types XML structure", "[EnumParameter types]") +{ + for (auto &vec : invalidEnumParameterParameters) { + GIVEN ("intentional error: " + vec.title) { + create(Config{&Config::instances, vec.payload}); + THEN ("Start should fail") { + CHECK_THROWS_AS(mPf->start(), Exception); + } + } + } +} + +SCENARIO_METHOD(EnumParameterPF, "EnumParameter types", "[EnumParameter types]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal"; + + AND_THEN ("Set/Get a EnumParameter type parameter in real value space") { + + for (auto &vec : Tests<string>{ + {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "on"}, {"(lower limit)", "off"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get a EnumParameter type parameter in raw value space") { + ElementHandle handle{*this, path}; + REQUIRE_NOTHROW(setRawValueSpace(true)); + + for (auto &vec : Tests<string>{{"(too high)", "7"}, {"(too low)", "-1"}}) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "3"}, {"(lower limit)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + + REQUIRE_NOTHROW(setHexOutputFormat(true)); + + for (auto &vec : Tests<string>{{"(too high)", "0x7"}, {"(too low)", "0xFF"}}) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "0x03"}, {"(lower limit)", "0x00"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get a EnumParameter type parameter in Integer value space") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<int32_t>{ + {"(upper limit)", 3}, {"(lower limit)", 0}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(handle.setAsSignedInteger(vec.payload)); + int32_t getValueBack; + REQUIRE_NOTHROW(handle.getAsSignedInteger(getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + for (auto &vec : Tests<int32_t>{ + {"(too high)", 13}, {"(too low)", -51}, + }) { + GIVEN ("An invalid value " + vec.title) { + CHECK_THROWS_AS(handle.setAsSignedInteger(vec.payload), Exception); + } + } + } + } + } +} +} diff --git a/upstream/test/functional-tests/FixedPoint.cpp b/upstream/test/functional-tests/FixedPoint.cpp new file mode 100644 index 0000000..ecc69b5 --- /dev/null +++ b/upstream/test/functional-tests/FixedPoint.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2017, 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 "ElementHandle.hpp" +#include "Test.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validFixedPointInstances = + Config{&Config::instances, + // Default for integers is unsigned/32bits + R"(<FixedPointParameter Name="nominal" Size="16" Integral="2" Fractional="7"/>)"}; +const auto &invalidFixedPointParameters = + Tests<string>{{"U8 Dec + Fractional > 7", + "<FixedPointParameter Name='q2.6' Size='8' Integral='2' Fractional='6'/>"}, + {"U16 Dec + Fractional > 15", + "<FixedPointParameter Name='q9.7' Size='16' Integral='9' Fractional='7'/>"}, + {"U32 Fractional > 31", + "<FixedPointParameter Name='q0.32' Size='32' Integral='0' Fractional='32'/>"}}; + +struct FixedPointPF : public ParameterFramework +{ + FixedPointPF() : ParameterFramework{std::move(validFixedPointInstances)} {} +}; + +SCENARIO_METHOD(LazyPF, "Invalid FixedPoint types XML structure", "[FixedPoint types]") +{ + for (auto &vec : invalidFixedPointParameters) { + GIVEN ("intentional error: " + vec.title) { + create(Config{&Config::instances, vec.payload}); + THEN ("Start should fail") { + CHECK_THROWS_AS(mPf->start(), Exception); + } + } + } +} + +SCENARIO_METHOD(FixedPointPF, "FixedPoint types", "[FixedPoint types]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal"; + + AND_THEN ("Set/Get a Fixed Point type parameter in real value space") { + for (auto &vec : Tests<string>{ + {"(too high)", "4.0000000"}, + {"(too low)", "-4.0078125"}, + {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "3.9921875"}, + {"(lower limit)", "-4.0000000"}, + {"(inside range)", "0.0000000"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + AND_THEN ("Set/Get a Fixed Point parameter in raw value space") { + REQUIRE_NOTHROW(setRawValueSpace(true)); + + for (auto &vec : Tests<string>{ + {"(upper limit) as decimal", "32767"}, + {"(lower limit) as decimal", "-32768"}, + {"(inside range) as decimal", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + for (auto &vec : Tests<string>{ + {"(too high)", "32768"}, {"(too low)", "-32769"}, + }) { + GIVEN ("Invalid value interger" + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(too high)", "0x10000"}, {"(too low)", "0xfffe0000"}, + }) { + GIVEN ("Invalid value hexa" + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + } + } + } +} +} diff --git a/upstream/test/functional-tests/Integer.cpp b/upstream/test/functional-tests/Integer.cpp index db39f84..1a44ca3 100644 --- a/upstream/test/functional-tests/Integer.cpp +++ b/upstream/test/functional-tests/Integer.cpp @@ -130,6 +130,31 @@ SCENARIO_METHOD(IntegerPF, "Integer types", "[Integer types]") } } + AND_THEN ("Set/Get a integer type parameter in raw value space") { + REQUIRE_NOTHROW(setRawValueSpace(true)); + REQUIRE_NOTHROW(setHexOutputFormat(true)); + + for (auto &vec : Tests<string>{ + {"(too high)", "0x0D"}, {"(too low)", "0xCD"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "0x0C"}, + {"(lower limit)", "0xCE"}, + {"(inside range)", "0x00"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + AND_THEN ("Set/Get integer type parameter handle") { ElementHandle handle{*this, path}; /** @FIXME: 'set' operations on a ParameterHandle are silently @@ -154,6 +179,30 @@ SCENARIO_METHOD(IntegerPF, "Integer types", "[Integer types]") } } } + + AND_THEN ("Set/Get double type parameter handle") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + + for (auto &vec : Tests<double>{ + {"(upper limit)", 12.0f}, + {"(lower limit)", -50.0f}, + {"(inside range)", 0.0f}, + }) { + GIVEN ("A valid value (rejected not supported)" + vec.title) { + CHECK_THROWS_AS(handle.setAsDouble(vec.payload), Exception); + } + } + for (auto &vec : Tests<double>{ + {"(too high)", 12.01f}, {"(too low)", -50.01f}, + }) { + GIVEN ("An invalid value " + vec.title) { + CHECK_THROWS_AS(handle.setAsDouble(vec.payload), Exception); + } + } + } } } } diff --git a/upstream/test/functional-tests/Linear.cpp b/upstream/test/functional-tests/Linear.cpp new file mode 100644 index 0000000..363567c --- /dev/null +++ b/upstream/test/functional-tests/Linear.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, 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 "ElementHandle.hpp" +#include "Test.hpp" +#include "BinaryCopy.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validLinearInstances = Config{ + &Config::instances, + // Size is fixed at 32 and as such is optional */ + R"(<IntegerParameter Name="trivial" Signed="true"> <LinearAdaptation SlopeNumerator="200" SlopeDenominator="10"/> </IntegerParameter> + <IntegerParameter Name="nominal" Size="32" Signed="true" Min="-1440" Max="300"> <LinearAdaptation SlopeNumerator="10" SlopeDenominator="100"/> </IntegerParameter>)"}; +const auto &invalidLinearParameters = Tests<string>{ + {"invalid Size(64)", "<IntegerParameter Name='nominal' Size='64' Signed='true' Min='-144' " + "Max='30'> <LinearAdaptation SlopeNumerator='200' SlopeDenominator='10'/> " + "</IntegerParameter>"}, + {"minimum > maximum", "<IntegerParameter Name='nominal' Size='32' Signed='true' Min='30' " + "Max='-144'> <LinearAdaptation SlopeNumerator='1' " + "SlopeDenominator='10'/> </IntegerParameter>"}, + {"SlopeDenominator=0", + "<IntegerParameter Name='nominal' Size='32' Signed='true' Min='-144' Max='30'> " + "<LinearAdaptation SlopeNumerator='1' SlopeDenominator='0'/> " + "</IntegerParameter>"}}; + +struct LinearsPF : public ParameterFramework +{ + LinearsPF() : ParameterFramework{std::move(validLinearInstances)} {} +}; + +SCENARIO_METHOD(LazyPF, "Invalid Linear points XML structure", "[Linear Type]") +{ + for (auto &vec : invalidLinearParameters) { + GIVEN ("intentional error: " + vec.title) { + create(Config{&Config::instances, vec.payload}); + THEN ("Start should fail") { + CHECK_THROWS_AS(mPf->start(), Exception); + } + } + } +} + +SCENARIO_METHOD(LinearsPF, "Linear points", "[Linear Type]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal"; + AND_THEN ("Set/Get a Loagaritmic point parameter in real value space") { + + for (auto &vec : Tests<string>{ + {"(too high)", "301"}, + {"(too low)", "-1441"}, + {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "300"}, + {"(lower limit)", "-1440"}, + {"(inside range)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack = "-11"; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + + AND_THEN ("Set/Get double type parameter handle") { + ElementHandle handle{*this, path}; + /** @FIXME: 'set' operations on a ParameterHandle are silently + * ignored in tuning mode. Does it make sense ? */ + REQUIRE_NOTHROW(setTuningMode(false)); + REQUIRE_NOTHROW(setRawValueSpace(true)); + + /* nominal is defined as a Num=10,Denum=100 (division by 10). So limits should be 10 + * above Mina dn Max Integer value in order to get exception. */ + for (auto &vec : Tests<double>{ + {"(upper limit)", 3000.0f}, + {"(lower limit)", -14400.0f}, + {"(inside range)", 0.0f}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(handle.setAsDouble(vec.payload)); + double getValueBack = 1.0f; + REQUIRE_NOTHROW(handle.getAsDouble(getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + for (auto &vec : Tests<double>{ + {"(too high)", 3010.0f}, {"(too low)", -14410.00f}, + }) { + GIVEN ("An invalid value " + vec.title) { + CHECK_THROWS_AS(handle.setAsDouble(vec.payload), Exception); + } + } + } + } + } +} +} // namespace parameterFramework diff --git a/upstream/test/functional-tests/Logarithmic.cpp b/upstream/test/functional-tests/Logarithmic.cpp new file mode 100644 index 0000000..137338e --- /dev/null +++ b/upstream/test/functional-tests/Logarithmic.cpp @@ -0,0 +1,114 @@ +/* + * 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 "ElementHandle.hpp" +#include "Test.hpp" +#include "BinaryCopy.hpp" + +#include <catch.hpp> + +#include <string> + +using std::string; + +namespace parameterFramework +{ + +const auto validLogarithmicInstances = Config{ + &Config::instances, + // Size is fixed at 32 and as such is optional */ + R"(<IntegerParameter Name="trivial" Signed="true"> <LogarithmicAdaptation SlopeNumerator="200" LogarithmBase="10"/> </IntegerParameter> + <IntegerParameter Name="nominal" Size="32" Signed="true" Min="-144" Max="30"> <LogarithmicAdaptation SlopeNumerator="1" LogarithmBase="10"/> </IntegerParameter>)"}; +const auto &invalidLogarithmicParameters = Tests<string>{ + {"invalid Size(64)", "<IntegerParameter Name='nominal' Size='64' Signed='true' Min='-144' " + "Max='30'> <LogarithmicAdaptation SlopeNumerator='1' LogarithmBase='10'/> " + "</IntegerParameter>"}, + {"minimum > maximum", "<IntegerParameter Name='nominal' Size='32' Signed='true' Min='30' " + "Max='-144'> <LogarithmicAdaptation SlopeNumerator='1' " + "LogarithmBase='10'/> </IntegerParameter>"}, + {"logBase =1", "<IntegerParameter Name='nominal' Size='32' Signed='true' Min='-144' Max='30'> " + "<LogarithmicAdaptation SlopeNumerator='1' LogarithmBase='1'/> " + "</IntegerParameter>"}, + {"logBase negative", "<IntegerParameter Name='nominal' Size='32' Signed='true' Min='-144' " + "Max='30'> <LogarithmicAdaptation SlopeNumerator='1' " + "LogarithmBase='-10'/> </IntegerParameter>"}}; + +struct LogarithmicsPF : public ParameterFramework +{ + LogarithmicsPF() : ParameterFramework{std::move(validLogarithmicInstances)} {} +}; + +SCENARIO_METHOD(LazyPF, "Invalid Logarithmic points XML structure", "[Logarithmic Type]") +{ + for (auto &vec : invalidLogarithmicParameters) { + GIVEN ("intentional error: " + vec.title) { + create(Config{&Config::instances, vec.payload}); + THEN ("Start should fail") { + CHECK_THROWS_AS(mPf->start(), Exception); + } + } + } +} + +SCENARIO_METHOD(LogarithmicsPF, "Logarithmic points", "[Logarithmic Type]") +{ + GIVEN ("A valid XML structure file") { + THEN ("Start should succeed") { + CHECK_NOTHROW(start()); + REQUIRE_NOTHROW(setTuningMode(true)); + string path = "/test/test/nominal"; + AND_THEN ("Set/Get a Loagaritmic point parameter in real value space") { + + for (auto &vec : Tests<string>{ + {"(too high)", "31"}, {"(too low)", "-145"}, {"(not a number)", "foobar"}, + }) { + GIVEN ("Invalid value " + vec.title) { + CHECK_THROWS_AS(setParameter(path, vec.payload), Exception); + } + } + for (auto &vec : Tests<string>{ + {"(upper limit)", "30"}, + {"(lower limit)", "-144"}, + {"(inside range)", "0"}, + }) { + GIVEN ("A valid value " + vec.title) { + CHECK_NOTHROW(setParameter(path, vec.payload)); + string getValueBack; + REQUIRE_NOTHROW(getParameter(path, getValueBack)); + CHECK(getValueBack == vec.payload); + } + } + } + } + } +} +} // namespace parameterFramework diff --git a/upstream/test/functional-tests/include/ElementHandle.hpp b/upstream/test/functional-tests/include/ElementHandle.hpp index a2f5475..335ac67 100644 --- a/upstream/test/functional-tests/include/ElementHandle.hpp +++ b/upstream/test/functional-tests/include/ElementHandle.hpp @@ -76,6 +76,9 @@ public: /** Wrap EH::getAsDouble to throw an exception on failure. */ void getAsDouble(double &value) const { mayFailCall(&EH::getAsDouble, value); } + void setAsBoolean(bool value) { mayFailCall(&EH::setAsBoolean, value); } + void getAsBoolean(bool &value) const { mayFailCall(&EH::getAsBoolean, value); } + void setAsInteger(uint32_t value) { mayFailCall(&EH::setAsInteger, value); } void getAsInteger(uint32_t &value) const { mayFailCall(&EH::getAsInteger, value); } void setAsIntegerArray(const std::vector<uint32_t> &value) diff --git a/upstream/tools/clientSimulator/CMakeLists.txt b/upstream/tools/clientSimulator/CMakeLists.txt index 299bfc6..4848d27 100644 --- a/upstream/tools/clientSimulator/CMakeLists.txt +++ b/upstream/tools/clientSimulator/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2015, Intel Corporation +# Copyright (c) 2015-2017, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -26,27 +26,25 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# has been tested on 2.8.11 only - should not work on older versions -cmake_minimum_required(VERSION 2.8.11) - -project(parameter-framework-clientSimulator) - -# Force usage of Python 3.x ... -find_package(PythonInterp 3 REQUIRED) -# ... and force the libs to be at the same version as the interpreter -find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED) -include_directories(${PYTHON_INCLUDE_DIRS}) +# Force usage of Python 3.x; here, we use find_program instead of find_package +# because other parts of Parameter Framework request Python 2.x and CMake has +# troubles with the cohabitation. +find_program(PYTHON3 python3 REQUIRED) # Find the python modules install path. # plat_specific is needed because we are installing a shared-library python # module and not only a pure python module. # prefix='' makes get_python_lib return a relative path. execute_process(COMMAND - ${PYTHON_EXECUTABLE} -c + ${PYTHON3} -c "from distutils import sysconfig;\\ print(sysconfig.get_python_lib(plat_specific=True, prefix=''))" OUTPUT_VARIABLE PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) -install(DIRECTORY clientsimulator DESTINATION ${PYTHON_MODULE_PATH}) +install(DIRECTORY clientsimulator + DESTINATION ${PYTHON_MODULE_PATH} + COMPONENT client_simulator) -install(PROGRAMS pfClientSimulator.py DESTINATION bin) +install(PROGRAMS pfClientSimulator.py + DESTINATION bin + COMPONENT client_simulator) |