mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 09:05:06 +08:00
sptests/spintrcritical19: PR2136: New test
This commit is contained in:
@@ -29,6 +29,7 @@ SUBDIRS = \
|
||||
spsem01 spsem02 spsimplesched01 spsimplesched02 spsimplesched03 spnsext01 \
|
||||
spedfsched01 spedfsched02 spedfsched03 \
|
||||
spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01
|
||||
SUBDIRS += spintrcritical19
|
||||
SUBDIRS += spcontext01
|
||||
SUBDIRS += spfatal26
|
||||
SUBDIRS += speventtransient01
|
||||
|
||||
@@ -27,6 +27,7 @@ AC_CHECK_SIZEOF([time_t])
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile
|
||||
spintrcritical19/Makefile
|
||||
spcontext01/Makefile
|
||||
spfatal26/Makefile
|
||||
spinternalerror02/Makefile
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
rtems_tests_PROGRAMS = spintrcritical19
|
||||
spintrcritical19_SOURCES = init.c ../spintrcritical_support/intrcritical.c
|
||||
|
||||
dist_rtems_tests_DATA = spintrcritical19.scn spintrcritical19.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/spintrcritical_support
|
||||
|
||||
LINK_OBJS = $(spintrcritical19_OBJECTS)
|
||||
LINK_LIBS = $(spintrcritical19_LDLIBS)
|
||||
|
||||
spintrcritical19$(EXEEXT): $(spintrcritical19_OBJECTS) $(spintrcritical19_DEPENDENCIES)
|
||||
@rm -f spintrcritical19$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2012 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tmacros.h>
|
||||
#include <intrcritical.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
|
||||
#define TEST_NAME "19"
|
||||
|
||||
#define PRIORITY_RED 1
|
||||
|
||||
#define PRIORITY_GREEN 2
|
||||
|
||||
#define PRIORITY_RESUMER 3
|
||||
|
||||
typedef struct {
|
||||
rtems_id master_task;
|
||||
rtems_id resumer_task;
|
||||
Thread_Control *master_task_tcb;
|
||||
bool test_case_hit;
|
||||
} test_context;
|
||||
|
||||
static test_context ctx_instance;
|
||||
|
||||
static void resumer_task(rtems_task_argument arg)
|
||||
{
|
||||
test_context *ctx = (test_context *) arg;
|
||||
|
||||
while (true) {
|
||||
rtems_status_code sc = rtems_task_resume(ctx->master_task);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
static void suspend_master_task(rtems_id timer, void *arg)
|
||||
{
|
||||
/* The arg is NULL */
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_status_code sc;
|
||||
|
||||
if (_States_Is_transient(ctx->master_task_tcb->current_state)) {
|
||||
ctx->test_case_hit = true;
|
||||
}
|
||||
|
||||
sc = rtems_task_suspend(ctx->master_task);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument ignored)
|
||||
{
|
||||
test_context *ctx = &ctx_instance;
|
||||
rtems_task_priority priority = PRIORITY_RED;
|
||||
int resets = 0;
|
||||
rtems_status_code sc;
|
||||
|
||||
puts("\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n");
|
||||
|
||||
ctx->master_task = rtems_task_self();
|
||||
ctx->master_task_tcb = _Thread_Get_executing();
|
||||
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('R', 'E', 'S', 'U'),
|
||||
PRIORITY_RESUMER,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->resumer_task
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
sc = rtems_task_start(
|
||||
ctx->resumer_task,
|
||||
resumer_task,
|
||||
(rtems_task_argument) ctx
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
interrupt_critical_section_test_support_initialize(
|
||||
suspend_master_task
|
||||
);
|
||||
|
||||
while (resets < 3 && !ctx->test_case_hit) {
|
||||
if (interrupt_critical_section_test_support_delay()) {
|
||||
++resets;
|
||||
}
|
||||
|
||||
sc = rtems_task_set_priority(RTEMS_SELF, priority, &priority);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rtems_test_assert(_States_Is_ready(ctx->master_task_tcb->current_state));
|
||||
}
|
||||
|
||||
rtems_test_assert(ctx->test_case_hit);
|
||||
|
||||
sc = rtems_task_delete(ctx->resumer_task);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
puts("*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***");
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 2
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 1
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_GREEN
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
@@ -0,0 +1,13 @@
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: spintrcritical19
|
||||
|
||||
directives:
|
||||
|
||||
- rtems_task_suspend()
|
||||
- rtems_task_set_priority()
|
||||
|
||||
concepts:
|
||||
|
||||
- Ensure that a priority change works during suspend requests from an
|
||||
interrupt service routine.
|
||||
@@ -0,0 +1,4 @@
|
||||
*** TEST INTERRUPT CRITICAL SECTION 19 ***
|
||||
|
||||
Support - rtems_timer_create - creating timer 1
|
||||
*** END OF TEST INTERRUPT CRITICAL SECTION 19 ***
|
||||
Reference in New Issue
Block a user