source: rtems/testsuites/psxtests/psxfatal_support/init.c @ 9a4eca5

5
Last change on this file since 9a4eca5 was 24d0ee57, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 08:39:50

cpukit, testsuite: Add rtems_printf and rtems_printer support.

This change adds rtems_printf and related functions and wraps the
RTEMS print plugin support into a user API. All references to the
plugin are removed and replaced with the rtems_printer interface.

Printk and related functions are made to return a valid number of
characters formatted and output.

The function attribute to check printf functions has been added
to rtems_printf and printk. No changes to remove warrnings are part
of this patch set.

The testsuite has been moved over to the rtems_printer. The testsuite
has a mix of rtems_printer access and direct print control via the
tmacros.h header file. The support for begink/endk has been removed
as it served no purpose and only confused the code base. The testsuite
has not been refactored to use rtems_printf. This is future work.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2010.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define TESTS_USE_PRINTK
15#include "tmacros.h"
16
17#define CONFIGURE_INIT
18#include "system.h"
19
20const char rtems_test_name[] = "PSXFATAL " FATAL_ERROR_TEST_NAME;
21
22static void print_test_begin_message(void)
23{
24  static bool done = false;
25
26  if (!done) {
27    done = true;
28    TEST_BEGIN();
29  }
30}
31
32void *POSIX_Init(
33  void *argument
34)
35{
36  print_test_begin_message();
37  force_error();
38  printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION );
39  rtems_test_exit(0);
40}
41
42void Put_Error( uint32_t source, uint32_t error )
43{
44  if ( source == INTERNAL_ERROR_CORE ) {
45    printk( rtems_internal_error_text( error ) );
46  }
47  else if (source == INTERNAL_ERROR_RTEMS_API ){
48    if (error >  RTEMS_NOT_IMPLEMENTED )
49      printk("Unknown Internal Rtems Error (%d)", error);
50    else
51      printk( "%s", rtems_status_text( error ) );
52  }
53  else if (source == INTERNAL_ERROR_POSIX_API ) {
54      printk( "SOURCE=%d ERROR=%d %s", source, error, strerror( error ) );
55  }
56}
57
58void Put_Source( rtems_fatal_source source )
59{
60  printk( "%s", rtems_fatal_source_text( source ) );
61}
62
63void Fatal_extension(
64  rtems_fatal_source source,
65  bool               is_internal,
66  rtems_fatal_code   error
67)
68{
69  print_test_begin_message();
70  printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
71
72  if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
73    printk( "ERROR==> Fatal Extension source Expected (");
74    Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
75    printk( ") received (");
76    Put_Source( source );
77    printk( ")\n" );
78  }
79
80  if ( is_internal !=  FATAL_ERROR_EXPECTED_IS_INTERNAL )
81  {
82    if ( is_internal == TRUE )
83      printk( "ERROR==> Fatal Extension is internal set to TRUE expected FALSE\n" );
84    else
85      printk( "ERROR==> Fatal Extension is internal set to FALSE expected TRUE\n" );
86  }
87
88  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
89    printk( "ERROR==> Fatal Error Expected (");
90    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
91    printk( ") received (");
92    Put_Error( source, error );
93    printk( ")\n" );
94  }
95
96  if (
97    source == FATAL_ERROR_EXPECTED_SOURCE
98      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
99      && error == FATAL_ERROR_EXPECTED_ERROR
100  ) {
101    TEST_END();
102  }
103}
Note: See TracBrowser for help on using the repository browser.