Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Bug_3758_Regression_Test.cpp
blob0c4197cc8bc4514dc5c112253ab8949194c8b68f
1 // ============================================================================
2 //
3 // = LIBRARY
4 // tests
5 //
6 // = DESCRIPTION
7 // This simple test exercises ACE_OS::fileno.
8 //
9 // = AUTHOR
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) \
20 ((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()
25 int
26 fileno_test ()
28 ACE_DEBUG ((LM_DEBUG,
29 ACE_TEXT ("Testing fileno method\n")));
31 int test_status = 0;
33 ACE_HANDLE fn;
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")));
39 test_status = -1;
41 else if (fn != ACE_STDIN)
43 ACE_ERROR ((LM_ERROR, ACE_TEXT ("stdin test failed.\n")));
44 test_status = -1;
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")));
51 test_status = -1;
53 else
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")));
61 else
62 #endif
63 if (fn != ACE_STDOUT)
65 ACE_ERROR ((LM_ERROR, ACE_TEXT ("stdout test failed.\n")));
66 test_status = -1;
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")));
73 test_status = -1;
75 else
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")));
83 else
84 #endif
85 if (fn != ACE_STDERR)
87 ACE_ERROR ((LM_ERROR, ACE_TEXT ("stderr test failed.\n")));
88 test_status = -1;
91 return test_status;
94 int
95 run_main (int, ACE_TCHAR *[])
97 ACE_START_TEST (ACE_TEXT ("Bug_3758_Regression_Test"));
99 int status = 0;
100 int result;
102 if ((result = fileno_test ()) != 0)
103 status = -1;
105 ACE_END_TEST;
106 return status;
108 #undef THIS_IS_NOT_AN_ASSERT_IT_IS_A_NON_DEBUG_TEST_AS_WELL