Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
fix pre-v3 boost::filesystem and outdated test
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrey committed Oct 2, 2012
1 parent 3320ae7 commit 7ddd1ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion tests/fixtures/basic_queue.hpp
@@ -1,6 +1,8 @@
#ifndef __TESTS_FIXTURES_BASIC_QUEUE_HPP__
#define __TESTS_FIXTURES_BASIC_QUEUE_HPP__

#include <boost/thread.hpp>
#include <boost/version.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>
Expand All @@ -20,9 +22,13 @@ class basic_queue
basic_queue()
: cb_count_(0),
wait_cb_(boost::bind(&basic_queue::wait_cb, this, _1)),
#if BOOST_VERSION < 104600
tmp_("/tmp/basic_queue_fixture")
#else
tmp_(boost::filesystem::temp_directory_path() / boost::filesystem::unique_path())
#endif
{
boost::filesystem::create_directories(tmp_);
boost::filesystem::create_directory(tmp_);
queue_.reset(new darner::queue(ios_, (tmp_ / "queue").string()));
}

Expand All @@ -39,6 +45,15 @@ class basic_queue
oqs.write(value);
}

void delayed_push_block(std::string& value, const boost::system::error_code& error)
{
// just like above, but blocks for a short while
boost::this_thread::sleep(boost::posix_time::milliseconds(30));
darner::oqstream oqs;
oqs.open(queue_, 1);
oqs.write(value);
}

protected:

void wait_cb(const boost::system::error_code& error)
Expand Down
4 changes: 2 additions & 2 deletions tests/queue.cpp
Expand Up @@ -73,8 +73,8 @@ BOOST_FIXTURE_TEST_CASE( test_multiple_pop_wait, fixtures::basic_queue )
BOOST_FIXTURE_TEST_CASE( test_pop_wait_race, fixtures::basic_queue )
{
string value = "Fur pillows are hard to actually sleep on";
deadline_timer timer(ios_, posix_time::milliseconds(100));
timer.async_wait(bind(&fixtures::basic_queue::delayed_push, this, ref(value), _1));
deadline_timer timer(ios_, posix_time::milliseconds(80));
timer.async_wait(bind(&fixtures::basic_queue::delayed_push_block, this, ref(value), _1));
queue_->wait(100, wait_cb_);
ios_.run();

Expand Down

0 comments on commit 7ddd1ea

Please sign in to comment.