source: rtems/testsuites/samples/unlimited/test1.c @ 732276e

4.104.115
Last change on this file since 732276e was 732276e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/26/09 at 11:34:27

Include "tmacros.h". Use PRIxrtems_id to print rtems_ids.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*  Test1
2 *
3 *  This test uses a hack to disable suto-extend then checks to see only the
4 *  requested number of objects are allocated.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may in
14 *  the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <inttypes.h>
21#include <stdio.h>
22#include <stdlib.h>
23
24#include "system.h"
25#include "tmacros.h"
26#include <rtems/score/object.h>
27
28void test1()
29{
30  bool                 auto_extend;
31  rtems_status_code    result;
32  uint32_t             task_count = 0;
33  Objects_Information *the_information;
34
35  char              c1 = 'a';
36  char              c2 = 'a';
37  char              c3 = '0';
38  char              c4 = '0';
39
40  printf( "\n TEST1 : auto-extend disabled.\n" );
41
42  /*
43   * This is a major hack and only recommended for a test. Doing this
44   * saves having another test.
45   */
46
47  the_information =
48    _Objects_Information_table[OBJECTS_CLASSIC_API][OBJECTS_RTEMS_TASKS];
49  auto_extend = the_information->auto_extend;
50  the_information->auto_extend = false;
51
52  while (task_count < MAX_TASKS)
53  {
54    rtems_name name;
55
56    printf(" TEST1 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
57
58    name = rtems_build_name(c1, c2, c3, c4);
59
60    result = rtems_task_create(name,
61                               10,
62                               RTEMS_MINIMUM_STACK_SIZE,
63                               RTEMS_DEFAULT_ATTRIBUTES,
64                               RTEMS_LOCAL,
65                               &task_id[task_count]);
66
67    if (status_code_bad(result))
68      break;
69
70    printf("number = %3" PRIi32 ", id = %08" PRIxrtems_id ", starting, ", task_count, task_id[task_count]);
71
72    fflush(stdout);
73    result = rtems_task_start(task_id[task_count],
74                              test_task,
75                              (rtems_task_argument) task_count);
76
77    if (status_code_bad(result))
78      break;
79
80    /*
81     *  Update the name.
82     */
83
84    NEXT_TASK_NAME(c1, c2, c3, c4);
85
86    task_count++;
87  }
88
89  if (task_count >= MAX_TASKS)
90    printf( "\nMAX_TASKS too small for work-space size, please make larger !!\n\n" );
91
92  if (task_count != (TASK_ALLOCATION_SIZE - 1)) {
93    printf( " FAIL1 : the number of tasks does not equal the expected size -\n"
94            "           task created = %" PRIi32 ", required number = %i\n",
95            task_count, TASK_ALLOCATION_SIZE);
96    exit( 1 );
97  }
98
99  destory_all_tasks("TEST1");
100
101  the_information->auto_extend = auto_extend;
102
103  printf( " TEST1 : completed\n" );
104}
Note: See TracBrowser for help on using the repository browser.