stdout non-blocking fix for tests
This commit is contained in:
parent
c4422cd34e
commit
3474346a3d
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <iostream>
|
||||
#include <boost/config.hpp>
|
||||
#include <fcntl.h>
|
||||
|
||||
int test_main();
|
||||
|
||||
|
@ -43,8 +44,10 @@ int main()
|
|||
// on darwin, stdout is set to non-blocking mode by default
|
||||
// which sometimes causes tests to fail with EAGAIN just
|
||||
// by printing logs
|
||||
int flags = fcntl(stdout, F_GETFL, 0);
|
||||
fcntl(stdout, F_SETFL, flags & ~O_NONBLOCK);
|
||||
int flags = fcntl(fileno(stdout), F_GETFL, 0);
|
||||
fcntl(fileno(stdout), F_SETFL, flags & ~O_NONBLOCK);
|
||||
flags = fcntl(fileno(stderr), F_GETFL, 0);
|
||||
fcntl(fileno(stderr), F_SETFL, flags & ~O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
@ -52,19 +55,21 @@ int main()
|
|||
{
|
||||
#endif
|
||||
test_main();
|
||||
return tests_failure ? 1 : 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
std::cerr << "Terminated with exception: \"" << e.what() << "\"\n";
|
||||
return 1;
|
||||
tests_failure = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Terminated with unknown exception\n";
|
||||
return 1;
|
||||
tests_failure = true;
|
||||
}
|
||||
#endif
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
return tests_failure ? 1 : 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue