source: rtems/testsuites/sptests/spinternalerror02/init.c @ de9b7d7

5
Last change on this file since de9b7d7 was de9b7d7, checked in by Sebastian Huber <sebastian.huber@…>, on 06/01/18 at 05:04:45

Add RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE

An invalid heap usage such as a double free is usually a fatal error
since this indicates a use after free. Replace the use of printk() in
free() with a fatal error.

Update #3437.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * Copyright (c) 2012, 2018 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Donierstr. 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.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include "tmacros.h"
20
21#include <rtems.h>
22
23const char rtems_test_name[] = "SPINTERNALERROR 2";
24
25static void test_internal_error_text(void)
26{
27  rtems_fatal_code error = 0;
28  const char *text = NULL;
29  const char *text_last;
30
31  do {
32    text_last = text;
33    text = rtems_internal_error_text( error );
34    ++error;
35    puts( text );
36  } while ( text != text_last );
37
38  rtems_test_assert(
39    error - 3 == INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL
40  );
41}
42
43static void test_fatal_source_text(void)
44{
45  rtems_fatal_source source = 0;
46  const char *text = NULL;
47  const char *text_last;
48
49  do {
50    text_last = text;
51    text = rtems_fatal_source_text( source );
52    ++source;
53    puts( text );
54  } while ( text != text_last );
55
56  rtems_test_assert( source - 3 == RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE );
57}
58
59static void test_status_text(void)
60{
61  rtems_status_code code = 0;
62  const char *text = NULL;
63  const char *text_last;
64
65  do {
66    text_last = text;
67    text = rtems_status_text( code );
68    ++code;
69    puts( text );
70  } while ( text != text_last );
71
72  rtems_test_assert( code - 3 == RTEMS_PROXY_BLOCKING );
73}
74
75static void Init(rtems_task_argument arg)
76{
77  TEST_BEGIN();
78
79  test_internal_error_text();
80  test_fatal_source_text();
81  test_status_text();
82
83  TEST_END();
84
85  rtems_test_exit(0);
86}
87
88#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
89#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
90
91#define CONFIGURE_MAXIMUM_TASKS 1
92
93#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
94
95#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
96
97#define CONFIGURE_INIT
98
99#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.