1 | /* |
---|
2 | * Copyright (c) 2018 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #define _GNU_SOURCE |
---|
16 | |
---|
17 | #ifdef HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <sys/stat.h> |
---|
22 | #include <errno.h> |
---|
23 | #include <pthread.h> |
---|
24 | |
---|
25 | #include <bsp.h> |
---|
26 | |
---|
27 | #include <tmacros.h> |
---|
28 | |
---|
29 | const char rtems_test_name[] = "SPCONFIG 1"; |
---|
30 | |
---|
31 | static int counter; |
---|
32 | |
---|
33 | static void checkpoint(int expected_counter) |
---|
34 | { |
---|
35 | int current_counter; |
---|
36 | |
---|
37 | current_counter = counter; |
---|
38 | rtems_test_assert(current_counter == expected_counter); |
---|
39 | counter = current_counter + 1; |
---|
40 | } |
---|
41 | |
---|
42 | static rtems_status_code bsp_prerequisite_drivers_init( |
---|
43 | rtems_device_major_number major, |
---|
44 | rtems_device_minor_number minor, |
---|
45 | void *arg |
---|
46 | ) |
---|
47 | { |
---|
48 | TEST_BEGIN(); |
---|
49 | checkpoint(0); |
---|
50 | return RTEMS_SUCCESSFUL; |
---|
51 | } |
---|
52 | |
---|
53 | static rtems_status_code app_prerequisite_drivers_init( |
---|
54 | rtems_device_major_number major, |
---|
55 | rtems_device_minor_number minor, |
---|
56 | void *arg |
---|
57 | ) |
---|
58 | { |
---|
59 | struct stat st; |
---|
60 | int rv; |
---|
61 | |
---|
62 | checkpoint(1); |
---|
63 | |
---|
64 | errno = 0; |
---|
65 | rv = stat("/dev/null", &st); |
---|
66 | rtems_test_assert(rv == -1); |
---|
67 | rtems_test_assert(errno == ENOENT); |
---|
68 | |
---|
69 | return RTEMS_SUCCESSFUL; |
---|
70 | } |
---|
71 | |
---|
72 | static rtems_status_code app_extra_drivers_init( |
---|
73 | rtems_device_major_number major, |
---|
74 | rtems_device_minor_number minor, |
---|
75 | void *arg |
---|
76 | ) |
---|
77 | { |
---|
78 | struct stat st; |
---|
79 | int rv; |
---|
80 | |
---|
81 | checkpoint(2); |
---|
82 | |
---|
83 | rv = stat("/dev/null", &st); |
---|
84 | rtems_test_assert(rv == 0); |
---|
85 | |
---|
86 | return RTEMS_SUCCESSFUL; |
---|
87 | } |
---|
88 | |
---|
89 | static void test_stack_config(void) |
---|
90 | { |
---|
91 | pthread_attr_t attr; |
---|
92 | size_t stack_size; |
---|
93 | int eno; |
---|
94 | |
---|
95 | rtems_test_assert( |
---|
96 | rtems_configuration_get_interrupt_stack_size() == CPU_STACK_MINIMUM_SIZE |
---|
97 | ); |
---|
98 | |
---|
99 | eno = pthread_getattr_np(pthread_self(), &attr); |
---|
100 | rtems_test_assert(eno == 0); |
---|
101 | |
---|
102 | eno = pthread_attr_getstacksize(&attr, &stack_size); |
---|
103 | rtems_test_assert(eno == 0); |
---|
104 | rtems_test_assert(stack_size == 2 * CPU_STACK_MINIMUM_SIZE); |
---|
105 | |
---|
106 | eno = pthread_attr_destroy(&attr); |
---|
107 | rtems_test_assert(eno == 0); |
---|
108 | } |
---|
109 | |
---|
110 | static void Init(rtems_task_argument arg) |
---|
111 | { |
---|
112 | checkpoint(3); |
---|
113 | test_stack_config(); |
---|
114 | TEST_END(); |
---|
115 | rtems_test_exit(0); |
---|
116 | } |
---|
117 | |
---|
118 | #ifdef BSP_INTERRUPT_STACK_SIZE |
---|
119 | #warning "BSP_INTERRUPT_STACK_SIZE will be #undef for this test" |
---|
120 | #undef BSP_INTERRUPT_STACK_SIZE |
---|
121 | #endif |
---|
122 | |
---|
123 | #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS |
---|
124 | #warning "CONFIGURE_BSP_PREREQUISITE_DRIVERS will be #undef for this test" |
---|
125 | #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS |
---|
126 | #endif |
---|
127 | |
---|
128 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
129 | |
---|
130 | #define CONFIGURE_BSP_PREREQUISITE_DRIVERS \ |
---|
131 | { bsp_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL } |
---|
132 | |
---|
133 | #define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \ |
---|
134 | { app_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL } |
---|
135 | |
---|
136 | #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER |
---|
137 | |
---|
138 | #define CONFIGURE_APPLICATION_EXTRA_DRIVERS \ |
---|
139 | { app_extra_drivers_init, NULL, NULL, NULL, NULL, NULL } |
---|
140 | |
---|
141 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
142 | |
---|
143 | #define CONFIGURE_MINIMUM_TASK_STACK_SIZE (2 * CPU_STACK_MINIMUM_SIZE) |
---|
144 | |
---|
145 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
146 | |
---|
147 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
148 | |
---|
149 | #define CONFIGURE_INIT |
---|
150 | |
---|
151 | #include <rtems/confdefs.h> |
---|