chore(dwarfsextract): use iolayer abstractions for mapping image

This commit is contained in:
Marcus Holland-Moritz 2024-01-06 00:00:08 +01:00
parent aaf8c91366
commit a1ba52d146
2 changed files with 9 additions and 10 deletions

View File

@ -35,6 +35,7 @@
#include "dwarfs/logger.h"
#include "dwarfs/mmap.h"
#include "dwarfs/options.h"
#include "dwarfs/os_access.h"
#include "dwarfs/performance_monitor.h"
#include "dwarfs/tool.h"
#include "dwarfs/util.h"
@ -137,7 +138,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
std::shared_ptr<performance_monitor> perfmon =
performance_monitor::create(perfmon_enabled);
filesystem_v2 fs(lgr, std::make_shared<mmap>(filesystem), fsopts, perfmon);
filesystem_v2 fs(lgr, iol.os->map_file(filesystem), fsopts, perfmon);
filesystem_extractor fsx(lgr);
if (format.empty()) {

View File

@ -54,7 +54,6 @@ namespace {
auto test_dir = fs::path(TEST_DATA_DIR).make_preferred();
auto audio_data_dir = test_dir / "pcmaudio";
auto test_data_image = test_dir / "data.dwarfs";
enum class input_mode {
from_file,
@ -429,14 +428,13 @@ TEST_F(dwarfsextract_main_test, cmdline_help_arg) {
}
#ifdef DWARFS_PERFMON_ENABLED
TEST_F(dwarfsextract_main_test, perfmon) {
// TODO: passing in test_data_image this way only only works because
// dwarfsextract_main does not currently use the os_access abstraction
auto exit_code = run({"-i", test_data_image.string(), "-f", "mtree",
"--perfmon", "filesystem_v2,inode_reader_v2"});
EXPECT_EQ(exit_code, 0);
auto outs = out();
auto errs = err();
TEST(dwarfsextract_test, perfmon) {
auto t = dwarfsextract_tester::create_with_image();
EXPECT_EQ(0, t.run({"-i", "image.dwarfs", "-f", "mtree", "--perfmon",
"filesystem_v2,inode_reader_v2"}))
<< t.err();
auto outs = t.out();
auto errs = t.err();
EXPECT_GT(outs.size(), 100);
EXPECT_FALSE(errs.empty());
EXPECT_THAT(errs, ::testing::HasSubstr("[filesystem_v2.readv_future]"));