mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
fix: don't create all 0-byte files in MakemetaTest::makeRandomFiles()
(#6394)
* fix: randomly failing `MakemetaTest.nameIsRootSingleFile` * fix: eliminate remaining probability for `MakemetaTest.nameIsRootSingleFile` to fail
This commit is contained in:
parent
bfa5da9705
commit
45298e5a4e
1 changed files with 13 additions and 2 deletions
|
@ -44,10 +44,21 @@ protected:
|
|||
{
|
||||
auto files = std::vector<std::pair<std::string, std::vector<std::byte>>>{};
|
||||
|
||||
for (size_t i = 0; i < n_files; ++i)
|
||||
auto file_sizes = std::vector<size_t>(n_files);
|
||||
EXPECT_EQ(std::size(file_sizes), n_files);
|
||||
while (
|
||||
std::all_of(std::begin(file_sizes), std::end(file_sizes), [](size_t const file_size) { return file_size == 0U; }))
|
||||
{
|
||||
for (auto& file_size : file_sizes)
|
||||
{
|
||||
file_size = tr_rand_int(max_size);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0U; i < n_files; ++i)
|
||||
{
|
||||
auto payload = std::vector<std::byte>{};
|
||||
payload.resize(static_cast<size_t>(tr_rand_int(max_size)));
|
||||
payload.resize(file_sizes[i]);
|
||||
tr_rand_buffer(std::data(payload), std::size(payload));
|
||||
|
||||
auto filename = tr_pathbuf{ top, '/', "test.XXXXXX" };
|
||||
|
|
Loading…
Reference in a new issue