Add a test that verifies that canceling a task that has a mutex locked cleans up properly (it does)

This commit is contained in:
Eric Frias 2014-08-21 15:22:43 -04:00
parent 362884fc52
commit ed2f543c24

View file

@ -2,10 +2,23 @@
#include <boost/test/unit_test.hpp>
#include <fc/thread/thread.hpp>
#include <fc/thread/scoped_lock.hpp>
#include <fc/log/logger.hpp>
#include <fc/thread/mutex.hpp>
#include <fc/exception/exception.hpp>
#include <fc/thread/non_preemptable_scope_check.hpp>
BOOST_AUTO_TEST_CASE( leave_mutex_locked )
{
{
fc::mutex test_mutex;
fc::future<void> test_task = fc::async([&](){ fc::scoped_lock<fc::mutex> test_lock(test_mutex); for (int i = 0; i < 10; ++i) fc::usleep(fc::seconds(1));});
fc::usleep(fc::seconds(3));
test_task.cancel_and_wait();
}
BOOST_TEST_PASSPOINT();
}
BOOST_AUTO_TEST_CASE( test_non_preemptable_assertion )
{
return; // this isn't a real test, because the thing it tries to test works by asserting, not by throwing