[PATCH 10/33] libtest: Add T_stop()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jul 21 15:04:27 UTC 2020


Update #3199.
---
 cpukit/include/rtems/test.h |  8 ++++++++
 cpukit/libtest/t-test.c     | 12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index 09afc29593..8af810def7 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -95,6 +95,12 @@ typedef struct T_fixture_node {
  * @{
  */
 
+#ifdef __cplusplus
+#define T_NO_RETURN [[ noreturn ]]
+#else
+#define T_NO_RETURN _Noreturn
+#endif
+
 typedef struct T_case_context {
 	const char *name;
 	void (*body)(void);
@@ -2243,6 +2249,8 @@ void *T_push_fixture(T_fixture_node *, const T_fixture *);
 
 void T_pop_fixture(void);
 
+T_NO_RETURN void T_stop(void);
+
 /**
  * @brief Gets the scope for nested fixtures.
  *
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index e74b4d3495..4c5746fc5c 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -423,8 +423,8 @@ T_add_failure(T_context *ctx)
 	    memory_order_relaxed);
 }
 
-static void
-T_stop(T_context *ctx)
+T_NO_RETURN static void
+T_do_stop(T_context *ctx)
 {
 	T_fixture_node *node;
 
@@ -445,6 +445,12 @@ T_stop(T_context *ctx)
 	longjmp(ctx->case_begin_context, 1);
 }
 
+T_NO_RETURN void
+T_stop(void)
+{
+	T_do_stop(&T_instance);
+}
+
 void T_plan(unsigned int planned_steps)
 {
 	T_context *ctx;
@@ -568,7 +574,7 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
 			}
 
 			if ((t->flags & T_CHECK_STOP) != 0) {
-				T_stop(ctx);
+				T_do_stop(ctx);
 			}
 		} else if ((t->flags & T_CHECK_QUIET) == 0 &&
 		    ctx->verbosity >= T_VERBOSE) {
-- 
2.26.2



More information about the devel mailing list