source: rtems/testsuites/psxtests/psxsysconf/init.c

Last change on this file was f9219db, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 5, 2019 at 6:16:05 AM

rtems: Add rtems_scheduler_get_processor_maximum()

Add rtems_scheduler_get_processor_maximum() as a replacement for
rtems_get_processor_count(). The rtems_get_processor_count() is a bit
orphaned. Adopt it by the Scheduler Manager. The count is also
misleading, since the processor set may have gaps and the actual count
of online processors may be less than the value returned by
rtems_get_processor_count().

Update #3732.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
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.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16#include "tmacros.h"
17
18#include <unistd.h>
19#include <stdint.h>
20#include <errno.h>
21
22const char rtems_test_name[] = "PSXSYSCONF";
23
24void *POSIX_Init(
25  void *argument
26)
27{
28  long  sc;
29
30  TEST_BEGIN();
31
32  puts( "sysconf -- bad configuration parameter - negative" );
33  sc = sysconf( -1 );
34  fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" );
35
36#if UNUSED
37/* FIXME: This test doesn't make sense.
38 * On targets with sizeof(int) < sizeof(long), compilation will fail,
39 * On targets with sizeof(int) == sizeof(long) the call is valid.
40 */
41  puts( "sysconf -- bad configuration parameter - too large" );
42  sc = sysconf( LONG_MAX );
43  fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" );
44#endif
45
46  sc = sysconf( _SC_CLK_TCK );
47  printf( "sysconf - _SC_CLK_TCK=%ld\n", sc );
48  if ( sc == -1 )
49   rtems_test_exit(0);
50
51  sc = sysconf( _SC_OPEN_MAX );
52  printf( "sysconf - _SC_OPEN_MAX=%ld\n", sc );
53  if ( sc == -1 )
54   rtems_test_exit(0);
55
56  sc = sysconf( _SC_GETPW_R_SIZE_MAX );
57  printf( "sysconf - _SC_GETPW_R_SIZE_MAX=%ld\n", sc );
58  if ( sc == -1 )
59   rtems_test_exit(0);
60
61  sc = sysconf( _SC_PAGESIZE );
62  printf( "sysconf - _SC_PAGESIZE=%ld\n", sc );
63  if ( sc == -1 )
64   rtems_test_exit(0);
65
66  sc = getpagesize();
67  printf( "getpagesize = %ld\n", sc );
68  if ( sc == -1 )
69   rtems_test_exit(0);
70
71  sc = sysconf( INT_MAX );
72  printf( "sysconf - bad parameter = %ld errno=%s\n", sc, strerror(errno) );
73  if ( (sc != -1) || (errno != EINVAL) )
74   rtems_test_exit(0);
75
76  rtems_test_assert(
77    sysconf( _SC_NPROCESSORS_CONF )
78      == (long) rtems_configuration_get_maximum_processors()
79  );
80
81  rtems_test_assert(
82    sysconf( _SC_NPROCESSORS_ONLN )
83      == (long) rtems_scheduler_get_processor_maximum()
84  );
85
86#if defined(__sparc__)
87  /* Solaris _SC_STACK_PROT - 515 */
88  sc = sysconf( _SC_PAGESIZE );
89  printf( "sysconf - (SPARC only) _SC_STACK_PROT=%ld\n", sc );
90  if ( sc == -1 )
91   rtems_test_exit(0);
92#endif
93
94  TEST_END();
95  rtems_test_exit( 0 );
96
97  return NULL; /* just so the compiler thinks we returned something */
98}
Note: See TracBrowser for help on using the repository browser.