PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/testsuites/psxtests/psxsysconf/init.c

https://bitbucket.org/cdcs/leon-rtems
C | 88 lines | 57 code | 16 blank | 15 comment | 16 complexity | 2fb9c84e29ce6c22939d0272d184a99b MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  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.com/license/LICENSE.
  8. *
  9. * $Id$
  10. */
  11. #ifdef HAVE_CONFIG_H
  12. #include "config.h"
  13. #endif
  14. #define CONFIGURE_INIT
  15. #include "system.h"
  16. #include "tmacros.h"
  17. #include <unistd.h>
  18. #include <stdint.h>
  19. #include <errno.h>
  20. void *POSIX_Init(
  21. void *argument
  22. )
  23. {
  24. long sc;
  25. puts( "\n\n*** POSIX TEST -- SYSCONF ***" );
  26. puts( "sysconf -- bad configuration parameter - negative" );
  27. sc = sysconf( -1 );
  28. fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" );
  29. #if UNUSED
  30. /* FIXME: This test doesn't make sense.
  31. * On targets with sizeof(int) < sizeof(long), compilation will fail,
  32. * On targets with sizeof(int) == sizeof(long) the call is valid.
  33. */
  34. puts( "sysconf -- bad configuration parameter - too large" );
  35. sc = sysconf( LONG_MAX );
  36. fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" );
  37. #endif
  38. sc = sysconf( _SC_CLK_TCK );
  39. printf( "sysconf - _SC_CLK_TCK=%ld\n", sc );
  40. if ( sc == -1 )
  41. rtems_test_exit(0);
  42. sc = sysconf( _SC_OPEN_MAX );
  43. printf( "sysconf - _SC_OPEN_MAX=%ld\n", sc );
  44. if ( sc == -1 )
  45. rtems_test_exit(0);
  46. sc = sysconf( _SC_GETPW_R_SIZE_MAX );
  47. printf( "sysconf - _SC_GETPW_R_SIZE_MAX=%ld\n", sc );
  48. if ( sc == -1 )
  49. rtems_test_exit(0);
  50. sc = sysconf( _SC_PAGESIZE );
  51. printf( "sysconf - _SC_PAGESIZE=%ld\n", sc );
  52. if ( sc == -1 )
  53. rtems_test_exit(0);
  54. sc = getpagesize();
  55. printf( "getpagesize = %ld\n", sc );
  56. if ( sc == -1 )
  57. rtems_test_exit(0);
  58. sc = sysconf( INT_MAX );
  59. printf( "sysconf - bad parameter = %ld errno=%s\n", sc, strerror(errno) );
  60. if ( (sc != -1) || (errno != EINVAL) )
  61. rtems_test_exit(0);
  62. #if defined(__sparc__)
  63. /* Solaris _SC_STACK_PROT - 515 */
  64. sc = sysconf( _SC_PAGESIZE );
  65. printf( "sysconf - (SPARC only) _SC_STACK_PROT=%ld\n", sc );
  66. if ( sc == -1 )
  67. rtems_test_exit(0);
  68. #endif
  69. puts( "*** END OF POSIX TEST SYSCONF ***" );
  70. rtems_test_exit( 0 );
  71. return NULL; /* just so the compiler thinks we returned something */
  72. }