source: rtems/testsuites/sptests/sp12/init.c

Last change on this file was eb57966, checked in by Joel Sherrill <joel@…>, on 03/31/22 at 21:32:14

testsuites/sptests/sp1*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 6.4 KB
RevLine 
[eb57966]1/* SPDX-License-Identifier: BSD-2-Clause */
2
[ac7d5ef0]3/*  Init
4 *
5 *  This routine is the initialization task for this test program.
6 *  It is a user initialization task and has the responsibility for creating
7 *  and starting the tasks that make up the test.  If the time of day
8 *  clock is required for the test, it should also be set to a known
9 *  value by this function.
10 *
11 *  Input parameters:
12 *    argument - task argument
13 *
14 *  Output parameters:  NONE
15 *
[b84f1fdc]16 *  COPYRIGHT (c) 1989-2009.
[ac7d5ef0]17 *  On-Line Applications Research Corporation (OAR).
18 *
[eb57966]19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 * 1. Redistributions of source code must retain the above copyright
23 *    notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 *    notice, this list of conditions and the following disclaimer in the
26 *    documentation and/or other materials provided with the distribution.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
[ac7d5ef0]39 */
40
[7d3f9c6]41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
[2186ba80]45#define CONFIGURE_INIT
[ac7d5ef0]46#include "system.h"
47
[6c0301d]48const char rtems_test_name[] = "SP 12";
49
[ac7d5ef0]50rtems_task Init(
51  rtems_task_argument argument
52)
53{
54  rtems_status_code status;
55
[6c0301d]56  TEST_BEGIN();
[ac7d5ef0]57
58  Task_name[ 1 ]          = rtems_build_name( 'T', 'A', '1', ' ' );
59  Task_name[ 2 ]          = rtems_build_name( 'T', 'A', '2', ' ' );
60  Task_name[ 3 ]          = rtems_build_name( 'T', 'A', '3', ' ' );
61  Task_name[ 4 ]          = rtems_build_name( 'T', 'A', '4', ' ' );
62  Task_name[ 5 ]          = rtems_build_name( 'T', 'A', '5', ' ' );
63
64  Priority_task_name[ 1 ] = rtems_build_name( 'P', 'R', 'I', '1' );
65  Priority_task_name[ 2 ] = rtems_build_name( 'P', 'R', 'I', '2' );
66  Priority_task_name[ 3 ] = rtems_build_name( 'P', 'R', 'I', '3' );
67  Priority_task_name[ 4 ] = rtems_build_name( 'P', 'R', 'I', '4' );
68  Priority_task_name[ 5 ] = rtems_build_name( 'P', 'R', 'I', '5' );
69
70  Semaphore_name[ 1 ]     = rtems_build_name( 'S', 'M', '1', ' ' );
71  Semaphore_name[ 2 ]     = rtems_build_name( 'S', 'M', '2', ' ' );
72  Semaphore_name[ 3 ]     = rtems_build_name( 'S', 'M', '3', ' ' );
73
74  status = rtems_semaphore_create(
[7f6a24ab]75    Semaphore_name[ 1 ],
76    1,
77    RTEMS_DEFAULT_ATTRIBUTES,
78    RTEMS_NO_PRIORITY,
79    &Semaphore_id[ 1 ]
[ac7d5ef0]80  );
81  directive_failed( status, "rtems_semaphore_create of SM1" );
82
83  status = rtems_semaphore_create(
84    Semaphore_name[ 2 ],
85    0,
86    RTEMS_PRIORITY,
[7f6a24ab]87    RTEMS_NO_PRIORITY,
[ac7d5ef0]88    &Semaphore_id[ 2 ]
89  );
90  directive_failed( status, "rtems_semaphore_create of SM2" );
91
92  status = rtems_semaphore_create(
93    Semaphore_name[ 3 ],
94    1,
[46c23871]95    RTEMS_GLOBAL,
[7f6a24ab]96    RTEMS_NO_PRIORITY,
[ac7d5ef0]97    &Semaphore_id[ 3 ]
98  );
99  directive_failed( status, "rtems_semaphore_create of SM3" );
100
101  puts( "INIT - Forward priority queue test" );
102  Priority_test_driver( 0 );
103
104  puts( "INIT - Backward priority queue test" );
[b84f1fdc]105  Priority_test_driver( (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u );
[ac7d5ef0]106
107  puts( "INIT - Binary Semaphore and Priority Inheritance Test" );
108
109  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
[a986c075]110  directive_failed( status, "rtems_semaphore_delete of SM2 #1" );
[ac7d5ef0]111
112  puts( "INIT - rtems_semaphore_create - allocated binary semaphore" );
113  status = rtems_semaphore_create(
114    Semaphore_name[ 2 ],
115    0,
116    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
[7f6a24ab]117    RTEMS_NO_PRIORITY,
[ac7d5ef0]118    &Semaphore_id[ 2 ]
119  );
120  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
121
122  puts( "INIT - rtems_semaphore_release - allocated binary semaphore" );
123  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
124  directive_failed( status, "rtems_semaphore_release of SM2" );
125
126  puts( "INIT - rtems_semaphore_delete - allocated binary semaphore" );
127  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
[a986c075]128  directive_failed( status, "rtems_semaphore_delete of SM2 #2" );
[ac7d5ef0]129
130  status = rtems_semaphore_create(
131    Semaphore_name[ 2 ],
132    1,
133    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
[7f6a24ab]134    RTEMS_NO_PRIORITY,
[ac7d5ef0]135    &Semaphore_id[ 2 ]
136  );
137  directive_failed( status, "rtems_semaphore_create of priority inherit SM2" );
138
[a986c075]139  Priority_test_driver( PRIORITY_INHERIT_BASE_PRIORITY );
[ac7d5ef0]140
141  status = rtems_semaphore_delete( Semaphore_id[ 2 ] );
[a986c075]142  directive_failed( status, "rtems_semaphore_delete of SM2 #3" );
[ac7d5ef0]143
144  status = rtems_semaphore_create(
145    Semaphore_name[ 2 ],
146    0,
147    RTEMS_PRIORITY,
[7f6a24ab]148    RTEMS_NO_PRIORITY,
[ac7d5ef0]149    &Semaphore_id[ 2 ]
150  );
151  directive_failed( status, "rtems_semaphore_create of priority SM2" );
152
153  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
154  directive_failed( status, "rtems_semaphore_release of SM2" );
155
156  status = rtems_task_create(
157    Task_name[ 1 ],
158    4,
[709b93d]159    RTEMS_MINIMUM_STACK_SIZE * 2,
[ac7d5ef0]160    RTEMS_DEFAULT_MODES,
161    RTEMS_DEFAULT_ATTRIBUTES,
162    &Task_id[ 1 ]
163  );
164  directive_failed( status, "rtems_task_create of TA1" );
165
166  status = rtems_task_create(
167    Task_name[ 2 ],
168    4,
[3652ad35]169    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]170    RTEMS_DEFAULT_MODES,
171    RTEMS_DEFAULT_ATTRIBUTES,
172    &Task_id[ 2 ]
173  );
174  directive_failed( status, "rtems_task_create of TA2" );
175
176  status = rtems_task_create(
177    Task_name[ 3 ],
178    4,
[3652ad35]179    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]180    RTEMS_DEFAULT_MODES,
181    RTEMS_DEFAULT_ATTRIBUTES,
182    &Task_id[ 3 ]
183  );
184  directive_failed( status, "rtems_task_create of TA3" );
185
186  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
187  directive_failed( status, "rtems_task_start of TA1" );
188
189  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
190  directive_failed( status, "rtems_task_start of TA2" );
191
192  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
193  directive_failed( status, "rtems_task_start of TA3" );
194
[51b3cbca]195  rtems_task_exit();
[ac7d5ef0]196}
Note: See TracBrowser for help on using the repository browser.