Changeset bcd0c06c in rtems


Ignore:
Timestamp:
Nov 7, 2017, 9:25:36 PM (19 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
e6df806
Parents:
a6bf052
git-author:
Chris Johns <chrisj@…> (11/07/17 21:25:36)
git-committer:
Chris Johns <chrisj@…> (11/11/17 05:14:59)
Message:

tests: Use rtems_test_begin and rtems_test_end.

Add a tests enum and move all test banner test to the library in libmisc.

Update #3199.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/testsupport/test.h

    ra6bf052 rbcd0c06c  
    5959
    6060/**
    61  * @brief Begin of test message format string.
    62  */
    63 #define TEST_BEGIN_STRING "\n\n*** BEGIN OF TEST %s ***\n", rtems_test_name
    64 
    65 /**
    66  * @brief End of test message format string.
    67  */
    68 #define TEST_END_STRING "*** END OF TEST %s ***\n", rtems_test_name
     61 * @brief Test states.
     62 */
     63typedef enum
     64{
     65  RTEMS_TEST_STATE_PASS,
     66  RTEMS_TEST_STATE_FAIL,
     67  RTEMS_TEST_STATE_USER_INPUT,
     68  RTEMS_TEST_STATE_INDETERMINATE,
     69  RTEMS_TEST_STATE_BENCHMARK
     70} RTEMS_TEST_STATE;
     71
     72#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
     73    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
     74    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
     75    (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
     76    (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
     77    (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
     78  #error Test states must be unique
     79#endif
     80
     81#if TEST_STATE_EXPECTED_FAIL
     82  #define TEST_STATE RTEMS_TEST_STATE_FAIL
     83#elif TEST_STATE_USER_INPUT
     84  #define TEST_STATE RTEMS_TEST_STATE_USER_INPUT
     85#elif TEST_STATE_INDETERMINATE
     86  #define TEST_STATE RTEMS_TEST_STATE_INDETERMINATE
     87#elif TEST_STATE_BENCHMARK
     88  #define TEST_STATE RTEMS_TEST_STATE_BENCHMARK
     89#else
     90  #define TEST_STATE RTEMS_TEST_STATE_PASS
     91#endif
    6992
    7093/**
     
    7396 * @returns As specified by printf().
    7497 */
    75 int rtems_test_begin(void);
     98int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state);
    7699
    77100/**
     
    80103 * @returns As specified by printf().
    81104 */
    82 int rtems_test_end(void);
     105int rtems_test_end(const char* name);
    83106
    84107/**
  • cpukit/libmisc/testsupport/testbeginend.c

    ra6bf052 rbcd0c06c  
    77 *  Germany
    88 *  <rtems@embedded-brains.de>
     9 *
     10 * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved.
    911 *
    1012 * The license and distribution terms for this file may be
     
    1921#include <rtems/test.h>
    2022#include <rtems/bspIo.h>
     23#include <rtems/version.h>
     24
     25#define TEST_BUILD_DEFAULT "default"
     26#if RTEMS_POSIX
     27  #define TEST_BUILD_DEFAULT ""
     28  #define TEST_BUILD_POSIX   "posix "
     29#else
     30  #define TEST_BUILD_POSIX
     31#endif
     32#if RTEMS_SMP
     33  #define TEST_BUILD_DEFAULT ""
     34  #define TEST_BUILD_SMP     "smp "
     35#else
     36  #define TEST_BUILD_SMP
     37#endif
     38#if RTEMS_MULTIPROCESSING
     39  #define TEST_BUILD_DEFAULT ""
     40  #define TEST_BUILD_MP      "mp "
     41#else
     42  #define TEST_BUILD_MP
     43#endif
     44#if RTEMS_PARAVIRT
     45  #define TEST_BUILD_DEFAULT  ""
     46  #define TEST_BUILD_PARAVIRT "paravirt "
     47#else
     48  #define TEST_BUILD_PARAVIRT
     49#endif
     50#if RTEMS_NETWORKING
     51  #define TEST_BUILD_DEFAULT    ""
     52  #define TEST_BUILD_NETWORKING "legacy-net "
     53#else
     54  #define TEST_BUILD_NETWORKING
     55#endif
     56#if RTEMS_DEBUG
     57  #define TEST_BUILD_DEFAULT ""
     58  #define TEST_BUILD_DEBUG   "debug "
     59#else
     60  #define TEST_BUILD_DEBUG
     61#endif
     62#if RTEMS_PROFILING
     63  #define TEST_BUILD_DEFAULT   ""
     64  #define TEST_BUILD_PROFILING "profiling "
     65#else
     66  #define TEST_BUILD_PROFILING
     67#endif
     68
     69#define TEST_BUILD_STRING \
     70         TEST_BUILD_DEFAULT \
     71         TEST_BUILD_POSIX \
     72         TEST_BUILD_SMP \
     73         TEST_BUILD_MP \
     74         TEST_BUILD_PARAVIRT \
     75         TEST_BUILD_NETWORKING \
     76         TEST_BUILD_DEBUG \
     77         TEST_BUILD_PROFILING
    2178
    2279rtems_printer rtems_test_printer = {
     
    2481};
    2582
    26 int rtems_test_begin(void)
     83static const char* const test_state_strings[] =
     84{
     85  "EXPECTED-PASS",
     86  "EXPECTED-FAIL",
     87  "USER_INPUT",
     88  "INDETERMINATE",
     89  "BENCHMARK"
     90};
     91
     92int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state)
     93{
     94  int l;
     95  l = rtems_printf(
     96    &rtems_test_printer,
     97    "\n\n*** BEGIN OF TEST %s ***\n", name
     98  );
     99  l += rtems_printf(
     100    &rtems_test_printer,
     101    "*** TEST VERSION: %s\n", rtems_version()
     102  );
     103  l += rtems_printf(
     104    &rtems_test_printer,
     105    "*** TEST STATE: %s\n", test_state_strings[state]
     106  );
     107  l += rtems_printf(
     108    &rtems_test_printer,
     109    "*** TEST BUILD: %s\n", TEST_BUILD_STRING
     110  );
     111  l += rtems_printf(
     112    &rtems_test_printer,
     113    "*** TEST TOOLS: " __VERSION__ "\n"
     114  );
     115  return l;
     116}
     117
     118int rtems_test_end(const char* name)
    27119{
    28120  return rtems_printf(
    29121    &rtems_test_printer,
    30     TEST_BEGIN_STRING
    31   );
    32 }
    33 
    34 int rtems_test_end(void)
    35 {
    36   return rtems_printf(
    37     &rtems_test_printer,
    38     TEST_END_STRING
     122    "\n*** END OF TEST %s ***\n\n", name
    39123  );
    40124}
  • testsuites/samples/cdtest/main.cc

    ra6bf052 rbcd0c06c  
    4848{
    4949  if ( num_inst == 0 ) {
    50     printf(TEST_BEGIN_STRING);
     50    TEST_BEGIN();
    5151  }
    5252}
     
    5555{
    5656  if ( num_inst == 0 ) {
    57     printk(TEST_END_STRING);
     57    TEST_END();
    5858  }
    5959}
  • testsuites/sptests/sp20/init.c

    ra6bf052 rbcd0c06c  
    3939void end_of_test( void )
    4040{
    41   rtems_test_printf( TEST_END_STRING );
     41  TEST_END();
    4242  rtems_printer_task_drain( &printer_task );
    4343  rtems_test_exit( 0 );
     
    6060  rtems_test_assert( error == 0 );
    6161
    62   rtems_test_printf( TEST_BEGIN_STRING );
     62  TEST_BEGIN();
    6363
    6464  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '1', ' ' );
  • testsuites/support/include/buffer_test_io.h

    ra6bf052 rbcd0c06c  
    1010#ifdef __cplusplus
    1111extern "C" {
    12 #endif
    13 
    14 /*
    15  * Test states. No state string is an expected pass.
    16  */
    17 #if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
    18     (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
    19     (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
    20     (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
    21     (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
    22     (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
    23   #error Test states must be unique
    24 #endif
    25 
    26 #if TEST_STATE_EXPECTED_FAIL
    27   #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-FAIL\n"
    28 #elif TEST_STATE_USER_INPUT
    29   #define TEST_STATE_STRING "*** TEST STATE: USER_INPUT\n"
    30 #elif TEST_STATE_INDETERMINATE
    31   #define TEST_STATE_STRING "*** TEST STATE: INDETERMINATE\n"
    32 #elif TEST_STATE_BENCHMARK
    33   #define TEST_STATE_STRING "*** TEST STATE: BENCHMARK\n"
    3412#endif
    3513
     
    6240  } while (0)
    6341
    64 #if defined(TEST_STATE_STRING)
    65   #define TEST_BEGIN() \
    66   do { \
    67     rtems_printf( &rtems_test_printer, "\n"); \
    68     rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
    69     rtems_printf( &rtems_test_printer, TEST_STATE_STRING ); \
    70   } while (0)
    71 #else
    72   #define TEST_BEGIN() \
    73   do { \
    74     rtems_printf( &rtems_test_printer, "\n" ); \
    75     rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
    76   } while (0)
    77 #endif
    78 
    79 #define TEST_END() \
    80   do { \
    81      rtems_printf( &rtems_test_printer, "\n" ); \
    82      rtems_printf( &rtems_test_printer, TEST_END_STRING ); \
    83      rtems_printf( &rtems_test_printer, "\n" ); \
    84   } while (0)
     42#define TEST_BEGIN() rtems_test_begin(rtems_test_name, TEST_STATE)
     43#define TEST_END()   rtems_test_end(rtems_test_name)
    8544
    8645#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.