Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:43

0001 /*
0002  * Copyright (c) 2016 embedded brains GmbH & Co. KG
0003  *
0004  * The license and distribution terms for this file may be
0005  * found in the file LICENSE in this distribution or at
0006  * http://www.rtems.com/license/LICENSE.
0007  */
0008 
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012 
0013 #include "tmacros.h"
0014 
0015 const char rtems_test_name[] = "SMPFATAL 3";
0016 
0017 static void bad( rtems_id timer_id, void *arg )
0018 {
0019   rtems_id *sem_id;
0020 
0021   sem_id = arg;
0022 
0023   rtems_semaphore_obtain( *sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
0024   rtems_test_assert( 0 );
0025 }
0026 
0027 static void Init( rtems_task_argument arg )
0028 {
0029   rtems_status_code sc;
0030   rtems_id          timer_id;
0031   rtems_id          sem_id;
0032 
0033   TEST_BEGIN();
0034 
0035   sc = rtems_semaphore_create(
0036     rtems_build_name('M', 'R', 'S', 'P'),
0037     1,
0038     RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY |
0039       RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
0040     1,
0041     &sem_id
0042   );
0043   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0044 
0045   sc = rtems_timer_create(
0046     rtems_build_name( 'E', 'V', 'I', 'L' ),
0047     &timer_id
0048   );
0049   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0050 
0051   sc = rtems_semaphore_obtain( sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
0052   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0053 
0054   sc = rtems_timer_fire_after( timer_id, 1, bad, &sem_id );
0055   rtems_test_assert( sc == RTEMS_SUCCESSFUL );
0056 
0057   rtems_task_wake_after( 2 );
0058   rtems_test_assert( 0 );
0059 }
0060 
0061 static void fatal_extension(
0062   rtems_fatal_source source,
0063   bool always_set_to_false,
0064   rtems_fatal_code code
0065 )
0066 {
0067   if (
0068     source == INTERNAL_ERROR_CORE
0069       && !always_set_to_false
0070       && code == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
0071   ) {
0072     TEST_END();
0073   }
0074 }
0075 
0076 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0077 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0078 
0079 #define CONFIGURE_INITIAL_EXTENSIONS \
0080   { .fatal = fatal_extension }, \
0081   RTEMS_TEST_INITIAL_EXTENSION
0082 
0083 #define CONFIGURE_MAXIMUM_TASKS 1
0084 #define CONFIGURE_MAXIMUM_TIMERS 1
0085 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
0086 
0087 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0088 
0089 #define CONFIGURE_INIT
0090 
0091 #include <rtems/confdefs.h>