debug: Added support for --debug=idle. Fixes #154.

This commit is contained in:
Snaipe 2016-09-16 17:15:47 +02:00
parent 0507dfcf50
commit 66556c8cdb
9 changed files with 56 additions and 24 deletions

@ -1 +1 @@
Subproject commit 16b0041c7eb80b2308978e0654c4bb0a2bd36173
Subproject commit 978fa9095d1675186d5935b2639d0bbaf8e9ec47

View File

@ -38,6 +38,13 @@ enum criterion_debugger {
*/
CR_DBG_NONE,
/**
* Run the test suspended, without a debugger, and print its PID.
*
* Allows external debuggers to attach.
*/
CR_DBG_IDLE,
/**
* Run the test with a debugging server compatible with the compiler
* it was built with.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Criterion \n"
"Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n"
"POT-Creation-Date: 2016-09-05 22:45+0200\n"
"POT-Creation-Date: 2016-09-16 11:24+0200\n"
"PO-Revision-Date: 2016-02-12 11:12+0100\n"
"Last-Translator: <a1lu@arcor.de>\n"
"Language-Team: German\n"
@ -192,13 +192,13 @@ msgstr ""
"die Anzahl an Aufträgen wurde explizit festgelegt. Die Berichte können "
"verwirrend sein!%2$s\n"
#: src/io/output.c:13
#: src/io/output.c:36
#, c-format
msgid "Could not open the file @ `%1$s` for %2$s reporting: %3$s.\n"
msgstr ""
"Konnte die Datei `%1$s` nicht für die Berichte von %2$s öffnen: %3$s.\n"
#: src/io/output.c:14
#: src/io/output.c:37
#, c-format
msgid "Writing %1$s report in `%2$s`.\n"
msgstr "Schreibe Bericht von %1$s nach `%2$s`.\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: criterion 2.0.0\n"
"Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n"
"POT-Creation-Date: 2016-09-05 22:45+0200\n"
"POT-Creation-Date: 2016-09-16 11:24+0200\n"
"PO-Revision-Date: 2015-04-03 17:58+0200\n"
"Last-Translator: <franklinmathieu@gmail.com>\n"
"Language-Team: French\n"
@ -194,13 +194,13 @@ msgstr ""
"nombre de tâches est explicitement défini. Les rapports d'erreur risquent "
"d'être déroutants!%2$s\n"
#: src/io/output.c:13
#: src/io/output.c:36
#, fuzzy, c-format
msgid "Could not open the file @ `%1$s` for %2$s reporting: %3$s.\n"
msgstr ""
"Impossible d'ouvrir le fichier `%1$s` pour faire le rapport %2$s: %3$s.\n"
#: src/io/output.c:14
#: src/io/output.c:37
#, c-format
msgid "Writing %1$s report in `%2$s`.\n"
msgstr "Écriture du rapport %1$s dans `%2$s`.\n"

View File

@ -364,6 +364,7 @@ CR_API int criterion_run_all_tests(struct criterion_test_set *set)
if (criterion_options.debug) {
criterion_options.jobs = 1;
criterion_options.crash = true;
criterion_options.logging_threshold = 1;
}
int res = criterion_run_all_tests_impl(set);

View File

@ -36,6 +36,7 @@
#include "protocol/protocol.h"
#include "protocol/connect.h"
#include "protocol/messages.h"
#include "string/i18n.h"
#include "client.h"
#include "err.h"
#include "report.h"
@ -50,6 +51,14 @@
# define RUNNING_ON_VALGRIND 0
#endif
typedef const char *const msg_t;
#ifdef ENABLE_NLS
static msg_t msg_print_pid = N_("%1$s::%2$s: Started test has PID %3$lu.\n");
#else
static msg_t msg_print_pid = "%s::%s: Started test has PID %lu.\n";
#endif
/* *INDENT-OFF* - This is a structure definition in disguise */
ccrBeginDefineContextType(run_next_context);
@ -290,7 +299,9 @@ static bxf_instance *run_test(struct run_next_context *ctx,
.inherit.context = inst_ctx,
};
if (criterion_options.debug) {
if (criterion_options.debug == CR_DBG_IDLE) {
sp.suspended = 1;
} else if (criterion_options.debug) {
enum bxf_debugger debugger = BXF_DBG_NONE;
if (criterion_options.debug == CR_DBG_NATIVE) {
switch (ctx->test->data->compiler_) {
@ -326,6 +337,14 @@ static bxf_instance *run_test(struct run_next_context *ctx,
bxf_context_term(inst_ctx);
/* TODO: integrate this to the logger after refactor */
if (criterion_options.debug == CR_DBG_IDLE) {
criterion_pinfo(CRITERION_PREFIX_DEBUG, _(msg_print_pid),
ctx->test->category,
ctx->test->name,
(unsigned long) instance->pid);
}
*client = (struct client_ctx) {
.test = ctx->test,
.suite = &ctx->suite_set->suite,

View File

@ -173,9 +173,11 @@ static int parse_dbg(const char *arg)
{ "gdb", CR_DBG_GDB },
{ "lldb", CR_DBG_LLDB },
{ "windbg", CR_DBG_WINDBG },
{ "idle", CR_DBG_IDLE },
{ NULL, 0 },
};
for (size_t i = 0; i < 3; ++i) {
for (size_t i = 0; values[i].name; ++i) {
if (!strcmp(values[i].name, arg)) {
criterion_options.debug = values[i].dbg;
return 1;

View File

@ -51,6 +51,7 @@ const struct criterion_prefix_data g_criterion_logging_prefixes[] = {
[CRITERION_LOGGING_PREFIX_FAIL] = { "FAIL", CRIT_FG_RED },
[CRITERION_LOGGING_PREFIX_ERR] = { "ERR ", CRIT_FG_RED },
[CRITERION_LOGGING_PREFIX_WARN] = { "WARN", CRIT_FG_GOLD },
[CRITERION_LOGGING_PREFIX_DEBUG] = { "----", CRIT_FG_GRAY },
{ NULL, NULL }
};

View File

@ -42,6 +42,7 @@ enum criterion_logging_prefix {
CRITERION_LOGGING_PREFIX_FAIL,
CRITERION_LOGGING_PREFIX_ERR,
CRITERION_LOGGING_PREFIX_WARN,
CRITERION_LOGGING_PREFIX_DEBUG,
};
struct criterion_prefix_data {
@ -49,23 +50,23 @@ struct criterion_prefix_data {
const char *color;
};
#ifdef CRITERION_LOGGING_COLORS
# define CRIT_COLOR_NORMALIZE(Str) (criterion_options.use_ascii ? "" : Str)
#define CRIT_COLOR_NORMALIZE(Str) (criterion_options.use_ascii ? "" : Str)
# define CRIT_FG_BOLD "\33[0;1m"
# define CRIT_FG_RED "\33[0;31m"
# define CRIT_FG_GREEN "\33[0;32m"
# define CRIT_FG_GOLD "\33[0;33m"
# define CRIT_FG_BLUE "\33[0;34m"
# define CRIT_RESET "\33[0m"
#define CRIT_FG_BOLD "\33[0;1m"
#define CRIT_FG_RED "\33[0;31m"
#define CRIT_FG_GREEN "\33[0;32m"
#define CRIT_FG_GOLD "\33[0;33m"
#define CRIT_FG_BLUE "\33[0;34m"
#define CRIT_FG_GRAY "\33[1;30m"
#define CRIT_RESET "\33[0m"
# define CR_FG_BOLD CRIT_COLOR_NORMALIZE(CRIT_FG_BOLD)
# define CR_FG_RED CRIT_COLOR_NORMALIZE(CRIT_FG_RED)
# define CR_FG_GREEN CRIT_COLOR_NORMALIZE(CRIT_FG_GREEN)
# define CR_FG_GOLD CRIT_COLOR_NORMALIZE(CRIT_FG_GOLD)
# define CR_FG_BLUE CRIT_COLOR_NORMALIZE(CRIT_FG_BLUE)
# define CR_RESET CRIT_COLOR_NORMALIZE(CRIT_RESET)
#endif
#define CR_FG_BOLD CRIT_COLOR_NORMALIZE(CRIT_FG_BOLD)
#define CR_FG_RED CRIT_COLOR_NORMALIZE(CRIT_FG_RED)
#define CR_FG_GREEN CRIT_COLOR_NORMALIZE(CRIT_FG_GREEN)
#define CR_FG_GOLD CRIT_COLOR_NORMALIZE(CRIT_FG_GOLD)
#define CR_FG_BLUE CRIT_COLOR_NORMALIZE(CRIT_FG_BLUE)
#define CR_FG_GRAY CRIT_COLOR_NORMALIZE(CRIT_FG_GRAY)
#define CR_RESET CRIT_COLOR_NORMALIZE(CRIT_RESET)
extern const struct criterion_prefix_data g_criterion_logging_prefixes[];
@ -77,6 +78,7 @@ extern const struct criterion_prefix_data g_criterion_logging_prefixes[];
#define CRITERION_PREFIX_FAIL (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_FAIL])
#define CRITERION_PREFIX_ERR (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_ERR])
#define CRITERION_PREFIX_WARN (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_WARN])
#define CRITERION_PREFIX_DEBUG (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_DEBUG])
#undef criterion_log
#undef criterion_info