From 692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 3 Jun 2016 18:05:04 +0200 Subject: [build] switch to CMake This is very much a work in progress. --- test/src/main.cpp | 15 +++++++++++++++ test/src/mbgl/test/util.cpp | 17 ++++++++++++++--- test/src/mbgl/test/util.hpp | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'test/src') diff --git a/test/src/main.cpp b/test/src/main.cpp index a481dc5dc3..d01cf75ffc 100644 --- a/test/src/main.cpp +++ b/test/src/main.cpp @@ -1,5 +1,20 @@ #include +#include +#include +#include +#include + +#define xstr(s) str(s) +#define str(s) #s int main(int argc, char *argv[]) { +#ifdef WORK_DIRECTORY + const int result = chdir(xstr(WORK_DIRECTORY)); + if (result != 0) { + fprintf(stderr, "failed to change directory: %s\n", strerror(errno)); + return errno; + } +#endif + return mbgl::runTests(argc, argv); } diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp index 4021fd89b1..393d65b667 100644 --- a/test/src/mbgl/test/util.cpp +++ b/test/src/mbgl/test/util.cpp @@ -14,10 +14,17 @@ #include +#ifndef NODE_EXECUTABLE +#define NODE_EXECUTABLE node +#endif + +#define xstr(s) str(s) +#define str(s) #s + namespace mbgl { namespace test { -Server::Server(const char* executable) { +Server::Server(const char* script) { int input[2]; int output[2]; @@ -48,14 +55,18 @@ Server::Server(const char* executable) { 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, nullptr); + 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)); } - exit(0); + abort(); } else { // This is the parent process. diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp index 30108a8866..66499c6fd6 100644 --- a/test/src/mbgl/test/util.hpp +++ b/test/src/mbgl/test/util.hpp @@ -59,7 +59,7 @@ namespace test { class Server { public: - Server(const char* executable); + Server(const char* script); ~Server(); private: -- cgit v1.2.1