improve storage unit tests

This commit is contained in:
Arvid Norberg 2014-03-07 08:39:55 +00:00
parent b643962bfe
commit e332167ddd
2 changed files with 17 additions and 3 deletions

View File

@ -493,7 +493,14 @@ void create_random_files(std::string const& path, const int file_sizes[], int nu
std::generate(random_data, random_data + 300000, random_byte);
char filename[200];
snprintf(filename, sizeof(filename), "test%d", i);
std::string full_path = combine_path(path, filename);
char dirname[200];
snprintf(dirname, sizeof(dirname), "test_dir%d", i / 5);
std::string full_path = combine_path(path, dirname);
error_code ec;
create_directory(full_path, ec);
full_path = combine_path(full_path, filename);
int to_write = file_sizes[i];
file f(full_path, file::write_only, ec);
if (ec) fprintf(stderr, "failed to create file \"%s\": (%d) %s\n"

View File

@ -114,8 +114,12 @@ void test_checking(bool read_only_files, bool corrupt_files = false)
{
char name[1024];
snprintf(name, sizeof(name), "test%d", i);
std::string path = combine_path("tmp1_checking", "test_torrent_dir");
char dirname[200];
snprintf(dirname, sizeof(dirname), "test_dir%d", i / 5);
std::string path = combine_path(combine_path("tmp1_checking", "test_torrent_dir"), dirname);
path = combine_path(path, name);
#ifdef TORRENT_WINDOWS
SetFileAttributesA(path.c_str(), FILE_ATTRIBUTE_READONLY);
#else
@ -173,7 +177,10 @@ void test_checking(bool read_only_files, bool corrupt_files = false)
{
char name[1024];
snprintf(name, sizeof(name), "test%d", i);
std::string path = combine_path("tmp1_checking", "test_torrent_dir");
char dirname[200];
snprintf(dirname, sizeof(dirname), "test_dir%d", i / 5);
std::string path = combine_path(combine_path("tmp1_checking", "test_torrent_dir"), dirname);
path = combine_path(path, name);
#ifdef TORRENT_WINDOWS
SetFileAttributesA(path.c_str(), FILE_ATTRIBUTE_NORMAL);