Reset the system last error value before checking it in wxLog test.
Explicitly set the last error indicator to 0 before checking that wxLogSysError() logs it correctly as it wasn't always set to 0 otherwise. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,6 +23,12 @@
|
|||||||
|
|
||||||
#include "wx/scopeguard.h"
|
#include "wx/scopeguard.h"
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
#include "wx/msw/wrapwin.h"
|
||||||
|
#else
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_8
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
// we override deprecated DoLog() and DoLogString() in this test, suppress
|
// we override deprecated DoLog() and DoLogString() in this test, suppress
|
||||||
// warnings about it
|
// warnings about it
|
||||||
@@ -348,11 +354,13 @@ void LogTestCase::SysError()
|
|||||||
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Error (", &s) );
|
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Error (", &s) );
|
||||||
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 17") );
|
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 17") );
|
||||||
|
|
||||||
// The last error code seems to be set somewhere in MinGW CRT as its value
|
// Try to ensure that the system error is 0.
|
||||||
// is just not what we expect (ERROR_INVALID_PARAMETER instead of 0 and 0
|
#ifdef __WINDOWS__
|
||||||
// instead of ERROR_FILE_NOT_FOUND) so exclude the tests which rely on last
|
::SetLastError(0);
|
||||||
// error being preserved for this compiler.
|
#else
|
||||||
#ifndef __MINGW32__
|
errno = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
wxLogSysError("Success");
|
wxLogSysError("Success");
|
||||||
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Success (", &s) );
|
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Success (", &s) );
|
||||||
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 0") );
|
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 0") );
|
||||||
@@ -361,7 +369,6 @@ void LogTestCase::SysError()
|
|||||||
wxLogSysError("Not found");
|
wxLogSysError("Not found");
|
||||||
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Not found (", &s) );
|
CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Not found (", &s) );
|
||||||
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 2") );
|
WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 2") );
|
||||||
#endif // __MINGW32__
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogTestCase::NoWarnings()
|
void LogTestCase::NoWarnings()
|
||||||
|
Reference in New Issue
Block a user