diff options
author | olli <olli@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-10-26 08:34:55 +0000 |
---|---|---|
committer | olli <olli@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-10-26 08:34:55 +0000 |
commit | 12a6697680b2cc572a81815874529b4f569ce14c (patch) | |
tree | e1e209d1f2bdf3761863539285948ea34920510d /ACE | |
parent | da0c420dd206076e0c6ca6994f41853aebf77d46 (diff) | |
download | ATCD-12a6697680b2cc572a81815874529b4f569ce14c.tar.gz |
ChangeLogTag: Mon Oct 26 08:32:08 UTC 2009 Olli Savia <ops@iki.fi>
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ChangeLog | 7 | ||||
-rw-r--r-- | ACE/tests/OS_Test.cpp | 50 |
2 files changed, 54 insertions, 3 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index c77984e828b..c7c3e8cbcf6 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 26 08:32:08 UTC 2009 Olli Savia <ops@iki.fi> + + * tests/OS_Test.cpp: + Improved test to detect if std{out,err} is not associated + with an output stream. This may happen with Windows application + without a console window. + Mon Oct 26 07:48:19 UTC 2009 Olli Savia <ops@iki.fi> * ace/config-win32-msvc-10.h: diff --git a/ACE/tests/OS_Test.cpp b/ACE/tests/OS_Test.cpp index 806bd468520..484136a892d 100644 --- a/ACE/tests/OS_Test.cpp +++ b/ACE/tests/OS_Test.cpp @@ -76,21 +76,65 @@ fileno_test (void) int test_status = 0; - if (ACE_OS::fileno (stdin) != ACE_STDIN) + ACE_HANDLE fn; + + fn = ACE_OS::fileno (stdin); + if (fn == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("fileno returned -1 (stdin).\n"))); + test_status = -1; + } + else if (fn != ACE_STDIN) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("stdin test failed.\n"))); test_status = -1; } - if (ACE_OS::fileno (stdout) != ACE_STDOUT) + + fn = ACE_OS::fileno (stdout); + if (fn == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("fileno returned -1 (stdout).\n"))); + test_status = -1; + } + else +#if defined (ACE_WIN32) + // Check if stdout is not associated with an output stream. + // This not an error. + if (fn == -2) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("fileno returned -2 (stdout).\n"))); + } + else +#else + if (fn != ACE_STDOUT) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("stdout test failed.\n"))); test_status = -1; } - if (ACE_OS::fileno (stderr) != ACE_STDERR) +#endif + + fn = ACE_OS::fileno (stderr); + if (fn == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("fileno returned -1 (stderr).\n"))); + test_status = -1; + } + else +#if defined (ACE_WIN32) + // Check if stderr is not associated with an output stream. + // This not an error. + if (fn == -2) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("fileno returned -2 (stderr).\n"))); + } + else +#else + if (fn != ACE_STDERR) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("stderr test failed.\n"))); test_status = -1; } +#endif return test_status; } |