source: rtems/testsuites/sptests/sp62/init.c @ d2861a11

4.104.115
Last change on this file since d2861a11 was d2861a11, checked in by Joel Sherrill <joel.sherrill@…>, on 07/28/09 at 23:49:47

2009-07-28 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac: Add new test to handle the case where a region resize frees enough memory to unblock a task.
  • sp62/.cvsignore, sp62/Makefile.am, sp62/init.c, sp62/sp62.doc, sp62/sp62.scn: New files.
  • sp61/init.c: Test does not need regions.
  • Property mode set to 100644
File size: 2.9 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
14rtems_id      Region;
15uint32_t      Region_Memory[256];
16volatile bool case_hit;
17
18#define    FIRST_ALLOC 980
19#define    BLOCK_ALLOC 900
20#define    RESIZE      16
21
22rtems_task Blocker(
23  rtems_task_argument ignored
24)
25{
26  rtems_status_code  sc;
27  void              *segment_address_1;
28
29  puts( "Blocker - rtems_region_get_segment - OK");
30  sc = rtems_region_get_segment(
31    Region,
32    BLOCK_ALLOC,
33    RTEMS_DEFAULT_OPTIONS,
34    RTEMS_NO_TIMEOUT,
35    &segment_address_1
36  );
37  directive_failed( sc, "rtems_region_get_segment" );
38
39
40  puts( "Blocker - Got memory after resize" );
41  case_hit = true;
42 
43  (void) rtems_task_delete( RTEMS_SELF );
44
45}
46
47rtems_task Init(
48  rtems_task_argument ignored
49)
50{
51  rtems_id           task_id;
52  rtems_status_code  sc;
53  void              *segment_address_1;
54  intptr_t           old_size;
55
56  puts( "\n\n*** TEST 62 ***" );
57 
58  puts( "Init - rtems_task_create Blocker - OK" );
59  sc = rtems_task_create(
60    rtems_build_name( 'B', 'L', 'C', 'K' ),
61    1,
62    RTEMS_MINIMUM_STACK_SIZE,
63    RTEMS_DEFAULT_MODES,
64    RTEMS_DEFAULT_ATTRIBUTES,
65    &task_id
66  );
67  directive_failed( sc, "rtems_task_create of Blocker" );
68
69  puts( "Init - rtems_task_start Blocker - OK" );
70  sc = rtems_task_start( task_id, Blocker, 0 );
71  directive_failed( sc, "rtems_task_start of Blocker" );
72
73
74  puts( "Init - rtems_task_create Region - OK" );
75  sc = rtems_region_create(
76    rtems_build_name( 'R', 'N', '1', ' ' ),
77    Region_Memory,
78    sizeof(Region_Memory),
79    16,
80    RTEMS_DEFAULT_ATTRIBUTES,
81    &Region
82  );
83  directive_failed( sc, "rtems_region_create" );
84
85  puts( "Init - rtems_region_get_segment - OK");
86  sc = rtems_region_get_segment(
87    Region,
88    FIRST_ALLOC,
89    RTEMS_DEFAULT_OPTIONS,
90    RTEMS_NO_TIMEOUT,
91    &segment_address_1
92  );
93  directive_failed( sc, "rtems_region_get_segment" );
94
95  puts( "Init - sleep 1 second for Blocker - OK");
96  sleep(1);
97
98  /* Check resize_segment errors */
99  sc = rtems_region_resize_segment(
100    Region, segment_address_1, RESIZE, &old_size);
101  directive_failed( sc, "rtems_region_resize_segment" );
102
103  case_hit = false;
104
105  puts( "Init - sleep 1 second for Blocker to run again - OK");
106  sleep(1);
107
108  if ( case_hit ) {
109    puts( "Init - successfully resized and unblocked a task" );
110    puts( "*** END OF TEST 62 ***" );
111  } else
112    puts( "Init - failed to resize and unblock a task" );
113
114  rtems_test_exit(0);
115}
116
117/* configuration information */
118
119#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
120#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
121
122#define CONFIGURE_MAXIMUM_TASKS         2
123#define CONFIGURE_MAXIMUM_REGIONS       1
124#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
125
126#define CONFIGURE_INIT
127#include <rtems/confdefs.h>
128
129/* global variables */
Note: See TracBrowser for help on using the repository browser.