Changeset 68f36d14 in rtems


Ignore:
Timestamp:
Jan 27, 2013, 1:02:50 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7571a23
Parents:
77ac578
git-author:
Sebastian Huber <sebastian.huber@…> (01/27/13 13:02:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/12/13 08:31:27)
Message:

score: Add and use rtems_assert_context

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/__assert.c

    r77ac578 r68f36d14  
    3535)
    3636{
     37  rtems_assert_context assert_context = {
     38    .file = file,
     39    .line = line,
     40    .function = func,
     41    .failed_expression = failedexpr
     42  };
     43
    3744  printk("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
    3845    failedexpr,
     
    4249    (func) ? func : ""
    4350  );
    44   rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, (rtems_fatal_code) func );
     51  rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, (rtems_fatal_code) &assert_context );
    4552}
    4653#endif
  • cpukit/sapi/include/rtems/fatal.h

    r77ac578 r68f36d14  
    3333 */
    3434/**@{**/
     35
     36/**
     37 * @brief Assert context.
     38 */
     39typedef struct {
     40  const char *file;
     41  int         line;
     42  const char *function;
     43  const char *failed_expression;
     44} rtems_assert_context;
    3545
    3646/**
  • cpukit/score/include/rtems/score/interr.h

    r77ac578 r68f36d14  
    8989   * @brief Fatal source of assert().
    9090   *
    91    * The fatal code is the pointer value of the function string.
     91   * The fatal code is the pointer value of the assert context.
     92   *
     93   * @see rtems_assert_context.
    9294   */
    9395  RTEMS_FATAL_SOURCE_ASSERT,
  • testsuites/sptests/spfatal10/testcase.h

    r77ac578 r68f36d14  
    1010
    1111#include <assert.h>
    12 
    13 static const char func [] = "Init";
     12#include <string.h>
    1413
    1514#define FATAL_ERROR_TEST_NAME            "10"
     
    1716#define FATAL_ERROR_EXPECTED_SOURCE      RTEMS_FATAL_SOURCE_ASSERT
    1817#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
    19 #define FATAL_ERROR_EXPECTED_ERROR       ((rtems_fatal_code) func)
     18#define FATAL_ERROR_EXPECTED_ERROR_CHECK spfatal10_is_expected_error
     19
     20#define ASSERT_FILE "testcase.h"
     21#define ASSERT_LINE 38
     22#define ASSERT_FUNC "Init"
     23#define ASSERT_FEXP "forced"
     24
     25static inline bool spfatal10_is_expected_error( rtems_fatal_code error )
     26{
     27  const rtems_assert_context *assert_context =
     28    (const rtems_assert_context *) error;
     29
     30  return strcmp( assert_context->file, ASSERT_FILE ) == 0
     31    && assert_context->line == ASSERT_LINE
     32    && strcmp( assert_context->function, ASSERT_FUNC ) == 0
     33    && strcmp( assert_context->failed_expression, ASSERT_FEXP ) == 0;
     34}
    2035
    2136void force_error()
    2237{
    23   __assert_func( __FILE__, __LINE__, func, "forced" );
     38  __assert_func( ASSERT_FILE, ASSERT_LINE, ASSERT_FUNC, ASSERT_FEXP );
    2439
    2540  /* we will not run this far */
  • testsuites/sptests/spfatal_support/init.c

    r77ac578 r68f36d14  
    8181}
    8282
     83static bool is_expected_error( rtems_fatal_code error )
     84{
     85#ifdef FATAL_ERROR_EXPECTED_ERROR
     86  return error == FATAL_ERROR_EXPECTED_ERROR;
     87#else /* FATAL_ERROR_EXPECTED_ERROR */
     88  return FATAL_ERROR_EXPECTED_ERROR_CHECK( error );
     89#endif /* FATAL_ERROR_EXPECTED_ERROR */
     90}
     91
    8392void Fatal_extension(
    8493  rtems_fatal_source source,
     
    110119  }
    111120
     121#ifdef FATAL_ERROR_EXPECTED_ERROR
    112122  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
    113123    printk( "ERROR==> Fatal Error Expected (");
     
    117127    printk( ")\n" );
    118128  }
     129#endif /* FATAL_ERROR_EXPECTED_ERROR */
    119130
    120131  if (
    121132    source == FATAL_ERROR_EXPECTED_SOURCE
    122133      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
    123       && error == FATAL_ERROR_EXPECTED_ERROR
     134      && is_expected_error( error )
    124135  ) {
    125136    printk( "*** END OF TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
Note: See TracChangeset for help on using the changeset viewer.