forked from Imagelibrary/rtems
libtest: Add more action events
This allows more control over the initialization and finalization run. Update #3199.
This commit is contained in:
@@ -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 *);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user