|
3 | 3 | #include "../common/range_tools.hpp" |
4 | 4 | #include "../common/temporary_file.hpp" |
5 | 5 |
|
| 6 | +#include <boost/function_output_iterator.hpp> |
| 7 | +#include <boost/iterator/function_input_iterator.hpp> |
6 | 8 | #include <boost/test/unit_test.hpp> |
7 | 9 |
|
8 | 10 | BOOST_AUTO_TEST_SUITE(tar) |
@@ -187,4 +189,35 @@ BOOST_AUTO_TEST_CASE(continue_write_tar_file) |
187 | 189 | CHECK_EQUAL_COLLECTIONS(result_64bit_vector, vector_64bit); |
188 | 190 | } |
189 | 191 |
|
| 192 | +// This test case is disabled by default because it needs 70 GiB of storage |
| 193 | +BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled()) |
| 194 | +{ |
| 195 | + TemporaryFile tmp{TEST_DATA_DIR "/tar_huge_write_test.tar"}; |
| 196 | + |
| 197 | + std::uint64_t reference_checksum = 0; |
| 198 | + { |
| 199 | + storage::tar::FileWriter writer(tmp.path, storage::tar::FileWriter::GenerateFingerprint); |
| 200 | + std::uint64_t value = 0; |
| 201 | + const std::function<std::uint64_t()> encode_function = [&]() -> std::uint64_t { |
| 202 | + reference_checksum += value; |
| 203 | + return value++; |
| 204 | + }; |
| 205 | + std::uint64_t num_elements = (70ULL * 1024ULL * 1024ULL * 1024ULL) / sizeof(std::uint64_t); |
| 206 | + writer.WriteStreaming<std::uint64_t>( |
| 207 | + "huge_data", |
| 208 | + boost::make_function_input_iterator(encode_function, boost::infinite()), |
| 209 | + num_elements); |
| 210 | + } |
| 211 | + |
| 212 | + std::uint64_t checksum = 0; |
| 213 | + { |
| 214 | + storage::tar::FileReader reader(tmp.path, storage::tar::FileReader::VerifyFingerprint); |
| 215 | + reader.ReadStreaming<std::uint64_t>( |
| 216 | + "huge_data", |
| 217 | + boost::make_function_output_iterator([&](const auto &value) { checksum += value; })); |
| 218 | + } |
| 219 | + |
| 220 | + BOOST_CHECK_EQUAL(checksum, reference_checksum); |
| 221 | +} |
| 222 | + |
190 | 223 | BOOST_AUTO_TEST_SUITE_END() |
0 commit comments