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 | |
---|
22 | void *POSIX_Init( |
---|
23 | void *argument |
---|
24 | ) |
---|
25 | { |
---|
26 | long sc; |
---|
27 | |
---|
28 | puts( "\n\n*** POSIX TEST -- SYSCONF ***" ); |
---|
29 | |
---|
30 | puts( "sysconf -- bad configuration parameter - negative" ); |
---|
31 | sc = sysconf( -1 ); |
---|
32 | fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" ); |
---|
33 | |
---|
34 | #if UNUSED |
---|
35 | /* FIXME: This test doesn't make sense. |
---|
36 | * On targets with sizeof(int) < sizeof(long), compilation will fail, |
---|
37 | * On targets with sizeof(int) == sizeof(long) the call is valid. |
---|
38 | */ |
---|
39 | puts( "sysconf -- bad configuration parameter - too large" ); |
---|
40 | sc = sysconf( LONG_MAX ); |
---|
41 | fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" ); |
---|
42 | #endif |
---|
43 | |
---|
44 | sc = sysconf( _SC_CLK_TCK ); |
---|
45 | printf( "sysconf - _SC_CLK_TCK=%ld\n", sc ); |
---|
46 | if ( sc == -1 ) |
---|
47 | rtems_test_exit(0); |
---|
48 | |
---|
49 | sc = sysconf( _SC_OPEN_MAX ); |
---|
50 | printf( "sysconf - _SC_OPEN_MAX=%ld\n", sc ); |
---|
51 | if ( sc == -1 ) |
---|
52 | rtems_test_exit(0); |
---|
53 | |
---|
54 | sc = sysconf( _SC_GETPW_R_SIZE_MAX ); |
---|
55 | printf( "sysconf - _SC_GETPW_R_SIZE_MAX=%ld\n", sc ); |
---|
56 | if ( sc == -1 ) |
---|
57 | rtems_test_exit(0); |
---|
58 | |
---|
59 | sc = sysconf( _SC_PAGESIZE ); |
---|
60 | printf( "sysconf - _SC_PAGESIZE=%ld\n", sc ); |
---|
61 | if ( sc == -1 ) |
---|
62 | rtems_test_exit(0); |
---|
63 | |
---|
64 | sc = getpagesize(); |
---|
65 | printf( "getpagesize = %ld\n", sc ); |
---|
66 | if ( sc == -1 ) |
---|
67 | rtems_test_exit(0); |
---|
68 | |
---|
69 | sc = sysconf( INT_MAX ); |
---|
70 | printf( "sysconf - bad parameter = %ld errno=%s\n", sc, strerror(errno) ); |
---|
71 | if ( (sc != -1) || (errno != EINVAL) ) |
---|
72 | rtems_test_exit(0); |
---|
73 | |
---|
74 | #if defined(__sparc__) |
---|
75 | /* Solaris _SC_STACK_PROT - 515 */ |
---|
76 | sc = sysconf( _SC_PAGESIZE ); |
---|
77 | printf( "sysconf - (SPARC only) _SC_STACK_PROT=%ld\n", sc ); |
---|
78 | if ( sc == -1 ) |
---|
79 | rtems_test_exit(0); |
---|
80 | #endif |
---|
81 | |
---|
82 | puts( "*** END OF POSIX TEST SYSCONF ***" ); |
---|
83 | rtems_test_exit( 0 ); |
---|
84 | |
---|
85 | return NULL; /* just so the compiler thinks we returned something */ |
---|
86 | } |
---|