mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 17:00:30 -04:00
test: add some filesystem_writer tests
This commit is contained in:
parent
a494eb749a
commit
665a4f0272
@ -923,6 +923,7 @@ if(WITH_TESTS)
|
||||
error_test
|
||||
file_access_test
|
||||
filesystem_test
|
||||
filesystem_writer_test
|
||||
fits_categorizer_test
|
||||
fragment_category_test
|
||||
incompressible_categorizer_test
|
||||
|
120
test/filesystem_writer_test.cpp
Normal file
120
test/filesystem_writer_test.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/**
|
||||
* \author Marcus Holland-Moritz (github@mhxnet.de)
|
||||
* \copyright Copyright (c) Marcus Holland-Moritz
|
||||
*
|
||||
* This file is part of dwarfs.
|
||||
*
|
||||
* dwarfs is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dwarfs is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <dwarfs/block_compressor.h>
|
||||
#include <dwarfs/filesystem_writer_factory.h>
|
||||
#include <dwarfs/thread_pool.h>
|
||||
#include <dwarfs/writer_progress.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
#include "test_logger.h"
|
||||
|
||||
using namespace dwarfs;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
TEST(filesystem_writer, compression_metadata_requirements) {
|
||||
test::test_logger lgr;
|
||||
auto os = test::os_access_mock::create_test_instance();
|
||||
writer_progress prog;
|
||||
thread_pool pool(lgr, *os, "worker", 1);
|
||||
std::ostringstream devnull;
|
||||
|
||||
block_compressor bcnull("null");
|
||||
|
||||
EXPECT_NO_THROW(filesystem_writer_factory::create(devnull, lgr, pool, prog,
|
||||
bcnull, bcnull, bcnull));
|
||||
|
||||
#ifdef DWARFS_HAVE_FLAC
|
||||
block_compressor bcflac("flac:level=1");
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcflac,
|
||||
bcnull, bcnull);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'flac [level=1]' for schema compression because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bits_per_sample'")));
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcnull,
|
||||
bcflac, bcnull);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'flac [level=1]' for metadata compression because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bits_per_sample'")));
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcnull,
|
||||
bcnull, bcflac);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'flac [level=1]' for history compression because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bits_per_sample'")));
|
||||
#endif
|
||||
|
||||
#ifdef DWARFS_HAVE_RICEPP
|
||||
block_compressor bcrice("ricepp");
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcrice,
|
||||
bcnull, bcnull);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'ricepp [block_size=128]' for schema compression because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bytes_per_sample'")));
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcnull,
|
||||
bcrice, bcnull);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'ricepp [block_size=128]' for metadata compression "
|
||||
"because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bytes_per_sample'")));
|
||||
|
||||
EXPECT_THAT(
|
||||
[&] {
|
||||
filesystem_writer_factory::create(devnull, lgr, pool, prog, bcnull,
|
||||
bcnull, bcrice);
|
||||
},
|
||||
testing::ThrowsMessage<dwarfs::runtime_error>(testing::HasSubstr(
|
||||
"cannot use 'ricepp [block_size=128]' for history compression "
|
||||
"because "
|
||||
"compression metadata requirements are not met: missing requirement "
|
||||
"'bytes_per_sample'")));
|
||||
#endif
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user