1 | /* |
---|
2 | * Exercise SuperCore Object Get Next |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2009. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #define CONFIGURE_INIT |
---|
17 | #include "system.h" |
---|
18 | |
---|
19 | #include <rtems/rtems/tasksimpl.h> |
---|
20 | |
---|
21 | /* prototypes */ |
---|
22 | int scan_objects( |
---|
23 | Objects_Information *information, |
---|
24 | Objects_Id start |
---|
25 | ); |
---|
26 | |
---|
27 | #define MAX_SCAN 10 |
---|
28 | |
---|
29 | int scan_objects( |
---|
30 | Objects_Information *information, |
---|
31 | Objects_Id start |
---|
32 | ) |
---|
33 | { |
---|
34 | Objects_Control *o[MAX_SCAN]; |
---|
35 | int i; |
---|
36 | Objects_Locations location; |
---|
37 | Objects_Id id; |
---|
38 | |
---|
39 | memset( o, 1, sizeof(o) ); |
---|
40 | |
---|
41 | id = start; |
---|
42 | for (i=0 ; i<MAX_SCAN ; i++ ) { |
---|
43 | o[i] = _Objects_Get_next( |
---|
44 | information, |
---|
45 | id, |
---|
46 | &location, |
---|
47 | &id |
---|
48 | ); |
---|
49 | if ( !o[i] ) |
---|
50 | break; |
---|
51 | if ( location == OBJECTS_ERROR ) |
---|
52 | break; |
---|
53 | /* XXX check dispatch level with macros */ |
---|
54 | |
---|
55 | _Thread_Enable_dispatch(); |
---|
56 | |
---|
57 | /* XXX should be able to check that next Id is not one we have seen */ |
---|
58 | } |
---|
59 | return i; |
---|
60 | } |
---|
61 | |
---|
62 | rtems_task Init( |
---|
63 | rtems_task_argument argument |
---|
64 | ) |
---|
65 | { |
---|
66 | rtems_id main_task; |
---|
67 | int count; |
---|
68 | Objects_Control *o; |
---|
69 | Objects_Locations location; |
---|
70 | Objects_Id id; |
---|
71 | Objects_Information *info; |
---|
72 | Objects_Maximum active_count; |
---|
73 | |
---|
74 | puts( "\n\n*** TEST OBJECT GET NEXT ***" ); |
---|
75 | |
---|
76 | info = &_RTEMS_tasks_Information; |
---|
77 | main_task = rtems_task_self(); |
---|
78 | |
---|
79 | puts( "Init - _Objects_Get_next - NULL object information" ); |
---|
80 | o = _Objects_Get_next( NULL, main_task, &location, &id ); |
---|
81 | rtems_test_assert( o == NULL ); |
---|
82 | |
---|
83 | puts( "Init - _Objects_Get_next - NULL location" ); |
---|
84 | o = _Objects_Get_next( info, main_task, NULL, &id ); |
---|
85 | rtems_test_assert( o == NULL ); |
---|
86 | |
---|
87 | puts( "Init - _Objects_Get_next - NULL id" ); |
---|
88 | o = _Objects_Get_next( info, main_task, &location, NULL ); |
---|
89 | rtems_test_assert( o == NULL ); |
---|
90 | |
---|
91 | /* XXX push the three NULL error cases */ |
---|
92 | |
---|
93 | /* simple case of only all tasks in the system, starting at initial */ |
---|
94 | count = scan_objects( info, OBJECTS_ID_INITIAL_INDEX ); |
---|
95 | printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") ); |
---|
96 | rtems_test_assert( count == 1 ); |
---|
97 | |
---|
98 | /* simple case of only 1 task in the system, starting at that task */ |
---|
99 | count = scan_objects( info, main_task ); |
---|
100 | printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") ); |
---|
101 | rtems_test_assert( count == 1 ); |
---|
102 | |
---|
103 | /* XXX create >= 1 task and make sure the counts are correct when */ |
---|
104 | /* XXX you start the search at initial, first id, arbitrary id */ |
---|
105 | |
---|
106 | /* XXX try with a manager with no objects created */ |
---|
107 | |
---|
108 | puts( "Init - _Objects_Active_count" ); |
---|
109 | active_count = _Objects_Active_count( info ); |
---|
110 | rtems_test_assert( active_count == 1 ); |
---|
111 | |
---|
112 | puts( "*** END OF TEST OBJECT GET NEXT ***" ); |
---|
113 | rtems_test_exit( 0 ); |
---|
114 | } |
---|