[block-cache] unit tests + debug io_engine and copier

This commit is contained in:
Joe Thornber
2016-06-07 11:12:27 +01:00
parent 34c039d7dc
commit a94bfea798
12 changed files with 560 additions and 150 deletions

View File

@ -3,6 +3,8 @@
#include "persistent-data/space-maps/core.h"
using namespace persistent_data;
using namespace std;
using namespace test;
//----------------------------------------------------------------
@ -21,3 +23,35 @@ test::open_temporary_tm(block_manager<>::ptr bm)
}
//----------------------------------------------------------------
temp_file::temp_file(string const &name_base, unsigned meg_size)
: path_(gen_path(name_base))
{
int fd = ::open(path_.c_str(), O_CREAT | O_RDWR, 0666);
if (fd < 0)
throw runtime_error("couldn't open file");
if (::fallocate(fd, 0, 0, 1024 * 1024 * meg_size))
throw runtime_error("couldn't fallocate");
::close(fd);
}
temp_file::~temp_file()
{
// ::unlink(path_.c_str());
}
string const &
temp_file::get_path() const
{
return path_;
}
string
temp_file::gen_path(string const &base)
{
return string("./") + base + string(".tmp");
}
//----------------------------------------------------------------