summaryrefslogtreecommitdiff
path: root/test/src/mbgl/test/util.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-11-15 11:15:33 +0100
committerIvo van Dongen <info@ivovandongen.nl>2016-11-15 11:15:33 +0100
commit7dd6e720ce36f4eacc0c52b7c05e4e5cb92965d6 (patch)
tree0ee0e2555b2f47096f4c74458f5988ff9a76edf8 /test/src/mbgl/test/util.cpp
parent338bc7cd88ab381446f417f8271d55989132cf09 (diff)
downloadqtlocation-mapboxgl-7dd6e720ce36f4eacc0c52b7c05e4e5cb92965d6.tar.gz
[android] start on main test libupstream/5456-android-core-tests-cmake
Diffstat (limited to 'test/src/mbgl/test/util.cpp')
-rw-r--r--test/src/mbgl/test/util.cpp73
1 files changed, 0 insertions, 73 deletions
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index a674eafeb4..1704f7961e 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -24,79 +24,6 @@
namespace mbgl {
namespace test {
-Server::Server(const char* script) {
- int input[2];
- int output[2];
-
- if (pipe(input)) {
- throw std::runtime_error("Cannot create server input pipe");
- }
- if (pipe(output)) {
- throw std::runtime_error("Cannot create server output pipe");
- }
-
- // Store the parent => child pipe so that we can close it in the destructor.
- fd = input[1];
-
- pid_t pid = fork();
- if (pid < 0) {
- Log::Error(Event::Setup, "Cannot create server process");
- exit(1);
- } else if (pid == 0) {
- // This is the child process.
-
- // Connect the parent => child pipe to stdin.
- while ((dup2(input[0], STDIN_FILENO) == -1) && (errno == EINTR)) {}
- close(input[0]);
- close(input[1]);
-
- // Move the child => parent side of the pipe to stdout.
- while ((dup2(output[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
- close(output[1]);
- close(output[0]);
-
- const char* executable = xstr(NODE_EXECUTABLE);
-
- fprintf(stderr, "executable: %s\n", executable);
-
- // Launch the actual server process.
- int ret = execl(executable, executable, script, nullptr);
-
- // This call should not return. In case execl failed, we exit anyway.
- if (ret < 0) {
- Log::Error(Event::Setup, "Failed to start server: %s", strerror(errno));
- }
- abort();
- } else {
- // This is the parent process.
-
- // Close the unneeded sides of the pipes.
- close(output[1]);
- close(input[0]);
-
- // Wait until the server process sends at least 2 bytes or closes the handle.
- char buffer[2];
- ssize_t bytes, total = 0;
- while (total < 2 && (bytes = read(output[0], buffer + total, 2 - total)) != 0) {
- total += bytes;
- }
-
- // Close child => parent pipe.
- close(output[0]);
-
- // Check signature
- if (total != 2 || strncmp(buffer, "OK", 2) != 0) {
- throw std::runtime_error("Failed to start server: Invalid signature");
- }
- }
-}
-
-Server::~Server() {
- if (fd > 0) {
- close(fd);
- }
-}
-
PremultipliedImage render(Map& map) {
PremultipliedImage result;
map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) {