aboutsummaryrefslogtreecommitdiffstats
path: root/test/test-platform/main.cpp
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/main.cpp
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/main.cpp')
-rw-r--r--test/test-platform/main.cpp34
1 files changed, 21 insertions, 13 deletions
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