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