Use byte based tar size encoding above 8GB

This commit is contained in:
Patrick Niklaus 2018-04-10 16:55:48 +00:00 committed by Michael Krasnyk
parent e1efa4c6ab
commit 69fa52a010
2 changed files with 7 additions and 3 deletions

View File

@ -141,7 +141,7 @@ static int header_to_raw(mtar_raw_header_t *rh, const mtar_header_t *h) {
memset(rh, 0, sizeof(*rh)); memset(rh, 0, sizeof(*rh));
/* Store size in ASCII octal digits or base-256 formats */ /* Store size in ASCII octal digits or base-256 formats */
if (sizeof(mtar_size_t) <= 4 || filesize <= (mtar_size_t)0777777777777LL) { if (sizeof(mtar_size_t) <= 4 || filesize <= (mtar_size_t)077777777777LL) {
#ifdef _MSC_VER #ifdef _MSC_VER
sprintf(rh->size, "%llo", h->size); sprintf(rh->size, "%llo", h->size);
#else #else

View File

@ -189,7 +189,10 @@ BOOST_AUTO_TEST_CASE(continue_write_tar_file)
CHECK_EQUAL_COLLECTIONS(result_64bit_vector, vector_64bit); CHECK_EQUAL_COLLECTIONS(result_64bit_vector, vector_64bit);
} }
// This test case is disabled by default because it needs 70 GiB of storage // Boost test only supports disabling was only introduced in 1.59
#if BOOST_VERSION >= 105900
// This test case is disabled by default because it needs 10 GiB of storage
// Enable with ./storage-tests --run_test=tar/write_huge_tar_file
BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled()) BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled())
{ {
TemporaryFile tmp{TEST_DATA_DIR "/tar_huge_write_test.tar"}; TemporaryFile tmp{TEST_DATA_DIR "/tar_huge_write_test.tar"};
@ -202,7 +205,7 @@ BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled())
reference_checksum += value; reference_checksum += value;
return value++; return value++;
}; };
std::uint64_t num_elements = (70ULL * 1024ULL * 1024ULL * 1024ULL) / sizeof(std::uint64_t); std::uint64_t num_elements = (10ULL * 1024ULL * 1024ULL * 1024ULL) / sizeof(std::uint64_t);
writer.WriteStreaming<std::uint64_t>( writer.WriteStreaming<std::uint64_t>(
"huge_data", "huge_data",
boost::make_function_input_iterator(encode_function, boost::infinite()), boost::make_function_input_iterator(encode_function, boost::infinite()),
@ -219,5 +222,6 @@ BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled())
BOOST_CHECK_EQUAL(checksum, reference_checksum); BOOST_CHECK_EQUAL(checksum, reference_checksum);
} }
#endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()