Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Aio_Platform_Test.cpp
blob96f71dd66d2654b328792fd52fe7287d202cad0d
2 //=============================================================================
3 /**
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
10 * features further.
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 ()
23 ACE_DEBUG ((LM_DEBUG,
24 "Doing <sysconf> calls to know the run-time values of POSIX feature limits\n"));
26 // Call sysconf to find out runtime values.
27 errno = 0;
28 #if defined (_SC_LISTIO_AIO_MAX)
29 ACE_DEBUG ((LM_DEBUG,
30 "Runtime value of LISTIO_AIO_MAX is %d, errno = %d, Minimum is 2\n",
31 ACE_OS::sysconf (_SC_LISTIO_AIO_MAX),
32 errno));
33 #elif defined (_SC_AIO_LISTIO_MAX)
34 ACE_DEBUG ((LM_DEBUG,
35 "Runtime value of AIO_LISTIO_MAX is %d, errno = %d, Minimum is 2\n",
36 ACE_OS::sysconf (_SC_AIO_LISTIO_MAX),
37 errno));
38 #else
39 ACE_ERROR ((LM_ERROR,
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)
45 errno = 0;
46 ACE_DEBUG ((LM_DEBUG,
47 "Runtime value of AIO_MAX is %d, errno = %d, Minimum is 1\n",
48 ACE_OS::sysconf (_SC_AIO_MAX),
49 errno));
50 #else
51 ACE_ERROR ((LM_ERROR,
52 "_SC_AIO_MAX does not exist on this platform\n"));
53 #endif /* _SC_AIO_MAX */
55 #if defined (_SC_ASYNCHRONOUS_IO)
56 errno = 0;
57 ACE_DEBUG ((LM_DEBUG,
58 "Runtime value of _POSIX_ASYNCHRONOUS_IO is %d, errno = %d\n",
59 ACE_OS::sysconf (_SC_ASYNCHRONOUS_IO),
60 errno));
61 #else /* Not _SC_ASYNCHRONOUS_IO */
62 ACE_ERROR ((LM_ERROR,
63 "_SC_ASYNCHRONOUS_IO does not exist on this platform\n"));
64 #endif /* _SC_ASYNCHRONOUS_IO */
66 #if defined (_SC_REALTIME_SIGNALS)
67 errno = 0;
68 ACE_DEBUG ((LM_DEBUG,
69 "Runtime value of _POSIX_REALTIME_SIGNALS is %d, errno = %d\n",
70 ACE_OS::sysconf (_SC_REALTIME_SIGNALS),
71 errno));
72 #else /* Not _SC_REALTIME_SIGNALS */
73 ACE_ERROR ((LM_ERROR,
74 "_SC_REALTIME_SIGNALS does not exist on this platform\n"));
75 #endif /* _SC_REALTIME_SIGNALS */
78 #if defined (_SC_RTSIG_MAX)
79 errno = 0;
80 ACE_DEBUG ((LM_DEBUG,
81 "Runtime value of RTSIG_MAX %d, Errno = %d, Minimum is 8\n",
82 ACE_OS::sysconf (_SC_RTSIG_MAX),
83 errno));
84 #else /* Not _SC_RTSIG_MAX */
85 ACE_ERROR ((LM_ERROR,
86 "_SC_RTSIG_MAX does not exist on this platform\n"));
87 #endif /* _SC_RTSIG_MAX */
89 #if defined (_SC_SIGQUEUE_MAX)
90 errno = 0;
91 ACE_DEBUG ((LM_DEBUG,
92 "Runtime value of SIGQUEUE_MAX %d, Errno = %d, Minimum is 32\n",
93 ACE_OS::sysconf (_SC_SIGQUEUE_MAX),
94 errno));
95 #else /* Not _SC_SIGQUEUE_MAX */
96 ACE_ERROR ((LM_ERROR,
97 "_SC_SIGQUEUE_MAX does not exist on this platform\n"));
98 #endif /* _SC_SIGQUEUE_MAX */
99 return 0;
101 #endif /* _POSIX_ASYNCHRONOUS_IO */
103 static int
104 have_asynchio ()
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"));
111 return -1;
112 #else /* Not _POSIX_ASYNC_IO == -1 */
113 ACE_DEBUG ((LM_DEBUG,
114 "_POSIX_ASYNC_IO = %d\n ASYNCH IO is supported FULLY\n",
115 _POSIX_ASYNC_IO));
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));
135 #else
136 ACE_DEBUG ((LM_DEBUG,
137 "No value for _POSIX_AIO_LISTIO_MAX\n"));
138 #endif
140 #if defined(_POSIX_AIO_MAX)
141 ACE_DEBUG ((LM_DEBUG,
142 "Number of simultaneous asynchronous I/Os: "
143 "Minimum is 1: "
144 "_POSIX_AIO_MAX = %d\n",
145 _POSIX_AIO_MAX));
146 #else
147 ACE_DEBUG ((LM_DEBUG,
148 "No value for _POSIX_AIO_MAX\n"));
149 #endif
151 // @@ Debugging.
152 ACE_DEBUG ((LM_DEBUG,
153 "Before do_sysconf : Errno %d\n",
154 errno));
156 // Check and print the run time values.
157 do_sysconf ();
159 // @@ Debugging.
160 ACE_DEBUG ((LM_DEBUG,
161 "After do_sysconf: Errno : %d\n", errno));
163 return 0;
165 #else /* Not _POSIX_ASYNCHRONOUS_IO */
166 ACE_DEBUG ((LM_DEBUG,
167 "No support._POSIX_ASYNCHRONOUS_IO itself is not defined\n"));
168 return -1;
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.
178 errno = 0;
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"));
185 else
186 ACE_ERROR ((LM_INFO,
187 "AIO not supported on this platform\n"));
189 ACE_END_TEST;
191 return 0;