Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-04-11 14:09:48 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-04-11 14:09:48 +0300
commit487b9a266f9a2d5e81902fde842c41cbd53f1ce4 (patch)
treeaaf7fed1f6d2b30b0ee7c25cc81bf608e336b7f0 /test/tests
parented04b40b799d1cb2b4c1787b9a1089050e3c89ae (diff)
Convert AFIO over to use std::byte for buffers instead of char.
Diffstat (limited to 'test/tests')
-rw-r--r--test/tests/async_io.cpp39
-rw-r--r--test/tests/coroutines.cpp4
-rw-r--r--test/tests/map_handle_create_close/runner.cpp8
-rw-r--r--test/tests/mapped_span.cpp3
-rw-r--r--test/tests/section_handle_create_close/runner.cpp2
5 files changed, 29 insertions, 27 deletions
diff --git a/test/tests/async_io.cpp b/test/tests/async_io.cpp
index ed202d11..bb4be9fa 100644
--- a/test/tests/async_io.cpp
+++ b/test/tests/async_io.cpp
@@ -34,7 +34,7 @@ static inline void TestAsyncFileHandle()
std::vector<std::pair<std::future<afio::async_file_handle::const_buffers_type>, afio::async_file_handle::io_state_ptr>> futures;
futures.reserve(1024);
h.truncate(1024 * 4096).value();
- alignas(4096) char buffer[4096];
+ alignas(4096) afio::byte buffer[4096];
memset(buffer, 78, 4096); // NOLINT
afio::async_file_handle::const_buffer_type bt{buffer, sizeof(buffer)}; // NOLINT
for(size_t n = 0; n < 1024; n++)
@@ -42,24 +42,25 @@ static inline void TestAsyncFileHandle()
retry:
std::promise<afio::async_file_handle::const_buffers_type> p;
auto f(p.get_future());
- auto schedule_io = [&]{ return h
- .async_write({bt, n * 4096}, [ p = std::move(p), n ](afio::async_file_handle *, afio::async_file_handle::io_result<afio::async_file_handle::const_buffers_type> & result) mutable {
- (void) n;
- if(!result && result.error() == std::errc::resource_unavailable_try_again)
- {
- std::cout << "*** Completion handler saw error " << result.error() << std::endl;
- }
- try
- {
- p.set_value(result.value());
- // std::cout << "Written block " << n << " successfully" << std::endl;
- }
- catch(...)
- {
- p.set_exception(std::current_exception());
- // std::cout << "Written block " << n << " unsuccessfully" << std::endl;
- }
- }); };
+ auto schedule_io = [&] {
+ return h.async_write({bt, n * 4096}, [ p = std::move(p), n ](afio::async_file_handle *, afio::async_file_handle::io_result<afio::async_file_handle::const_buffers_type> & result) mutable {
+ (void) n;
+ if(!result && result.error() == std::errc::resource_unavailable_try_again)
+ {
+ std::cout << "*** Completion handler saw error " << result.error() << std::endl;
+ }
+ try
+ {
+ p.set_value(result.value());
+ // std::cout << "Written block " << n << " successfully" << std::endl;
+ }
+ catch(...)
+ {
+ p.set_exception(std::current_exception());
+ // std::cout << "Written block " << n << " unsuccessfully" << std::endl;
+ }
+ });
+ };
auto g(schedule_io());
if(!g && g.error() == std::errc::resource_unavailable_try_again)
{
diff --git a/test/tests/coroutines.cpp b/test/tests/coroutines.cpp
index 35c89291..ec534793 100644
--- a/test/tests/coroutines.cpp
+++ b/test/tests/coroutines.cpp
@@ -43,7 +43,7 @@ static inline void TestAsyncFileHandleCoroutines()
// Launch 8 coroutines, each writing 4Kb of chars 0-8 to every 32Kb block
auto coroutine = [&h](size_t no) -> std::future<void> {
- std::vector<char, afio::utils::page_allocator<char>> buffer(4096);
+ std::vector<afio::byte, afio::utils::page_allocator<afio::byte>> buffer(4096);
memset(buffer.data(), (int) ('0' + no), 4096);
afio::async_file_handle::const_buffer_type bt{buffer.data(), buffer.size()};
for(size_t n = 0; n < 128; n++)
@@ -71,7 +71,7 @@ static inline void TestAsyncFileHandleCoroutines()
//! [coroutines_example]
// Check that the file has the right contents
- alignas(4096) char buffer1[4096], buffer2[4096];
+ alignas(4096) afio::byte buffer1[4096], buffer2[4096];
afio::async_file_handle::extent_type offset = 0;
for(size_t n = 0; n < 128; n++)
{
diff --git a/test/tests/map_handle_create_close/runner.cpp b/test/tests/map_handle_create_close/runner.cpp
index f9eabbc7..b0e4abfd 100644
--- a/test/tests/map_handle_create_close/runner.cpp
+++ b/test/tests/map_handle_create_close/runner.cpp
@@ -72,7 +72,7 @@ template <class U> inline void map_handle_create_close_(U &&f)
{
// Create a temporary backing file
temph = file_handle::file({}, "tempfile", file_handle::mode::write, file_handle::creation::if_needed).value();
- temph.write(0, { {"I am some file data", 19} }).value();
+ temph.write(0, { {reinterpret_cast<const AFIO_V2_NAMESPACE::byte *>("I am some file data"), 19} }).value();
}
else
{
@@ -100,13 +100,13 @@ template <class U> inline void map_handle_create_close_(U &&f)
//#define KERNELTEST_CHECK(a, ...) BOOST_CHECK(__VA_ARGS__)
if (testreturn)
{
- char *addr = maph.address();
+ AFIO_V2_NAMESPACE::byte *addr = maph.address();
section_handle::flag flags = std::get<1>(std::get<1>(permuter[idx]));
KERNELTEST_CHECK(testreturn, maph.length() > 0);
KERNELTEST_CHECK(testreturn, addr != nullptr);
if (!(flags & section_handle::flag::nocommit) && addr != nullptr)
{
- char buffer[64];
+ AFIO_V2_NAMESPACE::byte buffer[64];
// Make sure the backing file is appearing in the map
if (use_file_backing && maph.is_readable())
{
@@ -130,7 +130,7 @@ template <class U> inline void map_handle_create_close_(U &&f)
{
memcpy(addr, "NIALL was here", 14);
// Make sure maph's write() works
- maph.write(1, { {"iall", 4} });
+ maph.write(1, { {reinterpret_cast<const AFIO_V2_NAMESPACE::byte *>("iall"), 4} });
// Make sure data written to the map turns up in the file
if (use_file_backing)
{
diff --git a/test/tests/mapped_span.cpp b/test/tests/mapped_span.cpp
index cd776425..469a1453 100644
--- a/test/tests/mapped_span.cpp
+++ b/test/tests/mapped_span.cpp
@@ -64,6 +64,7 @@ static inline void TestMappedView2()
{
using namespace AFIO_V2_NAMESPACE;
using AFIO_V2_NAMESPACE::file_handle;
+ using AFIO_V2_NAMESPACE::byte;
{
std::error_code ec;
filesystem::remove("testfile", ec);
@@ -71,7 +72,7 @@ static inline void TestMappedView2()
mapped_file_handle mfh = mapped_file_handle::mapped_file(1024 * 1024, {}, "testfile", file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::all, file_handle::flag::unlink_on_close).value();
BOOST_CHECK(mfh.address() == nullptr);
mfh.truncate(10000 * sizeof(int)).value();
- char *addr = mfh.address();
+ byte *addr = mfh.address();
BOOST_CHECK(addr != nullptr);
algorithm::mapped_span<int> v1(mfh);
diff --git a/test/tests/section_handle_create_close/runner.cpp b/test/tests/section_handle_create_close/runner.cpp
index 2df9bc87..9b5d63f3 100644
--- a/test/tests/section_handle_create_close/runner.cpp
+++ b/test/tests/section_handle_create_close/runner.cpp
@@ -70,7 +70,7 @@ template <class U> inline void section_handle_create_close_(U &&f)
if (use_file_backing)
{
temph = file_handle::file({}, "tempfile", file_handle::mode::write, file_handle::creation::if_needed).value();
- temph.write(0, { {"niall is not here", 17} }).value();
+ temph.write(0, { {reinterpret_cast<const AFIO_V2_NAMESPACE::byte *>("niall is not here"), 17} }).value();
}
else
{