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
path: root/test
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-09-01 00:05:28 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-09-01 00:05:28 +0300
commitf95f2c8777ea373cf733fe2a21dae21789114bc0 (patch)
tree7c5fe267d20c38535acd8b54ef114dca866da091 /test
parent04dc2d13836c1fd69bd47aafc5772a07a0d1eb76 (diff)
Add missing large pages test.
Diffstat (limited to 'test')
-rw-r--r--test/tests/large_pages.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/test/tests/large_pages.cpp b/test/tests/large_pages.cpp
new file mode 100644
index 00000000..d65f4c11
--- /dev/null
+++ b/test/tests/large_pages.cpp
@@ -0,0 +1,105 @@
+/* Integration test kernel for large page support
+(C) 2017 Niall Douglas <http://www.nedproductions.biz/> (2 commits)
+File Created: Aug 2018
+
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License in the accompanying file
+Licence.txt or at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file Licence.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+#include "../test_kernel_decl.hpp"
+
+static inline void TestLargeMemMappedPages()
+{
+ using namespace LLFIO_V2_NAMESPACE;
+ using LLFIO_V2_NAMESPACE::byte;
+ auto pagesizes = utils::page_sizes();
+ if(pagesizes.size() == 1)
+ {
+ BOOST_TEST_MESSAGE("Large page support not available on this hardware, or to this privilege of user. So skipping this test.");
+ return;
+ }
+ map_handle mh(map_handle::map(1024 * 1024, false, section_handle::flag::readwrite | section_handle::flag::page_sizes_1).value());
+ BOOST_CHECK(mh.address() != nullptr);
+ BOOST_CHECK(mh.page_size() == pagesizes[1]);
+ BOOST_CHECK(mh.length() == pagesizes[1]);
+ mh.write(0, {{(const byte *) "hello world", 11}}).value();
+}
+
+static inline void TestLargeKernelMappedPages()
+{
+ using namespace LLFIO_V2_NAMESPACE;
+ using LLFIO_V2_NAMESPACE::file_handle;
+ using LLFIO_V2_NAMESPACE::byte;
+ auto pagesizes = utils::page_sizes();
+ if(pagesizes.size() == 1)
+ {
+ BOOST_TEST_MESSAGE("Large page support not available on this hardware, or to this privilege of user. So skipping this test.");
+ return;
+ }
+ // Windows appears to refuse section_handle::flag::page_sizes_1 during section creation when it is backed by a file
+ auto _sh(section_handle::section(1024 * 1024, path_discovery::memory_backed_temporary_files_directory(), section_handle::flag::readwrite));
+#ifdef _WIN32
+ if(!_sh)
+ {
+ BOOST_TEST_MESSAGE("Failed to create kernel memory backed file on Windows with large pages which does not work until at least Windows 10 1803, so ignoring this test failure.");
+ return;
+ }
+#endif
+ section_handle sh(std::move(_sh).value());
+ map_handle mh(map_handle::map(sh, 0, 0, section_handle::flag::readwrite | section_handle::flag::page_sizes_1).value());
+ BOOST_CHECK(mh.address() != nullptr);
+ BOOST_CHECK(mh.page_size() == pagesizes[1]);
+ BOOST_CHECK(mh.length() == pagesizes[1]);
+ mh.write(0, {{(const byte *) "hello world", 11}}).value();
+}
+
+static inline void TestLargeFileMappedPages()
+{
+ using namespace LLFIO_V2_NAMESPACE;
+ using LLFIO_V2_NAMESPACE::file_handle;
+ using LLFIO_V2_NAMESPACE::byte;
+ auto pagesizes = utils::page_sizes();
+ if(pagesizes.size() == 1)
+ {
+ BOOST_TEST_MESSAGE("Large page support not available on this hardware, or to this privilege of user. So skipping this test.");
+ return;
+ }
+ file_handle fh = file_handle::file({}, "testfile", file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::all, file_handle::flag::unlink_on_first_close).value();
+ fh.truncate(1024 * 1024).value();
+ // Windows appears to refuse section_handle::flag::page_sizes_1 during section creation when it is backed by a file
+ auto _sh(section_handle::section(fh, 0, section_handle::flag::readwrite));
+ section_handle sh(std::move(_sh).value());
+ auto _mh(map_handle::map(sh, 0, 0, section_handle::flag::readwrite | section_handle::flag::page_sizes_1));
+#ifdef _WIN32
+ if(!_mh)
+ {
+ BOOST_TEST_MESSAGE("Failed to create large page map of file which does not work until at least Windows 10 1803, so ignoring this test failure.");
+ return;
+ }
+#endif
+ map_handle mh(std::move(_mh).value());
+ BOOST_CHECK(mh.address() != nullptr);
+ BOOST_CHECK(mh.page_size() == pagesizes[1]);
+ BOOST_CHECK(mh.length() == pagesizes[1]);
+ mh.write(0, {{(const byte *) "hello world", 11}}).value();
+}
+
+KERNELTEST_TEST_KERNEL(integration, llfio, map_handle, large_mem_mapped_pages, "Tests that large page support for allocating memory works as expected", TestLargeMemMappedPages())
+KERNELTEST_TEST_KERNEL(integration, llfio, map_handle, large_kernel_mapped_pages, "Tests that large page support for mapping kernel memory works as expected", TestLargeKernelMappedPages())
+KERNELTEST_TEST_KERNEL(integration, llfio, map_handle, large_file_mapped_pages, "Tests that large page support for mapping files works as expected", TestLargeFileMappedPages())