2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com>

* sp43/Makefile.am, sp43/init.c, sp43/sp43.scn, sp43/system.h: Add test
	for Id which is in range for the object class but not allocated yet.
This commit is contained in:
Joel Sherrill
2009-09-13 20:37:54 +00:00
parent 88271c3308
commit cd4884a82d
5 changed files with 68 additions and 42 deletions

View File

@@ -1,3 +1,8 @@
2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com>
* sp43/Makefile.am, sp43/init.c, sp43/sp43.scn, sp43/system.h: Add test
for Id which is in range for the object class but not allocated yet.
2009-09-09 Joel Sherrill <joel.sherrill@OARcorp.com> 2009-09-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* sp46/init.c, sp46/sp46.scn: Fix numbering. * sp46/init.c, sp46/sp46.scn: Fix numbering.

View File

@@ -5,7 +5,7 @@
MANAGERS = all MANAGERS = all
rtems_tests_PROGRAMS = sp43 rtems_tests_PROGRAMS = sp43
sp43_SOURCES = init.c system.h sp43_SOURCES = init.c
dist_rtems_tests_DATA = sp43.scn dist_rtems_tests_DATA = sp43.scn

View File

@@ -65,7 +65,7 @@ void change_name(
bool printable bool printable
) )
{ {
rtems_status_code status; rtems_status_code sc;
char name[ 5 ]; char name[ 5 ];
char *ptr; char *ptr;
const char *c; const char *c;
@@ -85,11 +85,11 @@ void change_name(
printf( ")\n" ); printf( ")\n" );
} }
status = rtems_object_set_name( id, newName ); sc = rtems_object_set_name( id, newName );
directive_failed( status, "rtems_object_set_name" ); directive_failed( sc, "rtems_object_set_name" );
status = rtems_object_get_classic_name( id, &main_name ); sc = rtems_object_get_classic_name( id, &main_name );
directive_failed( status, "rtems_object_get_classic_name" ); directive_failed( sc, "rtems_object_get_classic_name" );
put_name( main_name, FALSE ); put_name( main_name, FALSE );
puts( " - name returned by rtems_object_get_classic_name" ); puts( " - name returned by rtems_object_get_classic_name" );
@@ -102,7 +102,7 @@ rtems_task Init(
rtems_task_argument argument rtems_task_argument argument
) )
{ {
rtems_status_code status; rtems_status_code sc;
rtems_id tmpId; rtems_id tmpId;
rtems_name tmpName; rtems_name tmpName;
char name[5]; char name[5];
@@ -119,45 +119,45 @@ rtems_task Init(
main_task = rtems_task_self(); main_task = rtems_task_self();
puts( "rtems_object_get_classic_name - INVALID_ADDRESS" ); puts( "rtems_object_get_classic_name - INVALID_ADDRESS" );
status = rtems_object_get_classic_name( main_task, NULL ); sc = rtems_object_get_classic_name( main_task, NULL );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ADDRESS, RTEMS_INVALID_ADDRESS,
"rtems_object_get_classic_name #1" "rtems_object_get_classic_name #1"
); );
puts( "rtems_object_get_classic_name - INVALID_ID (bad index)" ); puts( "rtems_object_get_classic_name - INVALID_ID (bad index)" );
status = rtems_object_get_classic_name( main_task + 5, &main_name ); sc = rtems_object_get_classic_name( main_task + 5, &main_name );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ID, RTEMS_INVALID_ID,
"rtems_object_get_classic_name #2" "rtems_object_get_classic_name #2"
); );
puts( "rtems_object_get_classic_name - INVALID_ID (unallocated index)" ); puts( "rtems_object_get_classic_name - INVALID_ID (unallocated index)" );
status = rtems_object_get_classic_name( main_task + 1, &main_name ); sc = rtems_object_get_classic_name( main_task + 1, &main_name );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ID, RTEMS_INVALID_ID,
"rtems_object_get_classic_name #4" "rtems_object_get_classic_name #4"
); );
puts( "rtems_object_get_classic_name - INVALID_ID (bad API)" ); puts( "rtems_object_get_classic_name - INVALID_ID (bad API)" );
tmpId = rtems_build_id( 0xff, OBJECTS_RTEMS_TASKS, 1, 1 ), tmpId = rtems_build_id( 0xff, OBJECTS_RTEMS_TASKS, 1, 1 ),
status = rtems_object_get_classic_name( tmpId, &main_name ); sc = rtems_object_get_classic_name( tmpId, &main_name );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ID, RTEMS_INVALID_ID,
"rtems_object_get_classic_name #5" "rtems_object_get_classic_name #5"
); );
status = rtems_object_get_classic_name( main_task, &main_name ); sc = rtems_object_get_classic_name( main_task, &main_name );
directive_failed( status, "rtems_object_get_classic_name" ); directive_failed( sc, "rtems_object_get_classic_name" );
put_name( main_name, FALSE ); put_name( main_name, FALSE );
puts( " - name returned by rtems_object_get_classic_name for Init task id" ); puts( " - name returned by rtems_object_get_classic_name for Init task id" );
status = rtems_object_get_classic_name( RTEMS_SELF, &main_name ); sc = rtems_object_get_classic_name( RTEMS_SELF, &main_name );
directive_failed( status, "rtems_object_get_classic_name" ); directive_failed( sc, "rtems_object_get_classic_name" );
put_name( main_name, FALSE ); put_name( main_name, FALSE );
puts( " - name returned by rtems_object_get_classic_name for RTEMS_SELF" ); puts( " - name returned by rtems_object_get_classic_name for RTEMS_SELF" );
@@ -203,17 +203,17 @@ rtems_task Init(
puts( "rtems_object_set_name - INVALID_ID (bad API)" ); puts( "rtems_object_set_name - INVALID_ID (bad API)" );
tmpId = rtems_build_id( 0xff, OBJECTS_RTEMS_TASKS, 1, 1 ), tmpId = rtems_build_id( 0xff, OBJECTS_RTEMS_TASKS, 1, 1 ),
status = rtems_object_set_name( tmpId, newName ); sc = rtems_object_set_name( tmpId, newName );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ID, RTEMS_INVALID_ID,
"rtems_object_set_name #1" "rtems_object_set_name #1"
); );
puts( "rtems_object_set_name - INVALID_ID (bad index)" ); puts( "rtems_object_set_name - INVALID_ID (bad index)" );
status = rtems_object_set_name( main_task + 10, newName ); sc = rtems_object_set_name( main_task + 10, newName );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ID, RTEMS_INVALID_ID,
"rtems_object_set_name #2" "rtems_object_set_name #2"
); );
@@ -344,67 +344,71 @@ rtems_task Init(
rtems_test_pause(); rtems_test_pause();
puts( "rtems_object_get_class_information - INVALID_ADDRESS" ); puts( "rtems_object_get_class_information - INVALID_ADDRESS" );
status = rtems_object_get_class_information( sc = rtems_object_get_class_information(
OBJECTS_INTERNAL_API, OBJECTS_INTERNAL_THREADS, NULL ); OBJECTS_INTERNAL_API, OBJECTS_INTERNAL_THREADS, NULL );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_ADDRESS, RTEMS_INVALID_ADDRESS,
"rtems_object_get_class_information" "rtems_object_get_class_information"
); );
puts( "rtems_object_get_class_information - INVALID_NUMBER (bad API)" ); puts( "rtems_object_get_class_information - INVALID_NUMBER (bad API)" );
status = sc =
rtems_object_get_class_information(0, OBJECTS_INTERNAL_THREADS, &info); rtems_object_get_class_information(0, OBJECTS_INTERNAL_THREADS, &info);
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_NUMBER, RTEMS_INVALID_NUMBER,
"rtems_object_get_class_information (API)" "rtems_object_get_class_information (API)"
); );
puts( "rtems_object_get_class_information - INVALID_NUMBER (api=0xff)" ); puts( "rtems_object_get_class_information - INVALID_NUMBER (api=0xff)" );
status = rtems_object_get_class_information( 0xff, 1, &info ); sc = rtems_object_get_class_information( 0xff, 1, &info );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_NUMBER, RTEMS_INVALID_NUMBER,
"rtems_object_get_class_information (api=0xff)" "rtems_object_get_class_information (api=0xff)"
); );
puts( "rtems_object_get_class_information - INVALID_NUMBER (class=0)" ); puts( "rtems_object_get_class_information - INVALID_NUMBER (class=0)" );
status = rtems_object_get_class_information( sc = rtems_object_get_class_information(
OBJECTS_INTERNAL_API, 0, &info ); OBJECTS_INTERNAL_API, 0, &info );
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_NUMBER, RTEMS_INVALID_NUMBER,
"rtems_object_get_class_information (class=0)" "rtems_object_get_class_information (class=0)"
); );
puts( puts(
"rtems_object_get_class_information - INVALID_NUMBER (class too high)" ); "rtems_object_get_class_information - INVALID_NUMBER (class too high)" );
status = rtems_object_get_class_information( sc = rtems_object_get_class_information(
OBJECTS_INTERNAL_API, 0xff, &info); OBJECTS_INTERNAL_API, 0xff, &info);
fatal_directive_status( fatal_directive_status(
status, sc,
RTEMS_INVALID_NUMBER, RTEMS_INVALID_NUMBER,
"rtems_object_get_class_information (class #2)" "rtems_object_get_class_information (class #2)"
); );
puts( "rtems_object_get_class_information - Classic Tasks - OK" ); puts( "rtems_object_get_class_information - Classic Tasks - OK" );
status = rtems_object_get_class_information( sc = rtems_object_get_class_information(
OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, &info ); OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, &info );
directive_failed( status, "rtems_object_get_class_information" ); directive_failed( sc, "rtems_object_get_class_information" );
print_class_info( OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, &info ); print_class_info( OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, &info );
puts( "rtems_object_get_class_information - Classic Timers - OK" ); puts( "rtems_object_get_class_information - Classic Timers - OK" );
status = rtems_object_get_class_information( sc = rtems_object_get_class_information(
OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, &info ); OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, &info );
directive_failed( status, "rtems_object_get_class_information" ); directive_failed( sc, "rtems_object_get_class_information" );
print_class_info( OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, &info ); print_class_info( OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, &info );
/* /*
* Ugly hack to force a weird error * Ugly hack to force a weird error.
*
* The weird case is that we need to look up a thread Id where the
* thread classes' object information table pointer is NULL. Probably
* impossible to really hit until registration is completely dynamically
* configurable.
*/ */
{ {
rtems_status_code sc;
rtems_task_priority old_priority; rtems_task_priority old_priority;
void *tmp; void *tmp;
int class; int class;
@@ -438,7 +442,24 @@ rtems_task Init(
puts( "rtems_task_set_priority - restore internal thread class info" ); puts( "rtems_task_set_priority - restore internal thread class info" );
_Objects_Information_table[ class ][ api ] = tmp; _Objects_Information_table[ class ][ api ] = tmp;
} }
/*
* Bad Id on an object which disables interrupts as part of translating
* the Id into an object pointer. Semaphore is the only object that
* needs this. This is a "good" Id in that is it in range, but bad in
* that it has not been allocated so the local_table pointer is NULL.
*/
puts( "rtems_semaphore_release - good but uncreated ID - INVALID_ID - OK" );
sc = rtems_semaphore_release(
rtems_build_id(
OBJECTS_CLASSIC_API,
OBJECTS_RTEMS_SEMAPHORES,
1,
rtems_configuration_get_maximum_semaphores()
)
);
fatal_directive_status( sc, RTEMS_INVALID_ID, "rtems_semaphore_obtain" );
puts( "*** END OF TEST 43 ***" ); puts( "*** END OF TEST 43 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );
} }

View File

@@ -87,4 +87,5 @@ rtems_task_set_priority - use valid Idle thread id
rtems_task_set_priority - clobber internal thread class info rtems_task_set_priority - clobber internal thread class info
rtems_task_set_priority - use valid Idle thread id again rtems_task_set_priority - use valid Idle thread id again
rtems_task_set_priority - restore internal thread class info rtems_task_set_priority - restore internal thread class info
rtems_semaphore_release - good but uncreated ID - INVALID_ID - OK
*** END OF TEST 43 *** *** END OF TEST 43 ***

View File

@@ -30,8 +30,7 @@ rtems_task Init(
#define CONFIGURE_MAXIMUM_TASKS 2 #define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_MAXIMUM_TIMERS 1 #define CONFIGURE_MAXIMUM_TIMERS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 1 #define CONFIGURE_MAXIMUM_SEMAPHORES 2
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */