If a assert fails and --crash is given, the debugger will trapped in this assert using debugbreak.h from the new debugbreak submodule.
This commit is contained in:
parent
15b221ac09
commit
25d444b1b9
7 changed files with 24 additions and 0 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -19,3 +19,6 @@
|
||||||
[submodule "dependencies/nanomsg-patched"]
|
[submodule "dependencies/nanomsg-patched"]
|
||||||
path = dependencies/nanomsg-patched
|
path = dependencies/nanomsg-patched
|
||||||
url = https://github.com/Snaipe/nanomsg.git
|
url = https://github.com/Snaipe/nanomsg.git
|
||||||
|
[submodule "dependencies/debugbreak"]
|
||||||
|
path = dependencies/debugbreak
|
||||||
|
url = https://github.com/scottt/debugbreak
|
||||||
|
|
|
@ -55,6 +55,7 @@ include_directories(
|
||||||
dependencies/valgrind/include/
|
dependencies/valgrind/include/
|
||||||
dependencies/klib/
|
dependencies/klib/
|
||||||
dependencies/nanopb/
|
dependencies/nanopb/
|
||||||
|
dependencies/debugbreak/
|
||||||
)
|
)
|
||||||
|
|
||||||
# Coverage
|
# Coverage
|
||||||
|
|
1
dependencies/debugbreak
vendored
Submodule
1
dependencies/debugbreak
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6b79ec8d8f8d4603111f580a0537f8f31c484c32
|
|
@ -116,6 +116,14 @@ struct criterion_options {
|
||||||
* default: false
|
* default: false
|
||||||
*/
|
*/
|
||||||
bool wait_for_clients;
|
bool wait_for_clients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raise a debug trap to crash the test if an assert fails so that a
|
||||||
|
* debugger can gain control.
|
||||||
|
*
|
||||||
|
* default: false
|
||||||
|
*/
|
||||||
|
bool crash;
|
||||||
};
|
};
|
||||||
|
|
||||||
CR_BEGIN_C_API
|
CR_BEGIN_C_API
|
||||||
|
|
|
@ -27,11 +27,16 @@
|
||||||
#include "protocol/messages.h"
|
#include "protocol/messages.h"
|
||||||
#include "criterion/internal/asprintf-compat.h"
|
#include "criterion/internal/asprintf-compat.h"
|
||||||
#include "criterion/criterion.h"
|
#include "criterion/criterion.h"
|
||||||
|
#include "criterion/options.h"
|
||||||
#include "io/event.h"
|
#include "io/event.h"
|
||||||
|
#include "debugbreak.h"
|
||||||
|
|
||||||
jmp_buf g_pre_test;
|
jmp_buf g_pre_test;
|
||||||
|
|
||||||
void criterion_abort_test(void) {
|
void criterion_abort_test(void) {
|
||||||
|
if (criterion_options.crash)
|
||||||
|
debug_break();
|
||||||
|
|
||||||
longjmp(g_pre_test, 1);
|
longjmp(g_pre_test, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@
|
||||||
"prematurely after the test\n" \
|
"prematurely after the test\n" \
|
||||||
" --verbose[=level]: sets verbosity to level " \
|
" --verbose[=level]: sets verbosity to level " \
|
||||||
"(1 by default)\n" \
|
"(1 by default)\n" \
|
||||||
|
" --crash: crash failing assertions rather than " \
|
||||||
|
"aborting (for debugging purposes)\n" \
|
||||||
" -OP:F or --output=PROVIDER=FILE: write test " \
|
" -OP:F or --output=PROVIDER=FILE: write test " \
|
||||||
"report to FILE using the specified provider\n"
|
"report to FILE using the specified provider\n"
|
||||||
|
|
||||||
|
@ -148,6 +150,7 @@ int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg) {
|
||||||
{"no-early-exit", no_argument, 0, 'z'},
|
{"no-early-exit", no_argument, 0, 'z'},
|
||||||
{"output", required_argument, 0, 'O'},
|
{"output", required_argument, 0, 'O'},
|
||||||
{"wait", no_argument, 0, 'w'},
|
{"wait", no_argument, 0, 'w'},
|
||||||
|
{"crash", no_argument, 0, 'c'},
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -271,6 +274,7 @@ int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg) {
|
||||||
} break;
|
} break;
|
||||||
case 'w': criterion_options.wait_for_clients = true; break;
|
case 'w': criterion_options.wait_for_clients = true; break;
|
||||||
case '?':
|
case '?':
|
||||||
|
case 'c': criterion_options.crash = true; break;
|
||||||
default : do_print_usage = handle_unknown_arg; break;
|
default : do_print_usage = handle_unknown_arg; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ Display the help message
|
||||||
--always-succeed: always exit with 0
|
--always-succeed: always exit with 0
|
||||||
--no-early-exit: do not exit the test worker prematurely after the test
|
--no-early-exit: do not exit the test worker prematurely after the test
|
||||||
--verbose[=level]: sets verbosity to level (1 by default)
|
--verbose[=level]: sets verbosity to level (1 by default)
|
||||||
|
--crash: crash failing assertions rather than aborting (for debugging purposes)
|
||||||
-OP:F or --output=PROVIDER=FILE: write test report to FILE using the specified provider
|
-OP:F or --output=PROVIDER=FILE: write test report to FILE using the specified provider
|
||||||
|
|
||||||
$ simple.cc.bin --help
|
$ simple.cc.bin --help
|
||||||
|
@ -40,6 +41,7 @@ Display the help message
|
||||||
--always-succeed: always exit with 0
|
--always-succeed: always exit with 0
|
||||||
--no-early-exit: do not exit the test worker prematurely after the test
|
--no-early-exit: do not exit the test worker prematurely after the test
|
||||||
--verbose[=level]: sets verbosity to level (1 by default)
|
--verbose[=level]: sets verbosity to level (1 by default)
|
||||||
|
--crash: crash failing assertions rather than aborting (for debugging purposes)
|
||||||
-OP:F or --output=PROVIDER=FILE: write test report to FILE using the specified provider
|
-OP:F or --output=PROVIDER=FILE: write test report to FILE using the specified provider
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue