Skip to content

Commit

Permalink
Use byte based tar size encoding above 8GB
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarex authored and oxidase committed Apr 10, 2018
1 parent e1efa4c commit 69fa52a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion third_party/microtar/src/microtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int header_to_raw(mtar_raw_header_t *rh, const mtar_header_t *h) {
memset(rh, 0, sizeof(*rh));

/* 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
sprintf(rh->size, "%llo", h->size);
#else
Expand Down
8 changes: 6 additions & 2 deletions unit_tests/storage/tar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ BOOST_AUTO_TEST_CASE(continue_write_tar_file)
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())
{
TemporaryFile tmp{TEST_DATA_DIR "/tar_huge_write_test.tar"};
Expand All @@ -202,7 +205,7 @@ BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled())
reference_checksum += 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>(
"huge_data",
boost::make_function_input_iterator(encode_function, boost::infinite()),
Expand All @@ -219,5 +222,6 @@ BOOST_AUTO_TEST_CASE(write_huge_tar_file, *boost::unit_test::disabled())

BOOST_CHECK_EQUAL(checksum, reference_checksum);
}
#endif

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 69fa52a

Please sign in to comment.