[rtems commit] spintrcritical23: Use T_interrupt_test()
Sebastian Huber
sebh at rtems.org
Thu Jul 23 08:57:41 UTC 2020
Module: rtems
Branch: master
Commit: 23b9debe12b5492fe474c871145a6508e3162a17
Changeset: http://git.rtems.org/rtems/commit/?id=23b9debe12b5492fe474c871145a6508e3162a17
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Jul 21 07:32:10 2020 +0200
spintrcritical23: Use T_interrupt_test()
---
testsuites/sptests/Makefile.am | 4 +-
testsuites/sptests/spintrcritical23/init.c | 108 +++++++++++++--------
.../sptests/spintrcritical23/spintrcritical23.scn | 20 ++++
3 files changed, 88 insertions(+), 44 deletions(-)
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index f35eeed..1482681 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -1370,9 +1370,7 @@ if TEST_spintrcritical23
sp_tests += spintrcritical23
sp_screens += spintrcritical23/spintrcritical23.scn
sp_docs += spintrcritical23/spintrcritical23.doc
-spintrcritical23_SOURCES = spintrcritical23/init.c \
- spintrcritical_support/intrcritical.h \
- spintrcritical_support/intrcritical.c
+spintrcritical23_SOURCES = spintrcritical23/init.c
spintrcritical23_CPPFLAGS = $(AM_CPPFLAGS) \
$(TEST_FLAGS_spintrcritical23) $(support_includes) \
-I$(top_srcdir)/spintrcritical_support
diff --git a/testsuites/sptests/spintrcritical23/init.c b/testsuites/sptests/spintrcritical23/init.c
index 70907f0..91b60a4 100644
--- a/testsuites/sptests/spintrcritical23/init.c
+++ b/testsuites/sptests/spintrcritical23/init.c
@@ -1,11 +1,5 @@
/*
- * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems at embedded-brains.de>
+ * Copyright (C) 2015, 2020 embedded brains GmbH (http://www.embedded-brains.de)
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -16,8 +10,8 @@
#include "config.h"
#endif
-#include <tmacros.h>
-#include <intrcritical.h>
+#include <rtems/test.h>
+#include <rtems/test-info.h>
#include <string.h>
@@ -33,18 +27,23 @@ typedef struct {
Scheduler_priority_Node *scheduler_node;
rtems_task_priority priority_task;
rtems_task_priority priority_interrupt;
- bool done;
+ volatile bool early;
+ volatile bool late;
} test_context;
-static test_context ctx_instance;
-
-static void change_priority(rtems_id timer, void *arg)
+static T_interrupt_test_state interrupt(void *arg)
{
- /* The arg is NULL */
- test_context *ctx = &ctx_instance;
+ test_context *ctx = arg;
+ T_interrupt_test_state state;
rtems_interrupt_lock_context lock_context;
unsigned int next_priority;
+ state = T_interrupt_test_get_state();
+
+ if (state != T_INTERRUPT_TEST_ACTION) {
+ return T_INTERRUPT_TEST_CONTINUE;
+ }
+
rtems_interrupt_lock_acquire(&ctx->lock, &lock_context);
next_priority = SCHEDULER_PRIORITY_UNMAP(
@@ -67,16 +66,34 @@ static void change_priority(rtems_id timer, void *arg)
priority_interrupt,
&previous
);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- rtems_test_assert(previous == priority_task);
+ T_quiet_rsc_success(sc);
+ T_quiet_eq_u32(previous, priority_task);
- ctx->done = true;
+ state = T_INTERRUPT_TEST_DONE;
} else {
rtems_interrupt_lock_release(&ctx->lock, &lock_context);
+
+ if ( ctx->early ) {
+ state = T_INTERRUPT_TEST_EARLY;
+ } else if ( ctx->late ) {
+ state = T_INTERRUPT_TEST_LATE;
+ } else {
+ state = T_INTERRUPT_TEST_CONTINUE;
+ }
}
+
+ return state;
+}
+
+static void prepare(void *arg)
+{
+ test_context *ctx = arg;
+
+ ctx->early = true;
+ ctx->late = false;
}
-static bool test_body(void *arg)
+static void action(void *arg)
{
test_context *ctx = arg;
rtems_status_code sc;
@@ -96,44 +113,55 @@ static bool test_body(void *arg)
rtems_interrupt_lock_release(&ctx->lock, &lock_context);
+ ctx->early = false;
sc = rtems_task_set_priority(
ctx->task_id,
priority_task,
&previous
);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- rtems_test_assert(previous == priority_last);
+ T_quiet_rsc_success(RTEMS_SUCCESSFUL);
+ T_quiet_eq_u32(previous, priority_last);
+ ctx->late = true;
- if (ctx->done) {
+ if (T_interrupt_test_get_state() == T_INTERRUPT_TEST_DONE) {
sc = rtems_task_set_priority(
ctx->task_id,
RTEMS_CURRENT_PRIORITY,
&previous
);
- rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- rtems_test_assert(previous == priority_interrupt);
+ T_quiet_rsc_success(sc);
+ T_quiet_eq_u32(previous, priority_interrupt);
}
-
- return ctx->done;
}
-static void Init(rtems_task_argument arg)
-{
- test_context *ctx = &ctx_instance;
-
- TEST_BEGIN();
+static const T_interrupt_test_config config = {
+ .prepare = prepare,
+ .action = action,
+ .interrupt = interrupt,
+ .max_iteration_count = 10000
+};
- rtems_interrupt_lock_initialize(&ctx->lock, "Test");
- ctx->priority_task = 1;
- ctx->task_id = rtems_task_self();
- ctx->scheduler_node =
+T_TEST_CASE(TaskSetPriorityInterrupt)
+{
+ test_context ctx;
+ T_interrupt_test_state state;
+
+ memset(&ctx, 0, sizeof(ctx));
+ rtems_interrupt_lock_initialize(&ctx.lock, "Test");
+ ctx.priority_task = 1;
+ ctx.task_id = rtems_task_self();
+ ctx.scheduler_node =
_Scheduler_priority_Thread_get_node(_Thread_Get_executing());
- interrupt_critical_section_test(test_body, ctx, change_priority);
- rtems_test_assert(ctx->done);
+ state = T_interrupt_test(&config, &ctx);
+ T_eq_int(state, T_INTERRUPT_TEST_DONE);
- TEST_END();
- rtems_test_exit(0);
+ rtems_interrupt_lock_destroy(&ctx.lock);
+}
+
+static rtems_task Init(rtems_task_argument argument)
+{
+ rtems_test_run(argument, TEST_STATE);
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
@@ -142,8 +170,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_MAXIMUM_TASKS 1
-#define CONFIGURE_MAXIMUM_TIMERS 1
-#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
/* We use internal data structures of this scheduler in this test */
#define CONFIGURE_SCHEDULER_PRIORITY
diff --git a/testsuites/sptests/spintrcritical23/spintrcritical23.scn b/testsuites/sptests/spintrcritical23/spintrcritical23.scn
index cea3292..fe3641a 100644
--- a/testsuites/sptests/spintrcritical23/spintrcritical23.scn
+++ b/testsuites/sptests/spintrcritical23/spintrcritical23.scn
@@ -1,2 +1,22 @@
*** BEGIN OF TEST SPINTRCRITICAL 23 ***
+*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP
+*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+A:SPINTRCRITICAL 23
+S:Platform:RTEMS
+S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4)
+S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d
+S:BSP:realview_pbx_a9_qemu
+S:RTEMS_DEBUG:1
+S:RTEMS_MULTIPROCESSING:0
+S:RTEMS_POSIX_API:1
+S:RTEMS_PROFILING:0
+S:RTEMS_SMP:1
+B:TaskSetPriorityInterrupt
+P:0:0:UI1:init.c:166
+E:TaskSetPriorityInterrupt:N:1:F:0:D:0.914959
+Z:SPINTRCRITICAL 23:C:1:N:1:F:0:D:0.916110
+Y:ReportHash:SHA256:b4aa098c47f8352ac00c37c1b61aabebd8770febfa4fd8821a1121a59b3c2b80
+
*** END OF TEST SPINTRCRITICAL 23 ***
More information about the vc
mailing list