source: rtems/testsuites/sptests/sp64/init.c @ c8ce082

4.104.115
Last change on this file since c8ce082 was c8ce082, checked in by Joel Sherrill <joel.sherrill@…>, on 08/11/09 at 17:53:09

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

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