diff --git a/src/client.cpp b/src/client.cpp index 1ea9b8b..2ee46c6 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -195,7 +195,7 @@ int main(int argc, char** argv) { return EXIT_BAD_ARGUMENT; } if(char* pipeNum = getenv("__LAMINAR_SETENV_PIPE")) { - write(atoi(pipeNum), argv[2], strlen(argv[2])); + LSYSCALL(write(atoi(pipeNum), argv[2], strlen(argv[2]))); } else { fprintf(stderr, "Must be run from within a laminar job\n"); return EXIT_BAD_ARGUMENT; diff --git a/src/laminar.cpp b/src/laminar.cpp index 2ac59de..5b941bb 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -780,7 +780,7 @@ bool Laminar::handleBadgeRequest(std::string job, std::string &badge) { const char* gradient1 = (rs == RunState::SUCCESS) ? "#2aff4d" : "#ff2a2a"; const char* gradient2 = (rs == RunState::SUCCESS) ? "#24b43c" : "#b42424"; char* svg = NULL; - asprintf(&svg, + if(asprintf(&svg, R"x( @@ -800,7 +800,9 @@ R"x( %s -)x", jobNameWidth+statusWidth, jobNameWidth+statusWidth, gradient1, gradient2, jobNameWidth, jobNameWidth/2+1, job.data(), jobNameWidth, statusWidth, jobNameWidth+statusWidth/2, status.data()); +)x", jobNameWidth+statusWidth, jobNameWidth+statusWidth, gradient1, gradient2, jobNameWidth, jobNameWidth/2+1, job.data(), jobNameWidth, statusWidth, jobNameWidth+statusWidth/2, status.data()) < 0) + return false; + badge = svg; return true; } diff --git a/src/leader.cpp b/src/leader.cpp index 4285583..5958d78 100644 --- a/src/leader.cpp +++ b/src/leader.cpp @@ -1,5 +1,5 @@ /// -/// Copyright 2019 Oliver Giles +/// Copyright 2019-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -89,7 +89,7 @@ Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jo }); })); - pipe(setEnvPipe); + LSYSCALL(pipe(setEnvPipe)); auto event = ioContext.lowLevelProvider->wrapInputFd(setEnvPipe[0], kj::LowLevelAsyncIoProvider::TAKE_OWNERSHIP); auto buffer = kj::heapArrayBuilder(1024); tasks.add(readEnvPipe(event, buffer.asPtr().begin()).attach(kj::mv(event), kj::mv(buffer))); diff --git a/src/run.cpp b/src/run.cpp index db0ef4e..b7be79d 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -1,5 +1,5 @@ /// -/// Copyright 2015-2018 Oliver Giles +/// Copyright 2015-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -152,8 +152,8 @@ kj::Promise Run::start(uint buildNum, std::shared_ptr ctx, co // enough. Instead, we'll just exec ourselves and handle that in laminard's // main() by calling leader_main() char* procName; - asprintf(&procName, "{laminar} %s:%d", name.data(), buildNum); - execl("/proc/self/exe", procName, NULL); // does not return + if(asprintf(&procName, "{laminar} %s:%d", name.data(), buildNum) > 0) + execl("/proc/self/exe", procName, NULL); // does not return _exit(EXIT_FAILURE); } diff --git a/test/laminar-fixture.h b/test/laminar-fixture.h index bfb635a..30d7c57 100644 --- a/test/laminar-fixture.h +++ b/test/laminar-fixture.h @@ -1,5 +1,5 @@ /// -/// Copyright 2019 Oliver Giles +/// Copyright 2019-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -19,15 +19,17 @@ #ifndef LAMINAR_FIXTURE_H_ #define LAMINAR_FIXTURE_H_ -#include -#include #include "laminar.capnp.h" #include "eventsource.h" #include "tempdir.h" #include "laminar.h" +#include "log.h" #include "server.h" #include "conf.h" +#include +#include + class LaminarFixture : public ::testing::Test { public: LaminarFixture() { @@ -108,7 +110,7 @@ public: StringMap parseFromString(kj::StringPtr content) { char tmp[16] = "/tmp/lt.XXXXXX"; int fd = mkstemp(tmp); - write(fd, content.begin(), content.size()); + LSYSCALL(write(fd, content.begin(), content.size())); close(fd); StringMap map = parseConfFile(tmp); unlink(tmp); diff --git a/test/tempdir.h b/test/tempdir.h index 847c633..8602987 100644 --- a/test/tempdir.h +++ b/test/tempdir.h @@ -1,5 +1,5 @@ /// -/// Copyright 2018 Oliver Giles +/// Copyright 2018-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -19,6 +19,8 @@ #ifndef LAMINAR_TEMPDIR_H_ #define LAMINAR_TEMPDIR_H_ +#include "log.h" + #include #include @@ -37,7 +39,7 @@ public: private: static kj::Path mkdtemp() { char dir[] = "/tmp/laminar-test-XXXXXX"; - ::mkdtemp(dir); + LASSERT(::mkdtemp(dir) != nullptr, "mkdtemp failed"); return kj::Path::parse(&dir[1]); } }; diff --git a/test/unit-conf.cpp b/test/unit-conf.cpp index bfde12c..e329a10 100644 --- a/test/unit-conf.cpp +++ b/test/unit-conf.cpp @@ -1,5 +1,5 @@ /// -/// Copyright 2018 Oliver Giles +/// Copyright 2018-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -16,8 +16,9 @@ /// You should have received a copy of the GNU General Public License /// along with Laminar. If not, see /// -#include #include "conf.h" +#include "log.h" +#include class ConfTest : public ::testing::Test { protected: @@ -30,7 +31,7 @@ protected: } void parseConf(std::string conf) { lseek(fd, SEEK_SET, 0); - write(fd, conf.data(), conf.size()); + LSYSCALL(write(fd, conf.data(), conf.size())); cfg = parseConfFile(tmpFile); } StringMap cfg;