source: rtems/testsuites/sptests/spobjgetnext/init.c @ 9e7d02a3

4.104.115
Last change on this file since 9e7d02a3 was 9e7d02a3, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:56

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • sp18/init.c, sp31/task1.c, sp43/init.c, sp63/init.c, sp64/init.c, spfatal10/testcase.h, spfatal11/testcase.h, spobjgetnext/init.c, spwkspace/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 2.7 KB
Line 
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 *  $Id$
12 */
13
14#define CONFIGURE_INIT
15#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1
16#include "system.h"
17
18/* prototypes */
19int scan_objects(
20  Objects_Information *information,
21  Objects_Id           start
22);
23
24#define MAX_SCAN 10
25
26int scan_objects(
27  Objects_Information *information,
28  Objects_Id           start
29)
30{
31  Objects_Control  *o[MAX_SCAN];
32  int               i;
33  Objects_Locations location;
34  Objects_Id        id;
35
36  memset( o, 1, sizeof(o) );
37
38  id = start;
39  for (i=0 ; i<MAX_SCAN ; i++ ) {
40    o[i] = _Objects_Get_next(
41      information,
42      id,
43      &location,
44      &id
45    );
46    if ( !o[i] )
47      break;
48    if ( location == OBJECTS_ERROR )
49      break;
50    /* XXX check dispatch level with macros */
51
52    _Thread_Enable_dispatch();
53
54    /* XXX should be able to check that next Id is not one we have seen */
55  }
56  return i;
57}
58
59rtems_task Init(
60  rtems_task_argument argument
61)
62{
63  rtems_id              main_task;
64  int                   count;
65  Objects_Control      *o;
66  Objects_Locations     location;
67  Objects_Id            id;
68  Objects_Information  *info;
69
70  puts( "\n\n*** TEST OBJECT GET NEXT ***" );
71
72  info      = &_RTEMS_tasks_Information;
73  main_task = rtems_task_self();
74
75  puts( "Init - _Objects_Get_next - NULL object information" );
76  o = _Objects_Get_next( NULL, main_task, &location, &id );
77  rtems_test_assert( o == NULL );
78
79  puts( "Init - _Objects_Get_next - NULL location" );
80  o = _Objects_Get_next( info, main_task, NULL, &id );
81  rtems_test_assert( o == NULL );
82
83  puts( "Init - _Objects_Get_next - NULL id" );
84  o = _Objects_Get_next( info, main_task, &location, NULL );
85  rtems_test_assert( o == NULL );
86
87  /* XXX push the three NULL error cases */
88
89  /* simple case of only all tasks in the system, starting at initial */
90  count = scan_objects( info, OBJECTS_ID_INITIAL_INDEX );
91  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
92  rtems_test_assert( count == 1 );
93
94  /* simple case of only 1 task in the system, starting at that task */
95  count = scan_objects( info, main_task );
96  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
97  rtems_test_assert( count == 1 );
98
99  /* XXX create >= 1 task and make sure the counts are correct when */
100  /* XXX you start the search at initial, first id, arbitrary id */
101
102  /* XXX try with a manager with no objects created */
103
104  puts( "*** END OF TEST OBJECT GET NEXT ***" );
105  rtems_test_exit( 0 );
106}
Note: See TracBrowser for help on using the repository browser.