source: rtems/testsuites/samples/unlimited/test1.c @ 51a95ff9

4.11
Last change on this file since 51a95ff9 was 51a95ff9, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 7, 2014 at 10:43:18 PM

samples/unlimited: Fix printf() warning and clean up

  • 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.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <inttypes.h>
23#include <stdio.h>
24#include <stdlib.h>
25
26#include "system.h"
27#include "tmacros.h"
28
29#include <rtems/score/objectimpl.h>
30
31void test1()
32{
33  bool                 auto_extend;
34  rtems_status_code    result;
35  uint32_t             task_count = 0;
36  Objects_Information *the_information;
37
38  char              c1 = 'a';
39  char              c2 = 'a';
40  char              c3 = '0';
41  char              c4 = '0';
42
43  printf( "\n TEST1 : auto-extend disabled.\n" );
44
45  /*
46   * This is a major hack and only recommended for a test. Doing this
47   * saves having another test.
48   */
49
50  the_information =
51    _Objects_Information_table[OBJECTS_CLASSIC_API][OBJECTS_RTEMS_TASKS];
52  auto_extend = the_information->auto_extend;
53  the_information->auto_extend = false;
54
55  while (task_count < MAX_TASKS)
56  {
57    rtems_name name;
58
59    printf(" TEST1 : creating task '%c%c%c%c', ", c1, c2, c3, c4);
60
61    name = rtems_build_name(c1, c2, c3, c4);
62
63    result = rtems_task_create(name,
64                               10,
65                               RTEMS_MINIMUM_STACK_SIZE,
66                               RTEMS_DEFAULT_ATTRIBUTES,
67                               RTEMS_LOCAL,
68                               &task_id[task_count]);
69
70    if (status_code_bad(result))
71      break;
72
73    printf("number = %3" PRIi32 ", id = %08" PRIxrtems_id ", starting, ", task_count, task_id[task_count]);
74
75    fflush(stdout);
76    result = rtems_task_start(task_id[task_count],
77                              test_task,
78                              (rtems_task_argument) task_count);
79
80    if (status_code_bad(result))
81      break;
82
83    /*
84     *  Update the name.
85     */
86
87    NEXT_TASK_NAME(c1, c2, c3, c4);
88
89    task_count++;
90  }
91
92  if (task_count >= MAX_TASKS)
93    printf( "\nMAX_TASKS too small for work-space size, please make larger !!\n\n" );
94
95  if (task_count != (TASK_ALLOCATION_SIZE - 1)) {
96    printf( " FAIL1 : the number of tasks does not equal the expected size -\n"
97            "           task created = %" PRIi32 ", required number = %i\n",
98            task_count, TASK_ALLOCATION_SIZE);
99    exit( 1 );
100  }
101
102  destroy_all_tasks("TEST1");
103
104  the_information->auto_extend = auto_extend;
105
106  printf( " TEST1 : completed\n" );
107}
Note: See TracBrowser for help on using the repository browser.