1 | /* Odd Object Name/Id Error Cases |
---|
2 | * |
---|
3 | * COPYRIGHT (c) 1989-2009. |
---|
4 | * On-Line Applications Research Corporation (OAR). |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.com/license/LICENSE. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifdef HAVE_CONFIG_H |
---|
14 | #include "config.h" |
---|
15 | #endif |
---|
16 | |
---|
17 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ |
---|
18 | #include <tmacros.h> |
---|
19 | #include "test_support.h" |
---|
20 | |
---|
21 | rtems_task Init( |
---|
22 | rtems_task_argument ignored |
---|
23 | ) |
---|
24 | { |
---|
25 | Objects_Name_or_id_lookup_errors namerc; |
---|
26 | Objects_Information TestClass; |
---|
27 | Objects_Id id; |
---|
28 | char name[64]; |
---|
29 | bool bc; |
---|
30 | |
---|
31 | puts( "\n\n*** POSIX OBJECT TEST 1 ***" ); |
---|
32 | |
---|
33 | /* very fake object class to test with */ |
---|
34 | _Objects_Initialize_information( |
---|
35 | &TestClass, |
---|
36 | 1, /* the_api */ |
---|
37 | 4, /* the_class */ |
---|
38 | 0, /* maximum */ |
---|
39 | 4, /* size */ |
---|
40 | true, /* is_string */ |
---|
41 | 10 /* maximum_name_length */ |
---|
42 | #if defined(RTEMS_MULTIPROCESSING) |
---|
43 | , |
---|
44 | false, /* supports_global */ |
---|
45 | NULL /* Objects_Thread_queue_Extract_callout extract */ |
---|
46 | #endif |
---|
47 | ); |
---|
48 | |
---|
49 | puts( "INIT - _Objects_Name_to_id_string - NULL name" ); |
---|
50 | namerc = _Objects_Name_to_id_string( &TestClass, NULL, &id ); |
---|
51 | if ( namerc != OBJECTS_INVALID_NAME ) { |
---|
52 | printf( "ERROR - Status = %d\n", namerc ); |
---|
53 | rtems_test_exit(0); |
---|
54 | } |
---|
55 | |
---|
56 | puts( "INIT - _Objects_Name_to_id_string - NULL ID" ); |
---|
57 | namerc = _Objects_Name_to_id_string( &TestClass, name, NULL ); |
---|
58 | if ( namerc != OBJECTS_INVALID_ADDRESS ) { |
---|
59 | printf( "ERROR - Status = %d\n", namerc ); |
---|
60 | rtems_test_exit(0); |
---|
61 | } |
---|
62 | |
---|
63 | puts( "INIT - _Objects_Name_to_id_string - name of non-existent object" ); |
---|
64 | strcpy( name, "NOT FOUND" ); |
---|
65 | namerc = _Objects_Name_to_id_string( &TestClass, name, &id ); |
---|
66 | if ( namerc != OBJECTS_INVALID_NAME ) { |
---|
67 | printf( "ERROR - Status = %d\n", namerc ); |
---|
68 | rtems_test_exit(0); |
---|
69 | } |
---|
70 | |
---|
71 | /* out of memory error ONLY when POSIX is enabled */ |
---|
72 | puts( "INIT - _Objects_Set_name fails - out of memory" ); |
---|
73 | Allocate_majority_of_workspace( 1 ); |
---|
74 | |
---|
75 | bc = _Objects_Set_name( &TestClass, &_Thread_Executing->Object, name ); |
---|
76 | rtems_test_assert( bc == false ); |
---|
77 | |
---|
78 | puts( "*** END OF POSIX OBJECT TEST 1 ***" ); |
---|
79 | rtems_test_exit(0); |
---|
80 | } |
---|
81 | |
---|
82 | /* configuration information */ |
---|
83 | |
---|
84 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
85 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
86 | |
---|
87 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
88 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
89 | |
---|
90 | #define CONFIGURE_INIT |
---|
91 | #include <rtems/confdefs.h> |
---|
92 | |
---|
93 | /* global variables */ |
---|