File indexing completed on 2025-05-11 08:24:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037
0038 #include <tmacros.h>
0039
0040 #include <rtems/score/objectimpl.h>
0041
0042 const char rtems_test_name[] = "PSXOBJ 1";
0043
0044 typedef struct {
0045 Objects_Control Object;
0046 } Test_Control;
0047
0048
0049 OBJECTS_INFORMATION_DEFINE( Test, 1, 4, Test_Control, 0, 10, NULL );
0050
0051 static rtems_task Init(
0052 rtems_task_argument ignored
0053 )
0054 {
0055 Objects_Get_by_name_error error;
0056 Objects_Control *the_object;
0057 char name[64];
0058 size_t name_len;
0059 Status_Control status;
0060
0061 TEST_BEGIN();
0062
0063 puts( "INIT - _Objects_Get_by_name - NULL name" );
0064 _Objects_Allocator_lock();
0065 the_object = _Objects_Get_by_name( &Test_Information, NULL, NULL, &error );
0066 _Objects_Allocator_unlock();
0067 rtems_test_assert( the_object == NULL );
0068 rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME );
0069
0070 puts( "INIT - _Objects_Get_by_name - name too long" );
0071 strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" );
0072 _Objects_Allocator_lock();
0073 the_object = _Objects_Get_by_name( &Test_Information, name, NULL, &error );
0074 _Objects_Allocator_unlock();
0075 rtems_test_assert( the_object == NULL );
0076 rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG );
0077
0078 puts( "INIT - _Objects_Get_by_name - name of non-existent object" );
0079 strcpy( name, "NOT FOUND" );
0080 name_len = 123;
0081 _Objects_Allocator_lock();
0082 the_object = _Objects_Get_by_name( &Test_Information, name, &name_len, &error );
0083 _Objects_Allocator_unlock();
0084 rtems_test_assert( the_object == NULL );
0085 rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT );
0086 rtems_test_assert( name_len == 9 );
0087
0088
0089 puts( "INIT - _Objects_Set_name fails - out of memory" );
0090 rtems_workspace_greedy_allocate( NULL, 0 );
0091
0092 status = _Objects_Set_name(
0093 &Test_Information,
0094 &_Thread_Get_executing()->Object,
0095 name
0096 );
0097 rtems_test_assert( status == STATUS_NO_MEMORY );
0098
0099 TEST_END();
0100 rtems_test_exit(0);
0101 }
0102
0103
0104
0105 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0106 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0107
0108 #define CONFIGURE_MAXIMUM_TASKS 1
0109 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0110
0111 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0112
0113 #define CONFIGURE_INIT
0114 #include <rtems/confdefs.h>
0115
0116