source: rtems/testsuites/support/src/test_support.c @ abe5612

4.115
Last change on this file since abe5612 was abe5612, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 4, 2011 at 9:55:04 AM

2011-11-04 Sebastian Huber <sebastian.huber@…>

  • support/src/test_support.c: Avoid magic numbers.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2010.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <fcntl.h>
17#include <tmacros.h>
18#include "test_support.h"
19#include <rtems/libcsupport.h>
20
21static char  Too_Long_Name[PATH_MAX + 2];
22static char  Longest_Name[PATH_MAX + 1];
23
24const char *Get_Too_Long_Name(void)
25{
26  int i;
27
28  for ( i=0; i <= PATH_MAX; i++ )
29    Too_Long_Name[i] = 'E';
30  Too_Long_Name[i] = '\0';
31  return Too_Long_Name;
32}
33
34const char *Get_Longest_Name(void)
35{
36  int i;
37
38  for ( i=0; i < PATH_MAX-1; i++ )
39    Longest_Name[i] = 'L';
40  Longest_Name[i] = '\0';
41  return Longest_Name;
42}
43
44void Allocate_majority_of_workspace( int smallest )
45{
46  bool                   result;
47  Heap_Information_block info;
48  void                   *temp;
49
50  puts("Allocate_majority_of_workspace: ");
51  result = rtems_workspace_get_information( &info );
52  if ( result != TRUE )
53    perror("==> Error Getting workspace information");
54
55  do {
56    result = rtems_workspace_allocate(
57      info.Free.largest - HEAP_BLOCK_HEADER_SIZE,
58      &temp
59    );
60    if ((!result) || (!temp))
61      perror("Unable to allocate from workspace");
62    result = rtems_workspace_get_information( &info );
63  } while ( info.Free.largest >= smallest );
64
65}
66
67void Allocate_majority_of_heap( int smallest )
68{
69  size_t    size;
70  void     *temp;
71
72  puts("Allocate_majority_of_heap: ");
73  size = malloc_free_space();
74  do {
75    temp = malloc( size - HEAP_BLOCK_HEADER_SIZE );
76    if (!temp)
77      perror("Unable to allocate from workspace");
78    size = malloc_free_space();
79  } while ( size >= smallest );
80
81}
Note: See TracBrowser for help on using the repository browser.