[block-cache] unit tests + debug io_engine and copier
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user