source: rtems/testsuites/sptests/spobjgetnext/init.c @ ae75429

4.115
Last change on this file since ae75429 was ae75429, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/13 at 14:10:26

PR766: Delete RTEMS_VIOLATE_KERNEL_VISIBILITY

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[c14c2f0]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
[7d3f9c6]12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
[c14c2f0]16#define CONFIGURE_INIT
17#include "system.h"
18
[c404828]19#include <rtems/rtems/tasksimpl.h>
20
[b84f1fdc]21/* prototypes */
[b1274bd9]22int scan_objects(
[b84f1fdc]23  Objects_Information *information,
24  Objects_Id           start
25);
26
[c14c2f0]27#define MAX_SCAN 10
[b84f1fdc]28
[b1274bd9]29int scan_objects(
[c14c2f0]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] )
[b1274bd9]50      break;
[c14c2f0]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;
[b1274bd9]60}
[c14c2f0]61
62rtems_task Init(
63  rtems_task_argument argument
64)
65{
66  rtems_id              main_task;
67  int                   count;
[7d414c3]68  Objects_Control      *o;
69  Objects_Locations     location;
70  Objects_Id            id;
71  Objects_Information  *info;
[fe1dc22]72  Objects_Maximum       active_count;
[c14c2f0]73
74  puts( "\n\n*** TEST OBJECT GET NEXT ***" );
75
[7d414c3]76  info      = &_RTEMS_tasks_Information;
[c14c2f0]77  main_task = rtems_task_self();
78
[7d414c3]79  puts( "Init - _Objects_Get_next - NULL object information" );
80  o = _Objects_Get_next( NULL, main_task, &location, &id );
[9e7d02a3]81  rtems_test_assert( o == NULL );
[7d414c3]82
83  puts( "Init - _Objects_Get_next - NULL location" );
84  o = _Objects_Get_next( info, main_task, NULL, &id );
[9e7d02a3]85  rtems_test_assert( o == NULL );
[7d414c3]86
87  puts( "Init - _Objects_Get_next - NULL id" );
88  o = _Objects_Get_next( info, main_task, &location, NULL );
[9e7d02a3]89  rtems_test_assert( o == NULL );
[7d414c3]90
[c14c2f0]91  /* XXX push the three NULL error cases */
92
93  /* simple case of only all tasks in the system, starting at initial */
[7d414c3]94  count = scan_objects( info, OBJECTS_ID_INITIAL_INDEX );
[c14c2f0]95  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
[9e7d02a3]96  rtems_test_assert( count == 1 );
[c14c2f0]97
98  /* simple case of only 1 task in the system, starting at that task */
[7d414c3]99  count = scan_objects( info, main_task );
[c14c2f0]100  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
[9e7d02a3]101  rtems_test_assert( count == 1 );
[c14c2f0]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
[fe1dc22]108  puts( "Init - _Objects_Active_count" );
109  active_count = _Objects_Active_count( info );
110  rtems_test_assert( active_count == 1 );
111
[c14c2f0]112  puts( "*** END OF TEST OBJECT GET NEXT ***" );
113  rtems_test_exit( 0 );
114}
Note: See TracBrowser for help on using the repository browser.