1 // ============================================================================
7 // This simple test exercises ACE_OS::fileno.
10 // Olli Savia <ops@iki.fi>
12 // ============================================================================
14 #include "test_config.h"
15 #include "ace/OS_NS_stdio.h"
16 #include "ace/OS_NS_unistd.h"
18 #undef THIS_IS_NOT_AN_ASSERT_IT_IS_A_NON_DEBUG_TEST_AS_WELL
19 #define THIS_IS_NOT_AN_ASSERT_IT_IS_A_NON_DEBUG_TEST_AS_WELL(X) \
21 ? static_cast<void>(0) \
22 : ACE_VERSIONED_NAMESPACE_NAME::__ace_assert(__FILE__, __LINE__, ACE_TEXT_CHAR_TO_TCHAR (#X)))
24 // Test ACE_OS::fileno()
29 ACE_TEXT ("Testing fileno method\n")));
35 fn
= ACE_OS::fileno (stdin
);
36 if (fn
== ACE_INVALID_HANDLE
)
38 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("fileno(stdin) returned ACE_INVALID_HANDLE.\n")));
41 else if (fn
!= ACE_STDIN
)
43 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("stdin test failed.\n")));
47 fn
= ACE_OS::fileno (stdout
);
48 if (fn
== ACE_INVALID_HANDLE
)
50 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("fileno(stdout) returned ACE_INVALID_HANDLE.\n")));
54 #if defined (ACE_WIN32)
55 // Check if stdout is not associated with an output stream.
56 // This is not an error.
57 if (fn
== reinterpret_cast<ACE_HANDLE
>(-2))
59 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("fileno(stdout) returned -2.\n")));
65 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("stdout test failed.\n")));
69 fn
= ACE_OS::fileno (stderr
);
70 if (fn
== ACE_INVALID_HANDLE
)
72 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("fileno(stderr) returned ACE_INVALID_HANDLE.\n")));
76 #if defined (ACE_WIN32)
77 // Check if stderr is not associated with an output stream.
78 // This is not an error.
79 if (fn
== reinterpret_cast<ACE_HANDLE
>(-2))
81 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("fileno(stderr) returned -2.\n")));
87 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("stderr test failed.\n")));
95 run_main (int, ACE_TCHAR
*[])
97 ACE_START_TEST (ACE_TEXT ("Bug_3758_Regression_Test"));
102 if ((result
= fileno_test ()) != 0)
108 #undef THIS_IS_NOT_AN_ASSERT_IT_IS_A_NON_DEBUG_TEST_AS_WELL