source: rtems/testsuites/sptests/sp64/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "tmacros.h"
15
16uint32_t Area1[50] CPU_STRUCTURE_ALIGNMENT;
17uint32_t Area2[50] CPU_STRUCTURE_ALIGNMENT;
18
19rtems_task Init(
20  rtems_task_argument ignored
21)
22{
23  rtems_id                region1;
24  rtems_id                region2;
25  rtems_status_code       sc;
26  bool                    sb;
27  Heap_Information_block  start;
28  Heap_Information_block  info;
29  size_t                  to_alloc;
30  void                   *alloced;
31
32  puts( "\n\n*** TEST 64 ***" );
33
34  puts( "Allocate one region -- so second auto extends" );
35  sc = rtems_region_create(
36    rtems_build_name( 'R', 'N', '1', ' ' ),
37    Area1,
38    sizeof(Area1),
39    8,
40    RTEMS_DEFAULT_ATTRIBUTES,
41    &region1
42  );
43  directive_failed( sc, "rtems_region_create of RN1" );
44
45  puts( "Init - rtems_workspace_get_information - OK" );
46  sb = rtems_workspace_get_information( &start );
47  rtems_test_assert( sb );
48
49  #if 0
50    printf( "Init - workspace free = %d\n", start.Free.largest );
51    printf( "Init - workspace free blocks = %d\n", start.Free.number );
52  #endif
53  rtems_test_assert( start.Free.number == 1 );
54  to_alloc = start.Free.largest;
55
56  /* find the largest we can actually allocate */
57  while ( 1 ) {
58    sb = rtems_workspace_allocate( to_alloc, &alloced );
59    if ( sb )
60      break;
61    to_alloc -= 4;
62  }
63
64  rtems_workspace_free( alloced );
65
66  #if 0
67    printf( "Init - start with to_alloc of = %d\n", to_alloc );
68  #endif
69
70  /*
71   * Verify heap is still in same shape if we couldn't allocate a region
72   */
73  sb = rtems_workspace_get_information( &info );
74  rtems_test_assert( sb );
75  rtems_test_assert( info.Free.largest == start.Free.largest );
76  rtems_test_assert( info.Free.number  == start.Free.number  );
77
78  puts( "Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED" );
79  while (1) {
80
81    sb = rtems_workspace_allocate( to_alloc, &alloced );
82    rtems_test_assert( sb );
83
84    sc = rtems_region_create(
85      rtems_build_name( 'R', 'N', '2', ' ' ),
86      Area2,
87      sizeof(Area2),
88      8,
89      RTEMS_DEFAULT_ATTRIBUTES,
90      &region2
91    );
92
93    /* free the memory we snagged, then check the status */
94    rtems_workspace_free( alloced );
95
96    if ( sc == RTEMS_SUCCESSFUL )
97      break;
98
99    if ( sc != RTEMS_TOO_MANY ) {
100      printf( "region create returned %d or %s\n", sc, rtems_status_text(sc) );
101      rtems_test_exit(0);
102    }
103
104    /*
105     * Verify heap is still in same shape if we couldn't allocate a region
106     */
107    sb = rtems_workspace_get_information( &info );
108    #if 0
109      printf( "Init - workspace free/blocks = %d/%d\n",
110        info.Free.largest, info.Free.number );
111    #endif
112    rtems_test_assert( sb );
113    rtems_test_assert( info.Free.largest == start.Free.largest );
114    rtems_test_assert( info.Free.number  == start.Free.number  );
115
116    to_alloc -= 8;
117    if ( to_alloc == 0 )
118     break;
119  }
120
121  if ( sc )
122    rtems_test_exit(0);
123
124  /*
125   * Verify heap is still in same shape after we free the region
126   */
127  puts( "Init - rtems_region_delete - OK" );
128  sc = rtems_region_delete( region2 );
129  rtems_test_assert( sc == 0 );
130
131  /*
132   *  Although it is intuitive that after deleting the region the
133   *  object space would shrink and go back to its original shape,
134   *  we could end up with fragmentation which prevents a simple
135   *  check from verifying this.
136   */
137  #if 0
138    puts( "Init - verify workspace has same memory" );
139    sb = rtems_workspace_get_information( &info );
140    #if 0
141        printf( "Init - workspace free/blocks = %d/%d\n",
142      info.Free.largest, info.Free.number );
143    #endif
144    rtems_test_assert( sb );
145    rtems_test_assert( info.Free.largest == start.Free.largest );
146    rtems_test_assert( info.Free.number  == start.Free.number  );
147  #endif
148
149  puts( "*** END OF TEST 64 ***" );
150  rtems_test_exit(0);
151}
152
153/* configuration information */
154
155#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
156#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
157
158#define CONFIGURE_MAXIMUM_TASKS         2
159#define CONFIGURE_MAXIMUM_REGIONS       rtems_resource_unlimited(1)
160#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
161
162#define CONFIGURE_INIT
163#include <rtems/confdefs.h>
164
165/* global variables */
Note: See TracBrowser for help on using the repository browser.