source: rtems/c/src/tests/samples/unlimited/test1.c @ 3d9f688e

4.104.114.84.95
Last change on this file since 3d9f688e was 3d9f688e, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 3, 2003 at 8:51:34 PM

2002-10-31 Chris Johns <ccj@…>

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