diff --git a/repertory/repertory_test/src/direct_open_file_test.cpp b/repertory/repertory_test/src/direct_open_file_test.cpp index 522f8e46..de9ebc53 100644 --- a/repertory/repertory_test/src/direct_open_file_test.cpp +++ b/repertory/repertory_test/src/direct_open_file_test.cpp @@ -52,11 +52,14 @@ TEST_F(direct_open_file_test, read_full_file) { fsi.directory = false; fsi.size = test_chunk_size * 32U; + std::mutex read_mtx; EXPECT_CALL(provider, read_file_bytes) - .WillRepeatedly([&source_file](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &source_file]( + const std::string & /* api_path */, std::size_t size, + std::uint64_t offset, data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -111,11 +114,14 @@ TEST_F(direct_open_file_test, read_full_file_in_reverse) { fsi.directory = false; fsi.size = test_chunk_size * 32U; + std::mutex read_mtx; EXPECT_CALL(provider, read_file_bytes) - .WillRepeatedly([&source_file](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &source_file]( + const std::string & /* api_path */, std::size_t size, + std::uint64_t offset, data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -170,11 +176,14 @@ TEST_F(direct_open_file_test, read_full_file_in_partial_chunks) { fsi.api_path = "/test.txt"; fsi.size = test_chunk_size * 32U; + std::mutex read_mtx; EXPECT_CALL(provider, read_file_bytes) - .WillRepeatedly([&source_file](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &source_file]( + const std::string & /* api_path */, std::size_t size, + std::uint64_t offset, data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -226,11 +235,14 @@ TEST_F(direct_open_file_test, read_full_file_in_partial_chunks_in_reverse) { fsi.api_path = "/test.txt"; fsi.size = test_chunk_size * 32U; + std::mutex read_mtx; EXPECT_CALL(provider, read_file_bytes) - .WillRepeatedly([&source_file](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &source_file]( + const std::string & /* api_path */, std::size_t size, + std::uint64_t offset, data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); diff --git a/repertory/repertory_test/src/ring_buffer_open_file_test.cpp b/repertory/repertory_test/src/ring_buffer_open_file_test.cpp index d8d0f919..292cb8fd 100644 --- a/repertory/repertory_test/src/ring_buffer_open_file_test.cpp +++ b/repertory/repertory_test/src/ring_buffer_open_file_test.cpp @@ -308,11 +308,14 @@ TEST_F(ring_buffer_open_file_test, read_full_file) { fsi.size = test_chunk_size * 33u + 11u; fsi.source_path = test::generate_test_file_name("ring_buffer_open_file"); + std::mutex read_mtx; EXPECT_CALL(mp, read_file_bytes) - .WillRepeatedly([&nf](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &nf](const std::string & /* api_path */, + std::size_t size, std::uint64_t offset, + data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -371,11 +374,14 @@ TEST_F(ring_buffer_open_file_test, read_full_file_in_reverse) { fsi.size = test_chunk_size * 32u; fsi.source_path = test::generate_test_file_name("ring_buffer_open_file"); + std::mutex read_mtx; EXPECT_CALL(mp, read_file_bytes) - .WillRepeatedly([&nf](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &nf](const std::string & /* api_path */, + std::size_t size, std::uint64_t offset, + data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -434,11 +440,14 @@ TEST_F(ring_buffer_open_file_test, read_full_file_in_partial_chunks) { fsi.size = test_chunk_size * 32u; fsi.source_path = test::generate_test_file_name("test"); + std::mutex read_mtx; EXPECT_CALL(mp, read_file_bytes) - .WillRepeatedly([&nf](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &nf](const std::string & /* api_path */, + std::size_t size, std::uint64_t offset, + data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size); @@ -499,11 +508,14 @@ TEST_F(ring_buffer_open_file_test, fsi.size = test_chunk_size * 32u; fsi.source_path = test::generate_test_file_name("ring_buffer_open_file"); + std::mutex read_mtx; EXPECT_CALL(mp, read_file_bytes) - .WillRepeatedly([&nf](const std::string & /* api_path */, - std::size_t size, std::uint64_t offset, - data_buffer &data, - stop_type &stop_requested) -> api_error { + .WillRepeatedly([&read_mtx, &nf](const std::string & /* api_path */, + std::size_t size, std::uint64_t offset, + data_buffer &data, + stop_type &stop_requested) -> api_error { + mutex_lock lock(read_mtx); + EXPECT_FALSE(stop_requested); std::size_t bytes_read{}; data.resize(size);