Permalink
Browse files

fix pre-v3 boost::filesystem and outdated test

  • Loading branch information...
1 parent 3320ae7 commit 7ddd1ea44adb805950a6a36088dea7267017ad8a @erikfrey erikfrey committed Oct 2, 2012
Showing with 18 additions and 3 deletions.
  1. +16 −1 tests/fixtures/basic_queue.hpp
  2. +2 −2 tests/queue.cpp
@@ -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>
@@ -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()));
}
@@ -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)
View
@@ -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();

0 comments on commit 7ddd1ea

Please sign in to comment.