diff --git a/src/core/worker.c b/src/core/worker.c index 7276f27..b92002b 100644 --- a/src/core/worker.c +++ b/src/core/worker.c @@ -51,6 +51,10 @@ bool is_runner(void) { return is_current_process(g_current_proc); } +bool is_single_mode(void) { + return g_current_proc == NULL; +} + static void close_process(void *ptr, CR_UNUSED void *meta) { struct worker *proc = ptr; sfree(proc->ctx.suite_stats); diff --git a/src/core/worker.h b/src/core/worker.h index 53edb46..0470ec3 100644 --- a/src/core/worker.h +++ b/src/core/worker.h @@ -77,6 +77,7 @@ void run_worker(struct worker_context *ctx); void set_runner_process(void); void unset_runner_process(void); bool is_runner(void); +bool is_single_mode(void); struct process_status wait_proc(struct worker *proc); struct worker *spawn_test_worker(struct execution_context *ctx, cr_worker_func func); diff --git a/src/protocol/connect.c b/src/protocol/connect.c index 0a53f67..5f64e51 100644 --- a/src/protocol/connect.c +++ b/src/protocol/connect.c @@ -28,6 +28,7 @@ #include #include "compat/process.h" +#include "core/worker.h" #define URL "ipc://%scriterion_%llu.sock" @@ -61,6 +62,9 @@ error: {} } int connect_client(void) { + if (is_single_mode()) + return 0; + int sock = nn_socket(AF_SP, NN_REQ); if (sock < 0) return -1; @@ -87,5 +91,8 @@ error: {} } void close_socket(int sock) { + if (is_single_mode()) + return; + nn_close(sock); } diff --git a/src/protocol/messages.c b/src/protocol/messages.c index 788d66e..4c0c3f7 100644 --- a/src/protocol/messages.c +++ b/src/protocol/messages.c @@ -80,6 +80,9 @@ const char *message_names[] = { }; void cr_send_to_runner(const criterion_protocol_msg *message) { + if (is_single_mode()) + return; + if (write_message(g_client_socket, message) != 1) { criterion_perror("Could not write the \"%s\" message down the event pipe: %s.\n", message_names[message->data.which_value],