[rtems commit] libtest: Add T_stop()

Sebastian Huber sebh at rtems.org
Thu Jul 23 08:57:41 UTC 2020


Module:    rtems
Branch:    master
Commit:    77814040262f2ae1a479f94d962139d68052b743
Changeset: http://git.rtems.org/rtems/commit/?id=77814040262f2ae1a479f94d962139d68052b743

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jul 17 21:21:16 2020 +0200

libtest: Add T_stop()

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 09afc29..8af810d 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 e74b4d3..4c5746f 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) {



More information about the vc mailing list