File indexing completed on 2025-05-11 08:24:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #define _GNU_SOURCE
0010
0011 #ifdef HAVE_CONFIG_H
0012 #include "config.h"
0013 #endif
0014
0015 #include <sys/stat.h>
0016 #include <errno.h>
0017 #include <pthread.h>
0018
0019 #include <bsp.h>
0020
0021 #include <tmacros.h>
0022
0023 const char rtems_test_name[] = "SPCONFIG 1";
0024
0025 static int counter;
0026
0027 static void checkpoint(int expected_counter)
0028 {
0029 int current_counter;
0030
0031 current_counter = counter;
0032 rtems_test_assert(current_counter == expected_counter);
0033 counter = current_counter + 1;
0034 }
0035
0036 static rtems_status_code bsp_prerequisite_drivers_init(
0037 rtems_device_major_number major,
0038 rtems_device_minor_number minor,
0039 void *arg
0040 )
0041 {
0042 TEST_BEGIN();
0043 checkpoint(0);
0044 return RTEMS_SUCCESSFUL;
0045 }
0046
0047 static rtems_status_code app_prerequisite_drivers_init(
0048 rtems_device_major_number major,
0049 rtems_device_minor_number minor,
0050 void *arg
0051 )
0052 {
0053 struct stat st;
0054 int rv;
0055
0056 checkpoint(1);
0057
0058 errno = 0;
0059 rv = stat("/dev/null", &st);
0060 rtems_test_assert(rv == -1);
0061 rtems_test_assert(errno == ENOENT);
0062
0063 return RTEMS_SUCCESSFUL;
0064 }
0065
0066 static rtems_status_code app_extra_drivers_init(
0067 rtems_device_major_number major,
0068 rtems_device_minor_number minor,
0069 void *arg
0070 )
0071 {
0072 struct stat st;
0073 int rv;
0074
0075 checkpoint(2);
0076
0077 rv = stat("/dev/null", &st);
0078 rtems_test_assert(rv == 0);
0079
0080 return RTEMS_SUCCESSFUL;
0081 }
0082
0083 static void test_stack_config(void)
0084 {
0085 pthread_attr_t attr;
0086 size_t stack_size;
0087 int eno;
0088
0089 rtems_test_assert(
0090 rtems_configuration_get_interrupt_stack_size() == CPU_STACK_MINIMUM_SIZE
0091 );
0092
0093 eno = pthread_getattr_np(pthread_self(), &attr);
0094 rtems_test_assert(eno == 0);
0095
0096 eno = pthread_attr_getstacksize(&attr, &stack_size);
0097 rtems_test_assert(eno == 0);
0098 rtems_test_assert(stack_size >= 2 * CPU_STACK_MINIMUM_SIZE);
0099 rtems_test_assert(
0100 stack_size <= 2 * CPU_STACK_MINIMUM_SIZE + CPU_STACK_ALIGNMENT -
0101 CPU_HEAP_ALIGNMENT
0102 );
0103
0104 eno = pthread_attr_destroy(&attr);
0105 rtems_test_assert(eno == 0);
0106 }
0107
0108 static void Init(rtems_task_argument arg)
0109 {
0110 checkpoint(3);
0111 test_stack_config();
0112 TEST_END();
0113 rtems_test_exit(0);
0114 }
0115
0116 #ifdef BSP_INTERRUPT_STACK_SIZE
0117 #warning "BSP_INTERRUPT_STACK_SIZE will be #undef for this test"
0118 #undef BSP_INTERRUPT_STACK_SIZE
0119 #endif
0120
0121 #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
0122 #warning "CONFIGURE_BSP_PREREQUISITE_DRIVERS will be #undef for this test"
0123 #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS
0124 #endif
0125
0126 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0127
0128 #define CONFIGURE_BSP_PREREQUISITE_DRIVERS \
0129 { bsp_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL }
0130
0131 #define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
0132 { app_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL }
0133
0134 #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
0135
0136 #define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
0137 { app_extra_drivers_init, NULL, NULL, NULL, NULL, NULL }
0138
0139 #define CONFIGURE_MAXIMUM_TASKS 1
0140
0141 #define CONFIGURE_MINIMUM_TASK_STACK_SIZE (2 * CPU_STACK_MINIMUM_SIZE)
0142
0143 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0144
0145 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0146
0147 #define CONFIGURE_INIT
0148
0149 #include <rtems/confdefs.h>