source: rtems/testsuites/sptests/sp48/init.c @ dbd40ca

4.104.115
Last change on this file since dbd40ca was dbd40ca, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/26/09 at 09:35:02

Use %zu instead of %d to print size_t's.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  Verify creation of semaphores with unlimited attribute works.
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#include <tmacros.h>
15#include <rtems/libcsupport.h>
16
17rtems_task Init(rtems_task_argument ignored);
18
19#define MAX 5000
20rtems_id Semaphores[MAX];
21
22rtems_task Init(rtems_task_argument ignored)
23{
24  rtems_status_code sc;
25  int               i;
26  int               created;
27
28  puts( "\n\n*** TEST 48 ***" );
29
30  printf( "Largest C program heap block available: %zu\n", malloc_free_space() );
31  for (i=0 ; i<MAX ; i++ ) {
32    sc = rtems_semaphore_create(
33      rtems_build_name('s', 'e', 'm', ' '),
34      1,
35      RTEMS_DEFAULT_ATTRIBUTES,
36      0,
37      &Semaphores[i]
38    );
39    /* printf("Creating %i id=0x%08x\n", i, Semaphores[i]); */
40
41    if (sc == RTEMS_TOO_MANY) {
42      printf("We run out at %i!\n", i);
43      break;
44    }
45    if (sc != RTEMS_SUCCESSFUL) {
46      printf("FAILED creating at %i\n", i);
47      directive_failed( sc, "rtems_semaphore_create " );
48      rtems_test_exit( 0 );
49    }
50  }
51
52  created = i;
53  if ( created == MAX )
54    puts( "Created all semaphores allowed in this test" );
55
56  printf( "%d semaphores created\n", i );
57  printf( "Largest C program heap block available: %zu\n", malloc_free_space() );
58
59  for ( i-- ; i ; i-- ) {
60    sc = rtems_semaphore_delete( Semaphores[i] );
61    if (sc != RTEMS_SUCCESSFUL) {
62      printf("FAILED deleting at %i\n", i);
63      directive_failed( sc, "rtems_semaphore_delete " );
64      rtems_test_exit( 0 );
65    }
66  }
67
68  printf( "%d semaphores successfully deleted\n", created );
69  printf( "Largest C program heap block available: %zu\n", malloc_free_space() );
70
71  puts( "*** END OF TEST 48 ***" );
72  rtems_test_exit( 0 );
73}
74
75/* configuration stuff */
76
77#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
78#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
79
80#define CONFIGURE_MAXIMUM_TASKS        1
81#define CONFIGURE_MAXIMUM_SEMAPHORES   rtems_resource_unlimited(5)
82#if 1
83  #define CONFIGURE_UNIFIED_WORK_AREAS
84#else
85  #define CONFIGURE_MEMORY_OVERHEAD    1024
86#endif
87
88#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
89
90#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
91
92#define CONFIGURE_INIT
93#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.