diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 07:25:23 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 15:36:58 +0100 |
commit | c904df573396d95957dc79b242b3a76911063089 (patch) | |
tree | be6406676689018e8af8a929b6a4ef5284f94c70 /testsuites/psxtests/psxobj01 | |
parent | 1f0e652a2afc7db36c55276a965ab1fffe7932dc (diff) |
score: Add _Objects_Get_by_name()
Replace _Objects_Name_to_id_string() with _Objects_Get_by_name() since
all users of this function are interested in the object itself and not
the identifier.
Use the object allocator lock to protect the search.
Update #2555.
Diffstat (limited to 'testsuites/psxtests/psxobj01')
-rw-r--r-- | testsuites/psxtests/psxobj01/init.c | 48 | ||||
-rw-r--r-- | testsuites/psxtests/psxobj01/psxobj01.scn | 11 |
2 files changed, 28 insertions, 31 deletions
diff --git a/testsuites/psxtests/psxobj01/init.c b/testsuites/psxtests/psxobj01/init.c index 27d32b340e..16b703ba52 100644 --- a/testsuites/psxtests/psxobj01/init.c +++ b/testsuites/psxtests/psxobj01/init.c @@ -29,11 +29,12 @@ rtems_task Init( rtems_task_argument ignored ) { - Objects_Name_or_id_lookup_errors namerc; - Objects_Information TestClass; - Objects_Id id; - char name[64]; - bool bc; + Objects_Get_by_name_error error; + Objects_Information TestClass; + Objects_Control *the_object; + char name[64]; + size_t name_len; + bool bc; TEST_BEGIN(); @@ -53,27 +54,24 @@ rtems_task Init( #endif ); - puts( "INIT - _Objects_Name_to_id_string - NULL name" ); - namerc = _Objects_Name_to_id_string( &TestClass, NULL, &id ); - if ( namerc != OBJECTS_INVALID_NAME ) { - printf( "ERROR - Status = %d\n", namerc ); - rtems_test_exit(0); - } - - puts( "INIT - _Objects_Name_to_id_string - NULL ID" ); - namerc = _Objects_Name_to_id_string( &TestClass, name, NULL ); - if ( namerc != OBJECTS_INVALID_ADDRESS ) { - printf( "ERROR - Status = %d\n", namerc ); - rtems_test_exit(0); - } - - puts( "INIT - _Objects_Name_to_id_string - name of non-existent object" ); + puts( "INIT - _Objects_Get_by_name - NULL name" ); + the_object = _Objects_Get_by_name( &TestClass, NULL, NULL, &error ); + rtems_test_assert( the_object == NULL ); + rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME ); + + puts( "INIT - _Objects_Get_by_name - name too long" ); + strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" ); + the_object = _Objects_Get_by_name( &TestClass, name, NULL, &error ); + rtems_test_assert( the_object == NULL ); + rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG ); + + puts( "INIT - _Objects_Get_by_name - name of non-existent object" ); strcpy( name, "NOT FOUND" ); - namerc = _Objects_Name_to_id_string( &TestClass, name, &id ); - if ( namerc != OBJECTS_INVALID_NAME ) { - printf( "ERROR - Status = %d\n", namerc ); - rtems_test_exit(0); - } + name_len = 123; + the_object = _Objects_Get_by_name( &TestClass, name, &name_len, &error ); + rtems_test_assert( the_object == NULL ); + rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT ); + rtems_test_assert( name_len == 9 ); /* out of memory error ONLY when POSIX is enabled */ puts( "INIT - _Objects_Set_name fails - out of memory" ); diff --git a/testsuites/psxtests/psxobj01/psxobj01.scn b/testsuites/psxtests/psxobj01/psxobj01.scn index 809d028eea..344820f75c 100644 --- a/testsuites/psxtests/psxobj01/psxobj01.scn +++ b/testsuites/psxtests/psxobj01/psxobj01.scn @@ -1,7 +1,6 @@ -*** POSIX OBJECT TEST 1 *** -INIT - _Objects_Name_to_id_string - NULL name -INIT - _Objects_Name_to_id_string - NULL ID -INIT - _Objects_Name_to_id_string - name of non-existent object +*** BEGIN OF TEST PSXOBJ 1 *** +INIT - _Objects_Get_by_name - NULL name +INIT - _Objects_Get_by_name - name too long +INIT - _Objects_Get_by_name - name of non-existent object INIT - _Objects_Set_name fails - out of memory -Allocate_majority_of_workspace: -*** END OF POSIX OBJECT TEST 1 *** +*** END OF TEST PSXOBJ 1 *** |