source: rtems/testsuites/libtests/stackchk/init.c

Last change on this file was acceb47, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:24:13

testsuites/libtests/[p-z]*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[acceb47]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 *
[08311cc3]16 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]17 *  On-Line Applications Research Corporation (OAR).
18 *
[acceb47]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
[5a8e7503]45#define CONFIGURE_INIT
[3a4ae6c]46#include "system.h"
[ac7d5ef0]47
[5d1d348]48#include <rtems/bspIo.h>
49
[f8b2eb03]50const char rtems_test_name[] = "STACKCHK";
51
[ac7d5ef0]52rtems_task Init(
53  rtems_task_argument argument
54)
55{
56  rtems_time_of_day time;
57  rtems_status_code status;
58
[f8b2eb03]59  TEST_BEGIN();
[ac7d5ef0]60
61  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
62  status = rtems_clock_set( &time );
63  directive_failed( status, "rtems_clock_set" );
64
65  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
66  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
67  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
68
69  status = rtems_task_create(
70     Task_name[ 1 ],
71     1,
72     TASK_STACK_SIZE,
73     RTEMS_DEFAULT_MODES,
74     RTEMS_DEFAULT_ATTRIBUTES,
75     &Task_id[ 1 ]
76  );
77  directive_failed( status, "rtems_task_create of TA1" );
78
79  status = rtems_task_create(
80     Task_name[ 2 ],
81     1,
82     TASK_STACK_SIZE,
83     RTEMS_DEFAULT_MODES,
84     RTEMS_DEFAULT_ATTRIBUTES,
85     &Task_id[ 2 ]
86  );
87  directive_failed( status, "rtems_task_create of TA2" );
88
89  status = rtems_task_create(
90     Task_name[ 3 ],
91     1,
92     TASK_STACK_SIZE,
93     RTEMS_DEFAULT_MODES,
94     RTEMS_DEFAULT_ATTRIBUTES,
95     &Task_id[ 3 ]
96  );
97  directive_failed( status, "rtems_task_create of TA3" );
98
99  status = rtems_task_start( Task_id[ 1 ], Task_1_through_3, 0 );
100  directive_failed( status, "rtems_task_start of TA1" );
101
102  status = rtems_task_start( Task_id[ 2 ], Task_1_through_3, 0 );
103  directive_failed( status, "rtems_task_start of TA2" );
104
105  status = rtems_task_start( Task_id[ 3 ], Task_1_through_3, 0 );
106  directive_failed( status, "rtems_task_start of TA3" );
107
[51b3cbca]108  rtems_task_exit();
[ac7d5ef0]109}
[63f871f]110
[33bd2efb]111void Fatal_extension(
112  rtems_fatal_source source,
[6a9282d]113  bool               always_set_to_false,
[33bd2efb]114  rtems_fatal_code   error
115)
[63f871f]116{
[a12f7e9]117  if ( source != RTEMS_FATAL_SOURCE_STACK_CHECKER ) {
[63f871f]118    printk( "unexpected fatal source\n" );
[6a9282d]119  } else if ( always_set_to_false ) {
[63f871f]120    printk( "unexpected fatal is internal\n" );
[a12f7e9]121  } else if ( error != rtems_build_name( 'T', 'A', '1', ' ' ) ) {
[63f871f]122    printk( "unexpected fatal error\n" );
123  } else {
[24d0ee57]124    TEST_END();
[63f871f]125  }
126}
Note: See TracBrowser for help on using the repository browser.