summaryrefslogtreecommitdiffstats
path: root/test/test-platform
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2015-07-15 15:37:57 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2015-07-15 17:09:51 -0700
commita9be2d378b7ad84e679a48efa81f42fb54f85d9a (patch)
tree587d34728dac3517a213d6d2a9a6ebdecd4e7531 /test/test-platform
parentc99720d29f2ee618cc74c9336d2cd2a26544c020 (diff)
downloadexternal_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.zip
external_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.tar.gz
external_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.tar.bz2
Drop release v2.6.0+no-stlport
Bug 246391 Change-Id: I662b7b0f90c97cb169978e1b64ad1fe32c440cf5 Signed-off-by: Jean-Michel Trivi <jmtrivi@google.com>
Diffstat (limited to 'test/test-platform')
-rw-r--r--test/test-platform/Android.mk6
-rw-r--r--test/test-platform/TestPlatform.cpp8
-rw-r--r--test/test-platform/TestPlatform.h3
-rw-r--r--test/test-platform/main.cpp34
4 files changed, 25 insertions, 26 deletions
diff --git a/test/test-platform/Android.mk b/test/test-platform/Android.mk
index e46ad57..04b1b90 100644
--- a/test/test-platform/Android.mk
+++ b/test/test-platform/Android.mk
@@ -43,8 +43,6 @@ common_c_includes := \
$(LOCAL_PATH)/../../parameter/include \
$(LOCAL_PATH)/../../remote-processor/
-common_ldlibs := -pthread
-
common_shared_libraries := libparameter libremote-processor
#############################
# Target build
@@ -58,7 +56,6 @@ LOCAL_MODULE_OWNER := intel
LOCAL_MODULE_TAGS := $(common_module_tags)
LOCAL_C_INCLUDES := $(common_c_includes)
-LOCAL_LDLIBS := $(common_ldlibs)
LOCAL_STATIC_LIBRARIES := libpfw_utility
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
@@ -77,7 +74,8 @@ LOCAL_MODULE_OWNER := intel
LOCAL_MODULE_TAGS := $(common_module_tags)
LOCAL_C_INCLUDES += $(common_c_includes)
-LOCAL_LDLIBS := $(common_ldlibs)
+LOCAL_CFLAGS := -pthread
+LOCAL_LDLIBS := -lpthread
LOCAL_STATIC_LIBRARIES := libpfw_utility_host
LOCAL_SHARED_LIBRARIES := $(foreach shared_library, $(common_shared_libraries), \
diff --git a/test/test-platform/TestPlatform.cpp b/test/test-platform/TestPlatform.cpp
index 9cb45f7..6e67b3a 100644
--- a/test/test-platform/TestPlatform.cpp
+++ b/test/test-platform/TestPlatform.cpp
@@ -63,7 +63,6 @@ public:
CTestPlatform::CTestPlatform(const string& strClass, int iPortNumber, sem_t& exitSemaphore) :
_pParameterMgrPlatformConnector(new CParameterMgrPlatformConnector(strClass)),
_pParameterMgrPlatformConnectorLogger(new CParameterMgrPlatformConnectorLogger),
- _portNumber(iPortNumber),
_exitSemaphore(exitSemaphore)
{
_pCommandHandler = new CCommandHandler(this);
@@ -163,12 +162,9 @@ CTestPlatform::CommandReturn CTestPlatform::exit(
bool CTestPlatform::load(std::string& strError)
{
// Start remote processor server
- if (!_pRemoteProcessorServer->start()) {
-
- std::ostringstream oss;
- oss << "TestPlatform: Unable to start remote processor server on port " << _portNumber;
- strError = oss.str();
+ if (!_pRemoteProcessorServer->start(strError)) {
+ strError = "TestPlatform: Unable to start remote processor server: " + strError;
return false;
}
diff --git a/test/test-platform/TestPlatform.h b/test/test-platform/TestPlatform.h
index e9d1dd4..fae8386 100644
--- a/test/test-platform/TestPlatform.h
+++ b/test/test-platform/TestPlatform.h
@@ -153,9 +153,6 @@ private:
// Remote Processor Server
CRemoteProcessorServer* _pRemoteProcessorServer;
- // Port number for the server socket
- int _portNumber;
-
// Semaphore used by calling thread to avoid exiting
sem_t& _exitSemaphore;
};
diff --git a/test/test-platform/main.cpp b/test/test-platform/main.cpp
index a3f50be..6a79597 100644
--- a/test/test-platform/main.cpp
+++ b/test/test-platform/main.cpp
@@ -29,12 +29,15 @@
*/
#include "TestPlatform.h"
+#include "FullIo.hpp"
#include <iostream>
#include <cstdlib>
#include <semaphore.h>
#include <string.h>
#include <unistd.h>
+#include <cerrno>
+#include <cassert>
using namespace std;
@@ -68,6 +71,16 @@ static bool startBlockingTestPlatform(const char *filePath, int portNumber, stri
return true;
}
+static void notifyParent(int parentFd, bool success)
+{
+ if (not utility::fullWrite(parentFd, &success, sizeof(success))) {
+ cerr << "Unable to warn parent process of load "
+ << (success ? "success" : "failure") << ": "
+ << strerror(errno) << endl;
+ assert(false);
+ }
+}
+
// Starts test-platform in daemon mode
static bool startDaemonTestPlatform(const char *filePath, int portNumber, string &strError)
{
@@ -106,31 +119,26 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string
CTestPlatform testPlatform(filePath, portNumber, sem);
// Message to send to parent process
- bool msgToParent;
+ bool loadSuccess = testPlatform.load(strError);
- // Start platformmgr
- if (!testPlatform.load(strError)) {
+ if (!loadSuccess) {
cerr << strError << endl;
// Notify parent of failure;
- msgToParent = false;
- write(pipefd[1], &msgToParent, sizeof(msgToParent));
+ notifyParent(pipefd[1], false);
- sem_destroy(&sem);
} else {
// Notify parent of success
- msgToParent = true;
- write(pipefd[1], &msgToParent, sizeof(msgToParent));
+ notifyParent(pipefd[1], true);
// Block here
sem_wait(&sem);
-
- sem_destroy(&sem);
}
+ sem_destroy(&sem);
- return msgToParent;
+ return loadSuccess;
} else {
@@ -143,9 +151,9 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string
// Message received from the child process
bool msgFromChild = false;
- if (read(pipefd[0], &msgFromChild, sizeof(msgFromChild)) <= 0) {
-
+ if (not utility::fullRead(pipefd[0], &msgFromChild, sizeof(msgFromChild))) {
strError = "Read pipe failed";
+ return false;
}
// return success/failure in exit status