summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Gaffie <francois.gaffie@renault.com>2018-12-04 13:58:18 +0100
committerEric Laurent <elaurent@google.com>2019-04-26 10:59:32 -0700
commitbc5c94366c071965c025fac450162d7ff6a29563 (patch)
tree0596c0ffd5fbbf4724af1002b32684fbe6f8a770
parent2191360f6c25eb140e6cb1085a24f9ff9a18d9c3 (diff)
downloadparameter-framework-bc5c94366c071965c025fac450162d7ff6a29563.tar.gz
Functional test: improve test to run on target
-Prevent the test linking with the plugin to allow using any plugin location -use customizable plugin path and name. Bug: 130284799 Test: make Change-Id: Ie694e8d6664220da06027e8b717e7db21ded0d3e Signed-off-by: François Gaffie <francois.gaffie@renault.com>
-rw-r--r--upstream/test/functional-tests/AutoSync.cpp32
-rw-r--r--upstream/test/functional-tests/CMakeLists.txt2
-rw-r--r--upstream/test/introspection-subsystem/include/IntrospectionEntryPoint.h9
-rw-r--r--upstream/test/tmpfile/CMakeLists.txt5
-rw-r--r--upstream/test/tmpfile/posix/TmpFile.cpp2
5 files changed, 42 insertions, 8 deletions
diff --git a/upstream/test/functional-tests/AutoSync.cpp b/upstream/test/functional-tests/AutoSync.cpp
index d23c0f7..c075700 100644
--- a/upstream/test/functional-tests/AutoSync.cpp
+++ b/upstream/test/functional-tests/AutoSync.cpp
@@ -30,11 +30,14 @@
#include "Config.hpp"
#include "ParameterFramework.hpp"
+#include "DynamicLibrary.hpp"
#include <SubsystemObject.h>
#include <IntrospectionEntryPoint.h>
#include "Test.hpp"
#include <catch.hpp>
#include <string>
+#include <iostream>
+#include "Memory.hpp"
using std::string;
@@ -43,7 +46,13 @@ namespace parameterFramework
struct BoolPF : public ParameterFramework
{
- BoolPF() : ParameterFramework{createConfig()} {}
+ BoolPF() : ParameterFramework{createConfig()} {
+
+ mDynamicLibrary = ::utility::make_unique<DynamicLibrary>(mSubsystemPath);
+ REQUIRE(mDynamicLibrary != nullptr);
+ mGetParamFunc = mDynamicLibrary->getSymbol<GetParamFunc>("getParameterValue");
+ REQUIRE(mGetParamFunc != nullptr);
+ }
/** Set the boolean parameter value within the "Conf" configuration,
* which is always applicable. */
@@ -53,14 +62,18 @@ struct BoolPF : public ParameterFramework
setConfigurationParameter("Domain", "Conf", "/test/test/param", valueStr);
}
+ bool getParameterValue()
+ {
+ return mGetParamFunc();
+ }
+
private:
static Config createConfig()
{
Config config;
config.instances = R"(<BooleanParameter Name="param" Mapping="Object"/>)";
- config.plugins = {{"", {"introspection-subsystem"}}};
+ config.plugins = {{PLUGIN_PATH, {PLUGIN_NAME}}};
config.subsystemType = "INTROSPECTION";
-
config.domains = R"(<ConfigurableDomain Name="Domain">
<Configurations>
<Configuration Name="Conf">
@@ -83,6 +96,11 @@ private:
return config;
}
+
+ using GetParamFunc = bool (*)();
+ std::string mSubsystemPath = std::string(PLUGIN_PATH) + (*PLUGIN_PATH ? "/":"") + PLUGIN_NAME;
+ std::unique_ptr<DynamicLibrary> mDynamicLibrary;
+ bool (*mGetParamFunc)();
};
SCENARIO_METHOD(BoolPF, "Auto sync")
@@ -91,7 +109,7 @@ SCENARIO_METHOD(BoolPF, "Auto sync")
REQUIRE_NOTHROW(start());
THEN ("Parameter value is false according to the settings") {
- REQUIRE_FALSE(introspectionSubsystem::getParameterValue());
+ REQUIRE_FALSE(getParameterValue());
AND_THEN ("Tuning is off") {
REQUIRE_FALSE(isTuningModeOn());
@@ -103,7 +121,7 @@ SCENARIO_METHOD(BoolPF, "Auto sync")
REQUIRE_NOTHROW(setParameterValue(true));
THEN ("Sync is done") {
- CHECK(introspectionSubsystem::getParameterValue());
+ CHECK(getParameterValue());
}
}
}
@@ -114,13 +132,13 @@ SCENARIO_METHOD(BoolPF, "Auto sync")
REQUIRE_NOTHROW(setParameterValue(true));
THEN ("Sync should not have occurred yet") {
- REQUIRE_FALSE(introspectionSubsystem::getParameterValue());
+ REQUIRE_FALSE(getParameterValue());
WHEN ("Turning autosync on") {
REQUIRE_NOTHROW(setAutoSync(true));
THEN ("Sync is done") {
- CHECK(introspectionSubsystem::getParameterValue());
+ CHECK(getParameterValue());
}
}
}
diff --git a/upstream/test/functional-tests/CMakeLists.txt b/upstream/test/functional-tests/CMakeLists.txt
index c3d02d0..b938231 100644
--- a/upstream/test/functional-tests/CMakeLists.txt
+++ b/upstream/test/functional-tests/CMakeLists.txt
@@ -48,6 +48,8 @@ if(BUILD_TESTING)
find_package(LibXml2 REQUIRED)
+ target_compile_definitions(parameterFunctionalTest PUBLIC -D PLUGIN_NAME=\"introspection-subsystem\" PLUGIN_PATH=\"\")
+
target_link_libraries(parameterFunctionalTest
PRIVATE parameter
PRIVATE pfw_utility catch tmpfile LibXml2::libxml2 introspection-subsystem)
diff --git a/upstream/test/introspection-subsystem/include/IntrospectionEntryPoint.h b/upstream/test/introspection-subsystem/include/IntrospectionEntryPoint.h
index b7feea9..84dc71b 100644
--- a/upstream/test/introspection-subsystem/include/IntrospectionEntryPoint.h
+++ b/upstream/test/introspection-subsystem/include/IntrospectionEntryPoint.h
@@ -36,6 +36,15 @@ namespace parameterFramework
namespace introspectionSubsystem
{
+#ifdef __cplusplus
+extern "C" {
+#endif
+
INTROSPECTION_SUBSYSTEM_EXPORT bool getParameterValue();
+
+#ifdef __cplusplus
+}
+#endif
+
} // namespace introspectionSubsystem
} // namespace parameterFramework
diff --git a/upstream/test/tmpfile/CMakeLists.txt b/upstream/test/tmpfile/CMakeLists.txt
index 0dba1a1..1975f3a 100644
--- a/upstream/test/tmpfile/CMakeLists.txt
+++ b/upstream/test/tmpfile/CMakeLists.txt
@@ -34,4 +34,9 @@ if(BUILD_TESTING)
endif ()
add_library(tmpfile STATIC ${OS_SPECIFIC_TMPFILE})
+
+ if (NOT WIN32)
+ target_compile_definitions(tmpfile PUBLIC -D RW_PATH=\"\")
+ endif ()
+
endif()
diff --git a/upstream/test/tmpfile/posix/TmpFile.cpp b/upstream/test/tmpfile/posix/TmpFile.cpp
index 5968cde..59fe441 100644
--- a/upstream/test/tmpfile/posix/TmpFile.cpp
+++ b/upstream/test/tmpfile/posix/TmpFile.cpp
@@ -42,7 +42,7 @@ std::string TmpFile::mktmp()
{
using std::string;
- char path[] = "Tmp_ParameterFramework_XXXXXX";
+ char path[] = RW_PATH "Tmp_ParameterFramework_XXXXXX";
int fd = mkstemp(path);
if (fd == -1) {
throwErrnoError("Could not create tmp file with pattern \"" + string(path) + '"');