[PATCH 1/2] libtest: Add more action events

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Oct 2 06:10:40 UTC 2019


This allows more control over the initialization and finalization run.

Update #3199.
---
 cpukit/include/t.h                  |  6 ++++--
 cpukit/libtest/t-test-hash-sha256.c |  4 ++--
 cpukit/libtest/t-test-rtems-fds.c   |  2 +-
 cpukit/libtest/t-test-rtems-heap.c  |  2 +-
 cpukit/libtest/t-test-rtems-objs.c  | 20 ++++++++++----------
 cpukit/libtest/t-test.c             | 18 ++++++++++--------
 6 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/cpukit/include/t.h b/cpukit/include/t.h
index 5dbf1e00b5..ec806a1f68 100644
--- a/cpukit/include/t.h
+++ b/cpukit/include/t.h
@@ -2185,12 +2185,14 @@ void T_free(void *);
 void T_register(void);
 
 typedef enum {
-	T_EVENT_RUN_INITIALIZE,
+	T_EVENT_RUN_INITIALIZE_EARLY,
+	T_EVENT_RUN_INITIALIZE_LATE,
 	T_EVENT_CASE_EARLY,
 	T_EVENT_CASE_BEGIN,
 	T_EVENT_CASE_END,
 	T_EVENT_CASE_LATE,
-	T_EVENT_RUN_FINALIZE
+	T_EVENT_RUN_FINALIZE_EARLY,
+	T_EVENT_RUN_FINALIZE_LATE
 } T_event;
 
 typedef void (*T_action)(T_event, const char *);
diff --git a/cpukit/libtest/t-test-hash-sha256.c b/cpukit/libtest/t-test-hash-sha256.c
index c272da27ac..4793a508e5 100644
--- a/cpukit/libtest/t-test-hash-sha256.c
+++ b/cpukit/libtest/t-test-hash-sha256.c
@@ -88,10 +88,10 @@ T_report_hash_sha256(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_report_hash_sha256_initialize();
 		break;
-	case T_EVENT_RUN_FINALIZE:
+	case T_EVENT_RUN_FINALIZE_LATE:
 		T_report_hash_sha256_finalize();
 		break;
 	default:
diff --git a/cpukit/libtest/t-test-rtems-fds.c b/cpukit/libtest/t-test-rtems-fds.c
index 79720a01c4..19abbd3673 100644
--- a/cpukit/libtest/t-test-rtems-fds.c
+++ b/cpukit/libtest/t-test-rtems-fds.c
@@ -71,7 +71,7 @@ T_check_file_descriptors(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_open_fds = T_count_open_fds();
 		break;
 	case T_EVENT_CASE_END:
diff --git a/cpukit/libtest/t-test-rtems-heap.c b/cpukit/libtest/t-test-rtems-heap.c
index 8858f5b952..6755e886b2 100644
--- a/cpukit/libtest/t-test-rtems-heap.c
+++ b/cpukit/libtest/t-test-rtems-heap.c
@@ -100,7 +100,7 @@ T_check_heap(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_heap_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
diff --git a/cpukit/libtest/t-test-rtems-objs.c b/cpukit/libtest/t-test-rtems-objs.c
index dd4f2d59d2..55da1ab850 100644
--- a/cpukit/libtest/t-test-rtems-objs.c
+++ b/cpukit/libtest/t-test-rtems-objs.c
@@ -94,7 +94,7 @@ T_check_rtems_barriers(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_barriers_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -127,7 +127,7 @@ T_check_rtems_extensions(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_extensions_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -160,7 +160,7 @@ T_check_rtems_message_queues(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_message_queues_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -193,7 +193,7 @@ T_check_rtems_partitions(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_partitions_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -226,7 +226,7 @@ T_check_rtems_periods(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_periods_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -259,7 +259,7 @@ T_check_rtems_regions(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_regions_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -292,7 +292,7 @@ T_check_rtems_semaphores(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_semaphores_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -329,7 +329,7 @@ T_check_rtems_tasks(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_tasks_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -362,7 +362,7 @@ T_check_rtems_timers(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_rtems_timers_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
@@ -435,7 +435,7 @@ T_check_posix_keys(T_event event, const char *name)
 	(void)name;
 
 	switch (event) {
-	case T_EVENT_RUN_INITIALIZE:
+	case T_EVENT_RUN_INITIALIZE_EARLY:
 		T_posix_keys_run_initialize();
 		break;
 	case T_EVENT_CASE_END:
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 881a92efb0..6338750c8c 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -645,7 +645,7 @@ T_call_destructors(const T_context *ctx)
 }
 
 static void
-T_call_actions_forward(const T_config *config, T_event event, const char *name)
+T_actions_forward(const T_config *config, T_event event, const char *name)
 {
 	const T_action *actions;
 	size_t n;
@@ -660,7 +660,7 @@ T_call_actions_forward(const T_config *config, T_event event, const char *name)
 }
 
 static void
-T_call_actions_backward(const T_config *config, T_event event,
+T_actions_backward(const T_config *config, T_event event,
     const char *name)
 {
 	const T_action *actions;
@@ -706,10 +706,11 @@ T_do_run_initialize(const T_config *config)
 	ctx->overall_failures = 0;
 
 	T_set_runner(ctx);
-	T_call_actions_forward(config, T_EVENT_RUN_INITIALIZE, config->name);
+	T_actions_forward(config, T_EVENT_RUN_INITIALIZE_EARLY, config->name);
 	T_do_log(ctx, T_QUIET, "A:%s\n", config->name);
 	T_system(ctx);
 	ctx->run_begin_time = (*config->now)();
+	T_actions_forward(config, T_EVENT_RUN_INITIALIZE_LATE, config->name);
 
 	return ctx;
 }
@@ -730,10 +731,10 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc)
 	atomic_store_explicit(&ctx->steps, 0, memory_order_relaxed);
 	atomic_store_explicit(&ctx->failures, 0, memory_order_relaxed);
 
-	T_call_actions_forward(config, T_EVENT_CASE_EARLY, tc->name);
+	T_actions_forward(config, T_EVENT_CASE_EARLY, tc->name);
 	T_do_log(ctx, T_NORMAL, "B:%s\n", tc->name);
 	ctx->case_begin_time = (*config->now)();
-	T_call_actions_forward(config, T_EVENT_CASE_BEGIN, tc->name);
+	T_actions_forward(config, T_EVENT_CASE_BEGIN, tc->name);
 
 	if (fixture != NULL) {
 		ctx->fixture_context = fixture->initial_context;
@@ -763,7 +764,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
 	}
 
 	T_call_destructors(ctx);
-	T_call_actions_backward(config, T_EVENT_CASE_END, tc->name);
+	T_actions_backward(config, T_EVENT_CASE_END, tc->name);
 
 	planned_steps = atomic_fetch_add_explicit(&ctx->planned_steps,
 	    0, memory_order_relaxed);
@@ -793,7 +794,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
 	ctx->overall_steps += steps;
 	ctx->overall_failures += failures;
 
-	T_call_actions_backward(config, T_EVENT_CASE_LATE, tc->name);
+	T_actions_backward(config, T_EVENT_CASE_LATE, tc->name);
 }
 
 static void
@@ -829,11 +830,12 @@ T_do_run_finalize(T_context *ctx)
 	T_time_string ts;
 
 	config = ctx->config;
+	T_actions_backward(config, T_EVENT_RUN_FINALIZE_EARLY, config->name);
 	delta = (*config->now)() - ctx->run_begin_time;
 	T_do_log(ctx, T_QUIET, "Z:%s:C:%u:N:%u:F:%u:D:%s\n", config->name,
 	    ctx->overall_cases, ctx->overall_steps, ctx->overall_failures,
 	    T_time_to_string_us(delta, ts));
-	T_call_actions_backward(config, T_EVENT_RUN_FINALIZE, config->name);
+	T_actions_backward(config, T_EVENT_RUN_FINALIZE_LATE, config->name);
 #ifdef __rtems__
 	ctx->runner_thread = NULL;
 	ctx->runner_cpu = NULL;
-- 
2.16.4



More information about the devel mailing list