Changeset d07d6498 in rtems


Ignore:
Timestamp:
07/01/22 07:00:51 (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
857fb17
Parents:
c15842d
git-author:
Sebastian Huber <sebastian.huber@…> (07/01/22 07:00:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/04/22 06:09:48)
Message:

samples/cdtest: Test exceptions during system init

Update #4668.
Update #4672.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/samples/cdtest/main.cc

    rc15842d rd07d6498  
    2626#include <rtems/bspIo.h>
    2727#include <rtems/test-info.h>
     28#include <rtems/sysinit.h>
    2829
    2930#include <cstdio>
    3031#include <cstdlib>
     32#include <cstring>
    3133#include <stdexcept>
    3234
     
    4547static int num_inst = 0;
    4648
    47 static void check_begin_of_test(void)
    48 {
    49   if ( num_inst == 0 ) {
    50     TEST_BEGIN();
    51   }
    52 }
    53 
    5449static void check_end_of_test(void)
    5550{
     
    6358  AClass(const char *p = "LOCAL" ) : ptr( p )
    6459    {
    65         check_begin_of_test();
    6660        num_inst++;
    6761        printf(
     
    10599  BClass(const char *p = "LOCAL" ) : AClass( p )
    106100    {
    107         check_begin_of_test();
    108101        num_inst++;
    109102        printf(
     
    245238    exit(0);
    246239}
     240
     241static void early_exception()
     242{
     243    try
     244    {
     245      throw "early exception";
     246    }
     247    catch( const char *e )
     248    {
     249      rtems_test_assert(strcmp(e, "early exception") == 0);
     250      throw "early exception 2";
     251    }
     252}
     253
     254static void test_exceptions_during_system_init()
     255{
     256    TEST_BEGIN();
     257
     258    try
     259    {
     260      early_exception();
     261    }
     262    catch( const char *e )
     263    {
     264      rtems_test_assert(strcmp(e, "early exception 2") == 0);
     265    }
     266}
     267
     268RTEMS_SYSINIT_ITEM(
     269    test_exceptions_during_system_init,
     270    RTEMS_SYSINIT_IDLE_THREADS,
     271    RTEMS_SYSINIT_ORDER_LAST
     272);
Note: See TracChangeset for help on using the changeset viewer.