source: rtems/testsuites/samples/unlimited/test1.c @ a2e3f33

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on Jul 24, 2013 at 11:50:54 AM

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

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