From 782fdc5cb58a357e9699e37ab19de3c80cc1099b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jur=C4=8Da?= Date: Fri, 1 Dec 2023 13:31:39 +0100 Subject: [PATCH] Fix data type in ReadAction and WriteAction --- include/filestorm/actions/rw_actions.h | 9 +++------ test/CMakeLists.txt | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/filestorm/actions/rw_actions.h b/include/filestorm/actions/rw_actions.h index f1d624d..6185569 100644 --- a/include/filestorm/actions/rw_actions.h +++ b/include/filestorm/actions/rw_actions.h @@ -23,7 +23,7 @@ class ReadAction : public VirtualMonitoredAction, public FileActionAttributes { protected: - long long m_read_bytes = 0; + u_int64_t m_read_bytes = 0; inline off_t get_offset() { static off_t offset = 0; @@ -69,7 +69,6 @@ class ReadAction : public VirtualMonitoredAction, public FileActionAttributes { throw std::runtime_error( fmt::format("{}::work: error opening file: {}", typeid(*this).name(), strerror(errno))); } - size_t offset = 0; spdlog::debug("{}::work: file_size: {}", typeid(*this).name(), get_file_size()); if (is_time_based()) { @@ -105,7 +104,6 @@ class RandomReadAction : public ReadAction { std::vector m_offsets; inline off_t get_offset() { - static off_t offset = 0; static off_t block_size_bytes = get_block_size().convert().get_value(); static ssize_t file_size_bytes = get_file_size().convert().get_value(); @@ -127,7 +125,7 @@ class RandomReadAction : public ReadAction { class WriteAction : public VirtualMonitoredAction, public FileActionAttributes { protected: - long long m_written_bytes = 0; + u_int64_t m_written_bytes = 0; inline off_t get_offset() { static off_t offset = 0; @@ -178,7 +176,7 @@ class WriteAction : public VirtualMonitoredAction, public FileActionAttributes { if (fd == -1) { throw std::runtime_error("WriteAction::work: error opening file"); } - size_t offset = 0; + spdlog::debug("{}::work: file_size: {}", typeid(*this).name(), get_file_size()); generate_random_chunk(line.get(), get_block_size().convert().get_value()); if (is_time_based()) { @@ -216,7 +214,6 @@ class RandomWriteAction : public WriteAction { std::vector m_offsets; inline off_t get_offset() { - static off_t offset = 0; static off_t block_size_bytes = get_block_size().convert().get_value(); static ssize_t file_size_bytes = get_file_size().convert().get_value(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a7928d0..ccf4958 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,6 +18,9 @@ include(../cmake/CPM.cmake) CPMAddPackage("gh:doctest/doctest@2.4.9") CPMAddPackage("gh:TheLartians/Format.cmake@1.7.3") +find_package(fmt REQUIRED) +find_package(spdlog REQUIRED) + if(TEST_INSTALLED_VERSION) find_package(filestorm REQUIRED) else() @@ -28,7 +31,7 @@ endif() file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) add_executable(${PROJECT_NAME} ${sources}) -target_link_libraries(${PROJECT_NAME} doctest::doctest filestorm::filestorm) +target_link_libraries(${PROJECT_NAME} doctest::doctest filestorm::filestorm fmt::fmt spdlog::spdlog) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) # enable compiler warnings