Ignore:
Timestamp:
Dec 20, 2015, 8:47:12 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
d5154d0f
Parents:
34a2ec92
git-author:
Sebastian Huber <sebastian.huber@…> (12/20/15 20:47:12)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/21/15 07:32:20)
Message:

score: Fix watchdog removal

Under certain conditions a new watchdog was inserted with a wrong and
very large delta interval due to an incomplete iterator update.

Bug was introduced by 1ccbd052910ed16131c74b0d5595c8a94066942d.

Close #2501.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spwatchdog/init.c

    r34a2ec92 ra48b7c44  
    3737static void init_watchdogs(
    3838  Watchdog_Header *header,
    39   Watchdog_Control watchdogs[3]
     39  Watchdog_Control watchdogs[4]
    4040)
    4141{
     
    106106  /* Remove next watchdog of iterator */
    107107  _Watchdog_Remove( &header, c );
    108   rtems_test_assert( i.delta_interval == 2 );
     108  rtems_test_assert( i.delta_interval == 4 );
    109109  rtems_test_assert( i.current == &b->Node );
    110110
    111111  /* Remove watchdog before the current watchdog of iterator */
    112112  _Watchdog_Remove( &header, a );
    113   rtems_test_assert( i.delta_interval == 4 );
     113  rtems_test_assert( i.delta_interval == 6 );
    114114  rtems_test_assert( i.current == &b->Node );
    115115
    116116  /* Remove current (= last) watchdog of iterator */
    117117  _Watchdog_Remove( &header, b );
    118   rtems_test_assert( i.delta_interval == 4 );
     118  rtems_test_assert( i.delta_interval == 6 );
    119119  rtems_test_assert( i.current == _Chain_Head( &header.Watchdogs ) );
    120120
     
    122122  a->initial = 1;
    123123  _Watchdog_Insert( &header, a );
    124   rtems_test_assert( i.delta_interval == 4 );
     124  rtems_test_assert( i.delta_interval == 6 );
    125125  rtems_test_assert( i.current == _Chain_Head( &header.Watchdogs ) );
    126126
     
    144144  rtems_test_assert( i.delta_interval == 2 );
    145145  rtems_test_assert( i.current == &b->Node );
     146
     147  destroy_watchdogs( &header );
     148}
     149
     150static void init_watchdogs_remove_second_and_insert_first(
     151  Watchdog_Header *header,
     152  Watchdog_Control watchdogs[3]
     153)
     154{
     155  Watchdog_Control *a = &watchdogs[0];
     156  Watchdog_Control *b = &watchdogs[1];
     157  Watchdog_Control *c = &watchdogs[2];
     158
     159  _Watchdog_Preinitialize( a );
     160  _Watchdog_Preinitialize( b );
     161  _Watchdog_Preinitialize( c );
     162
     163  _Watchdog_Header_initialize( header );
     164
     165  a->initial = 6;
     166  _Watchdog_Insert( header, a );
     167  rtems_test_assert( a->delta_interval == 6 );
     168
     169  b->initial = 8;
     170  _Watchdog_Insert( header, b );
     171  rtems_test_assert( a->delta_interval == 6 );
     172  rtems_test_assert( b->delta_interval == 2 );
     173}
     174
     175static void test_watchdog_remove_second_and_insert_first( void )
     176{
     177  Watchdog_Header header;
     178  Watchdog_Control watchdogs[3];
     179  Watchdog_Control *a = &watchdogs[0];
     180  Watchdog_Control *b = &watchdogs[1];
     181  Watchdog_Control *c = &watchdogs[2];
     182  Watchdog_Iterator i;
     183
     184  init_watchdogs_remove_second_and_insert_first( &header, watchdogs );
     185  add_iterator( &header, &i, b );
     186
     187  _Watchdog_Remove( &header, b );
     188  rtems_test_assert( i.delta_interval == 8 );
     189  rtems_test_assert( i.current == &a->Node );
     190
     191  c->initial = 4;
     192  _Watchdog_Insert( &header, c );
     193  rtems_test_assert( a->delta_interval == 2 );
     194  rtems_test_assert( c->delta_interval == 4 );
     195  rtems_test_assert( i.delta_interval == 4 );
     196  rtems_test_assert( i.current == &a->Node );
    146197
    147198  destroy_watchdogs( &header );
     
    185236  test_watchdog_static_init();
    186237  test_watchdog_insert_and_remove();
     238  test_watchdog_remove_second_and_insert_first();
    187239
    188240  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
Note: See TracChangeset for help on using the changeset viewer.