1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms, with or without |
---|
8 | * modification, are permitted provided that the following conditions |
---|
9 | * are met: |
---|
10 | * 1. Redistributions of source code must retain the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer. |
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer in the |
---|
14 | * documentation and/or other materials provided with the distribution. |
---|
15 | * |
---|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
26 | * POSSIBILITY OF SUCH DAMAGE. |
---|
27 | */ |
---|
28 | |
---|
29 | #ifdef HAVE_CONFIG_H |
---|
30 | #include "config.h" |
---|
31 | #endif |
---|
32 | |
---|
33 | #define CONFIGURE_INIT |
---|
34 | #include "system.h" |
---|
35 | #include "tmacros.h" |
---|
36 | |
---|
37 | #include <unistd.h> |
---|
38 | #include <stdint.h> |
---|
39 | #include <errno.h> |
---|
40 | |
---|
41 | const char rtems_test_name[] = "PSXSYSCONF"; |
---|
42 | |
---|
43 | void *POSIX_Init( |
---|
44 | void *argument |
---|
45 | ) |
---|
46 | { |
---|
47 | long sc; |
---|
48 | |
---|
49 | TEST_BEGIN(); |
---|
50 | |
---|
51 | puts( "sysconf -- bad configuration parameter - negative" ); |
---|
52 | sc = sysconf( -1 ); |
---|
53 | fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" ); |
---|
54 | |
---|
55 | #if UNUSED |
---|
56 | /* FIXME: This test doesn't make sense. |
---|
57 | * On targets with sizeof(int) < sizeof(long), compilation will fail, |
---|
58 | * On targets with sizeof(int) == sizeof(long) the call is valid. |
---|
59 | */ |
---|
60 | puts( "sysconf -- bad configuration parameter - too large" ); |
---|
61 | sc = sysconf( LONG_MAX ); |
---|
62 | fatal_posix_service_status_errno( sc, EINVAL, "bad conf name" ); |
---|
63 | #endif |
---|
64 | |
---|
65 | sc = sysconf( _SC_CLK_TCK ); |
---|
66 | printf( "sysconf - _SC_CLK_TCK=%ld\n", sc ); |
---|
67 | if ( sc == -1 ) |
---|
68 | rtems_test_exit(0); |
---|
69 | |
---|
70 | sc = sysconf( _SC_OPEN_MAX ); |
---|
71 | printf( "sysconf - _SC_OPEN_MAX=%ld\n", sc ); |
---|
72 | if ( sc == -1 ) |
---|
73 | rtems_test_exit(0); |
---|
74 | |
---|
75 | sc = sysconf( _SC_GETPW_R_SIZE_MAX ); |
---|
76 | printf( "sysconf - _SC_GETPW_R_SIZE_MAX=%ld\n", sc ); |
---|
77 | if ( sc == -1 ) |
---|
78 | rtems_test_exit(0); |
---|
79 | |
---|
80 | sc = sysconf( _SC_PAGESIZE ); |
---|
81 | printf( "sysconf - _SC_PAGESIZE=%ld\n", sc ); |
---|
82 | if ( sc == -1 ) |
---|
83 | rtems_test_exit(0); |
---|
84 | |
---|
85 | sc = getpagesize(); |
---|
86 | printf( "getpagesize = %ld\n", sc ); |
---|
87 | if ( sc == -1 ) |
---|
88 | rtems_test_exit(0); |
---|
89 | |
---|
90 | sc = sysconf( INT_MAX ); |
---|
91 | printf( "sysconf - bad parameter = %ld errno=%s\n", sc, strerror(errno) ); |
---|
92 | if ( (sc != -1) || (errno != EINVAL) ) |
---|
93 | rtems_test_exit(0); |
---|
94 | |
---|
95 | rtems_test_assert( |
---|
96 | sysconf( _SC_NPROCESSORS_CONF ) |
---|
97 | == (long) rtems_configuration_get_maximum_processors() |
---|
98 | ); |
---|
99 | |
---|
100 | rtems_test_assert( |
---|
101 | sysconf( _SC_NPROCESSORS_ONLN ) |
---|
102 | == (long) rtems_scheduler_get_processor_maximum() |
---|
103 | ); |
---|
104 | |
---|
105 | TEST_END(); |
---|
106 | rtems_test_exit( 0 ); |
---|
107 | |
---|
108 | return NULL; /* just so the compiler thinks we returned something */ |
---|
109 | } |
---|