2 //=============================================================================
4 * @file Aio_Platform_Test.cpp
6 * Testing the platform for POSIX Asynchronous I/O. Basically
7 * prints the predefined constants and also checks for their run
8 * time values. If this test succeeds further tests at
9 * $ACE_ROOT/examples/Reactor/Proactor can be used to test the
12 * @author Programming for the Real World. Bill O. GallMeister. Modified by Alexander Babu Arulanthu <alex@cs.wustl.edu>
14 //=============================================================================
17 #include "test_config.h"
18 #include "ace/OS_NS_unistd.h"
20 #if defined (_POSIX_ASYNCHRONOUS_IO)
21 static int do_sysconf ()
24 "Doing <sysconf> calls to know the run-time values of POSIX feature limits\n"));
26 // Call sysconf to find out runtime values.
28 #if defined (_SC_LISTIO_AIO_MAX)
30 "Runtime value of LISTIO_AIO_MAX is %d, errno = %d, Minimum is 2\n",
31 ACE_OS::sysconf (_SC_LISTIO_AIO_MAX
),
33 #elif defined (_SC_AIO_LISTIO_MAX)
35 "Runtime value of AIO_LISTIO_MAX is %d, errno = %d, Minimum is 2\n",
36 ACE_OS::sysconf (_SC_AIO_LISTIO_MAX
),
40 "_SC_LISTIO_AIO_MAX or _SC_AIO_LISTIO_MAX"
41 " do not exist on this platform\n"));
42 #endif /* _SC_LISTIO_AIO_MAX */
44 #if defined (_SC_AIO_MAX)
47 "Runtime value of AIO_MAX is %d, errno = %d, Minimum is 1\n",
48 ACE_OS::sysconf (_SC_AIO_MAX
),
52 "_SC_AIO_MAX does not exist on this platform\n"));
53 #endif /* _SC_AIO_MAX */
55 #if defined (_SC_ASYNCHRONOUS_IO)
58 "Runtime value of _POSIX_ASYNCHRONOUS_IO is %d, errno = %d\n",
59 ACE_OS::sysconf (_SC_ASYNCHRONOUS_IO
),
61 #else /* Not _SC_ASYNCHRONOUS_IO */
63 "_SC_ASYNCHRONOUS_IO does not exist on this platform\n"));
64 #endif /* _SC_ASYNCHRONOUS_IO */
66 #if defined (_SC_REALTIME_SIGNALS)
69 "Runtime value of _POSIX_REALTIME_SIGNALS is %d, errno = %d\n",
70 ACE_OS::sysconf (_SC_REALTIME_SIGNALS
),
72 #else /* Not _SC_REALTIME_SIGNALS */
74 "_SC_REALTIME_SIGNALS does not exist on this platform\n"));
75 #endif /* _SC_REALTIME_SIGNALS */
78 #if defined (_SC_RTSIG_MAX)
81 "Runtime value of RTSIG_MAX %d, Errno = %d, Minimum is 8\n",
82 ACE_OS::sysconf (_SC_RTSIG_MAX
),
84 #else /* Not _SC_RTSIG_MAX */
86 "_SC_RTSIG_MAX does not exist on this platform\n"));
87 #endif /* _SC_RTSIG_MAX */
89 #if defined (_SC_SIGQUEUE_MAX)
92 "Runtime value of SIGQUEUE_MAX %d, Errno = %d, Minimum is 32\n",
93 ACE_OS::sysconf (_SC_SIGQUEUE_MAX
),
95 #else /* Not _SC_SIGQUEUE_MAX */
97 "_SC_SIGQUEUE_MAX does not exist on this platform\n"));
98 #endif /* _SC_SIGQUEUE_MAX */
101 #endif /* _POSIX_ASYNCHRONOUS_IO */
106 #if defined (_POSIX_ASYNCHRONOUS_IO)
107 #if defined (_POSIX_ASYNC_IO)
108 #if _POSIX_ASYNC_IO == -1
109 ACE_DEBUG ((LM_DEBUG
,
110 "_POSIX_ASYNC_IO = -1.. ASYNCH IO NOT supported at all\n"));
112 #else /* Not _POSIX_ASYNC_IO == -1 */
113 ACE_DEBUG ((LM_DEBUG
,
114 "_POSIX_ASYNC_IO = %d\n ASYNCH IO is supported FULLY\n",
116 #endif /* _POSIX_ASYNC_IO == -1 */
118 #else /* Not defined _POSIX_ASYNC_IO */
119 ACE_ERROR ((LM_DEBUG
,
120 "_POSIX_ASYNC_IO is not defined.\n"));
121 ACE_DEBUG ((LM_DEBUG
,
122 "AIO might *not* be supported on all the paths\n"));
123 #endif /* _POSIX_ASYNC_IO */
125 // System defined POSIX Values.
126 ACE_DEBUG ((LM_DEBUG
,
127 "System claims to have POSIX_ASYNCHRONOUS_IO\n"));
129 #if defined(_POSIX_AIO_LISTIO_MAX)
130 ACE_DEBUG ((LM_DEBUG
,
131 "Number of operations in one listio: "
132 "Minimum value is 2: "
133 "_POSIX_AIO_LISTIO_MAX = %d\n",
134 _POSIX_AIO_LISTIO_MAX
));
136 ACE_DEBUG ((LM_DEBUG
,
137 "No value for _POSIX_AIO_LISTIO_MAX\n"));
140 #if defined(_POSIX_AIO_MAX)
141 ACE_DEBUG ((LM_DEBUG
,
142 "Number of simultaneous asynchronous I/Os: "
144 "_POSIX_AIO_MAX = %d\n",
147 ACE_DEBUG ((LM_DEBUG
,
148 "No value for _POSIX_AIO_MAX\n"));
152 ACE_DEBUG ((LM_DEBUG
,
153 "Before do_sysconf : Errno %d\n",
156 // Check and print the run time values.
160 ACE_DEBUG ((LM_DEBUG
,
161 "After do_sysconf: Errno : %d\n", errno
));
165 #else /* Not _POSIX_ASYNCHRONOUS_IO */
166 ACE_DEBUG ((LM_DEBUG
,
167 "No support._POSIX_ASYNCHRONOUS_IO itself is not defined\n"));
169 #endif /* _POSIX_ASYNCHRONOUS_IO */
173 run_main (int, ACE_TCHAR
*[])
175 ACE_START_TEST (ACE_TEXT ("Aio_Platform_Test"));
177 // Test the #defined and constants and runtime values.
179 if (have_asynchio () == 0)
180 ACE_DEBUG ((LM_DEBUG
,
181 "Basic test successful"
182 "Check the run time values of the predefined constants\n"
183 "ACE_HAS_AIO_CALLS can be defined for this platform\n"
184 "Further tests at $ACE_ROOT/examples/Reactor/Proactor\n"));
187 "AIO not supported on this platform\n"));