From 4601063b15ad7a1896135bf91bbcb7cabfbc9000 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 20 May 2011 15:51:33 +0930 Subject: [PATCH] failtest: failtest_has_failed() Allows tests to explicitly avoid continuing when a failure has been injected. --- ccan/failtest/failtest.c | 5 +++++ ccan/failtest/failtest.h | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index e9f83736..24715106 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -1053,6 +1053,11 @@ void failtest_init(int argc, char *argv[]) gettimeofday(&start, NULL); } +bool failtest_has_failed(void) +{ + return control_fd != -1; +} + void failtest_exit(int status) { if (failtest_exit_check) { diff --git a/ccan/failtest/failtest.h b/ccan/failtest/failtest.h index 4df28624..d4d9987b 100644 --- a/ccan/failtest/failtest.h +++ b/ccan/failtest/failtest.h @@ -196,6 +196,16 @@ extern enum failtest_result extern bool (*failtest_exit_check)(struct failtest_call *history, unsigned num); +/** + * failtest_has_failed - determine if a failure has occurred. + * + * Sometimes you want to exit immediately if you've experienced a failure. + * This is useful when you have four separate tests in your test suite, + * and you don't want to do the next one if you've had a failure in a + * previous one. + */ +extern bool failtest_has_failed(void); + /** * failtest_timeout_ms - how long to wait before killing child. * -- 2.39.2