Index: c/src/tests/sptests/ChangeLog
===================================================================
--- c/src/tests/sptests/ChangeLog	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ c/src/tests/sptests/ChangeLog	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -1,2 +1,11 @@
+2001-01-29	Joel Sherrill <joel@OARcorp.com>
+
+	* Fixed bug where resetting a timer that was not at the head
+	of one of the task timer chains resulted in the Timer Server
+	task waking up too far in the future.
+	* Added rtems_timer_get_information() directive to support testing.
+	* sp31/init.c, sp31/system.h, sp31/task1.c: Modified to test for
+	above condition.
+
 2001-01-22	Joel Sherrill <joel@OARcorp.com>
 
Index: c/src/tests/sptests/sp31/init.c
===================================================================
--- c/src/tests/sptests/sp31/init.c	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ c/src/tests/sptests/sp31/init.c	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -48,4 +48,5 @@
   Task_name[ 1 ]  = rtems_build_name( 'T', 'A', '1', ' ' );
   Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' );
+  Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' );
 
   status = rtems_task_create(
@@ -65,6 +66,10 @@
   status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
   directive_failed( status, "rtems_timer_create" );
+  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
 
-  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
+  puts( "INIT - rtems_timer_create - creating timer 2" );
+  status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
+  directive_failed( status, "rtems_timer_create" );
+  printf( "INIT - timer 2 has id (0x%x)\n", Timer_id[ 2 ] );
 
   status = rtems_task_delete( RTEMS_SELF );
Index: c/src/tests/sptests/sp31/system.h
===================================================================
--- c/src/tests/sptests/sp31/system.h	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ c/src/tests/sptests/sp31/system.h	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -53,6 +53,6 @@
 TEST_EXTERN rtems_name Task_name[ 4 ];       /* array of task names */
 
-TEST_EXTERN rtems_id   Timer_id[ 2 ];    /* array of timer ids */
-TEST_EXTERN rtems_name Timer_name[ 2 ];  /* array of timer names */
+TEST_EXTERN rtems_id   Timer_id[ 3 ];    /* array of timer ids */
+TEST_EXTERN rtems_name Timer_name[ 3 ];  /* array of timer names */
 
 /* end of include file */
Index: c/src/tests/sptests/sp31/task1.c
===================================================================
--- c/src/tests/sptests/sp31/task1.c	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ c/src/tests/sptests/sp31/task1.c	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -25,7 +25,9 @@
 )
 {
-  rtems_id          tmid;
-  rtems_time_of_day time;
-  rtems_status_code status;
+  rtems_id                 tmid;
+  rtems_id                 tmid2;
+  rtems_time_of_day        time;
+  rtems_status_code        status;
+  rtems_timer_information  info;
 
 /* Get id */
@@ -35,4 +37,70 @@
   directive_failed( status, "rtems_timer_ident" );
   printf( "TA1 - timer 1 has id (0x%x)\n", tmid );
+
+  puts( "TA1 - rtems_timer_ident - identing timer 2" );
+  status = rtems_timer_ident( Timer_name[ 2 ], &tmid2 );
+  directive_failed( status, "rtems_timer_ident" );
+  printf( "TA1 - timer 2 has id (0x%x)\n", tmid2 );
+
+/* now check that rescheduling an active timer works OK. */
+  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 30 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid, 30 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+
+  puts( "TA1 - rtems_task_wake_after - 1 second" );
+  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
+  directive_failed( status, "rtems_timer_wake_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  directive_failed( status, "rtems_timer_get_information" );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+  assert(  (info.start_time + info.initial) == 
+    (_Timer_Server->Timer.initial + _Timer_Server->Timer.start_time) );
+
+  puts( "TA1 - rtems_task_wake_after - 1 second" );
+  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
+  directive_failed( status, "rtems_timer_wake_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  directive_failed( status, "rtems_timer_get_information" );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+  assert(  (info.start_time + info.initial) == 
+    (_Timer_Server->Timer.initial + _Timer_Server->Timer.start_time) );
+
+  puts( "TA1 - rtems_timer_cancel - timer 1" );
+  status = rtems_timer_cancel( tmid );
+  directive_failed( status, "rtems_timer_cancel" );
+
+  puts( "TA1 - rtems_timer_cancel - timer 2" );
+  status = rtems_timer_cancel( tmid2 );
+  directive_failed( status, "rtems_timer_cancel" );
 
 /* after which is allowed to fire */
Index: testsuites/sptests/ChangeLog
===================================================================
--- testsuites/sptests/ChangeLog	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ testsuites/sptests/ChangeLog	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -1,2 +1,11 @@
+2001-01-29	Joel Sherrill <joel@OARcorp.com>
+
+	* Fixed bug where resetting a timer that was not at the head
+	of one of the task timer chains resulted in the Timer Server
+	task waking up too far in the future.
+	* Added rtems_timer_get_information() directive to support testing.
+	* sp31/init.c, sp31/system.h, sp31/task1.c: Modified to test for
+	above condition.
+
 2001-01-22	Joel Sherrill <joel@OARcorp.com>
 
Index: testsuites/sptests/sp31/init.c
===================================================================
--- testsuites/sptests/sp31/init.c	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ testsuites/sptests/sp31/init.c	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -48,4 +48,5 @@
   Task_name[ 1 ]  = rtems_build_name( 'T', 'A', '1', ' ' );
   Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' );
+  Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' );
 
   status = rtems_task_create(
@@ -65,6 +66,10 @@
   status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
   directive_failed( status, "rtems_timer_create" );
+  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
 
-  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
+  puts( "INIT - rtems_timer_create - creating timer 2" );
+  status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
+  directive_failed( status, "rtems_timer_create" );
+  printf( "INIT - timer 2 has id (0x%x)\n", Timer_id[ 2 ] );
 
   status = rtems_task_delete( RTEMS_SELF );
Index: testsuites/sptests/sp31/system.h
===================================================================
--- testsuites/sptests/sp31/system.h	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ testsuites/sptests/sp31/system.h	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -53,6 +53,6 @@
 TEST_EXTERN rtems_name Task_name[ 4 ];       /* array of task names */
 
-TEST_EXTERN rtems_id   Timer_id[ 2 ];    /* array of timer ids */
-TEST_EXTERN rtems_name Timer_name[ 2 ];  /* array of timer names */
+TEST_EXTERN rtems_id   Timer_id[ 3 ];    /* array of timer ids */
+TEST_EXTERN rtems_name Timer_name[ 3 ];  /* array of timer names */
 
 /* end of include file */
Index: testsuites/sptests/sp31/task1.c
===================================================================
--- testsuites/sptests/sp31/task1.c	(revision a94c2fbba44891cbfbef0baa6c66b6bd604bd550)
+++ testsuites/sptests/sp31/task1.c	(revision ef70d9b652e75326f534d7e66bb3e0bcc55b3b58)
@@ -25,7 +25,9 @@
 )
 {
-  rtems_id          tmid;
-  rtems_time_of_day time;
-  rtems_status_code status;
+  rtems_id                 tmid;
+  rtems_id                 tmid2;
+  rtems_time_of_day        time;
+  rtems_status_code        status;
+  rtems_timer_information  info;
 
 /* Get id */
@@ -35,4 +37,70 @@
   directive_failed( status, "rtems_timer_ident" );
   printf( "TA1 - timer 1 has id (0x%x)\n", tmid );
+
+  puts( "TA1 - rtems_timer_ident - identing timer 2" );
+  status = rtems_timer_ident( Timer_name[ 2 ], &tmid2 );
+  directive_failed( status, "rtems_timer_ident" );
+  printf( "TA1 - timer 2 has id (0x%x)\n", tmid2 );
+
+/* now check that rescheduling an active timer works OK. */
+  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 30 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid, 30 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+
+  puts( "TA1 - rtems_task_wake_after - 1 second" );
+  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
+  directive_failed( status, "rtems_timer_wake_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  directive_failed( status, "rtems_timer_get_information" );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+  assert(  (info.start_time + info.initial) == 
+    (_Timer_Server->Timer.initial + _Timer_Server->Timer.start_time) );
+
+  puts( "TA1 - rtems_task_wake_after - 1 second" );
+  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
+  directive_failed( status, "rtems_timer_wake_after" );
+
+  puts( "TA1 - rtems_timer_server_fire_after - timer 2 in 60 seconds" );
+  status = rtems_timer_server_fire_after(
+    tmid2, 60 * TICKS_PER_SECOND, Delayed_resume, NULL );
+  directive_failed( status, "rtems_timer_server_fire_after" );
+
+  status = rtems_timer_get_information( tmid, &info );
+  directive_failed( status, "rtems_timer_get_information" );
+  printf( "Timer 1 scheduled for %d ticks since boot\n",
+    info.start_time + info.initial );
+  printf( "Timer Server scheduled for %d ticks since boot\n",
+    _Timer_Server->Timer.initial + _Timer_Server->Timer.start_time );
+  assert(  (info.start_time + info.initial) == 
+    (_Timer_Server->Timer.initial + _Timer_Server->Timer.start_time) );
+
+  puts( "TA1 - rtems_timer_cancel - timer 1" );
+  status = rtems_timer_cancel( tmid );
+  directive_failed( status, "rtems_timer_cancel" );
+
+  puts( "TA1 - rtems_timer_cancel - timer 2" );
+  status = rtems_timer_cancel( tmid2 );
+  directive_failed( status, "rtems_timer_cancel" );
 
 /* after which is allowed to fire */
