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-07-24 22:29:21 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-07-24 22:29:21 +0300
commit964d174c1c44d4810789b198bbf07271cebbe8c8 (patch)
treedc3d0ebb672e919caa2f9d2b8fb5654d230ae604 /test/tests/symlink_handle_create_close
parent084b3eb8aaae639e9a63e97245386fd78b8d8413 (diff)
i/o buffers now work as if they were span<byte>.
Implemented many of the missing functions in path_view. Implemented symlink_handle for Windows.
Diffstat (limited to 'test/tests/symlink_handle_create_close')
-rw-r--r--test/tests/symlink_handle_create_close/existing0/testfile.txt1
-rw-r--r--test/tests/symlink_handle_create_close/existing1/testfile.txt1
l---------test/tests/symlink_handle_create_close/existing1/testlink1
-rw-r--r--test/tests/symlink_handle_create_close/kernel_symlink_handle.cpp.hpp57
-rw-r--r--test/tests/symlink_handle_create_close/runner.cpp83
5 files changed, 143 insertions, 0 deletions
diff --git a/test/tests/symlink_handle_create_close/existing0/testfile.txt b/test/tests/symlink_handle_create_close/existing0/testfile.txt
new file mode 100644
index 00000000..e55f0f57
--- /dev/null
+++ b/test/tests/symlink_handle_create_close/existing0/testfile.txt
@@ -0,0 +1 @@
+niall \ No newline at end of file
diff --git a/test/tests/symlink_handle_create_close/existing1/testfile.txt b/test/tests/symlink_handle_create_close/existing1/testfile.txt
new file mode 100644
index 00000000..e55f0f57
--- /dev/null
+++ b/test/tests/symlink_handle_create_close/existing1/testfile.txt
@@ -0,0 +1 @@
+niall \ No newline at end of file
diff --git a/test/tests/symlink_handle_create_close/existing1/testlink b/test/tests/symlink_handle_create_close/existing1/testlink
new file mode 120000
index 00000000..62c74bcb
--- /dev/null
+++ b/test/tests/symlink_handle_create_close/existing1/testlink
@@ -0,0 +1 @@
+testfile.txt \ No newline at end of file
diff --git a/test/tests/symlink_handle_create_close/kernel_symlink_handle.cpp.hpp b/test/tests/symlink_handle_create_close/kernel_symlink_handle.cpp.hpp
new file mode 100644
index 00000000..04cb9098
--- /dev/null
+++ b/test/tests/symlink_handle_create_close/kernel_symlink_handle.cpp.hpp
@@ -0,0 +1,57 @@
+/* Test kernel for symlink_handle create and close
+(C) 2018 Niall Douglas <http://www.nedproductions.biz/> (5 commits)
+File Created: Jul 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"
+
+namespace symlink_handle_create_close
+{
+ LLFIO_TEST_KERNEL_DECL LLFIO_V2_NAMESPACE::result<LLFIO_V2_NAMESPACE::symlink_handle> test_kernel_symlink_handle_absolute(LLFIO_V2_NAMESPACE::symlink_handle::mode m, LLFIO_V2_NAMESPACE::symlink_handle::creation c, LLFIO_V2_NAMESPACE::symlink_handle::flag f)
+ {
+ auto h = LLFIO_V2_NAMESPACE::symlink_handle::symlink({}, "testlink", m, c, f);
+ if(h)
+ {
+ if(h.value().is_writable())
+ {
+ h.value().write("testfile.txt").value();
+ }
+ h.value().close().value();
+ }
+ return h;
+ }
+ LLFIO_TEST_KERNEL_DECL LLFIO_V2_NAMESPACE::result<LLFIO_V2_NAMESPACE::symlink_handle> test_kernel_symlink_handle_relative(LLFIO_V2_NAMESPACE::symlink_handle::mode m, LLFIO_V2_NAMESPACE::symlink_handle::creation c, LLFIO_V2_NAMESPACE::symlink_handle::flag f)
+ {
+ OUTCOME_TRY(b, LLFIO_V2_NAMESPACE::path_handle::path("."));
+ auto h = LLFIO_V2_NAMESPACE::symlink_handle::symlink(b, "testlink", m, c, f);
+ if(h)
+ {
+ if(h.value().is_writable())
+ {
+ h.value().write("testfile.txt").value();
+ }
+ h.value().close().value();
+ }
+ b.close().value();
+ return h;
+ }
+} // namespace file_handle_create_close
diff --git a/test/tests/symlink_handle_create_close/runner.cpp b/test/tests/symlink_handle_create_close/runner.cpp
new file mode 100644
index 00000000..1e14f1a0
--- /dev/null
+++ b/test/tests/symlink_handle_create_close/runner.cpp
@@ -0,0 +1,83 @@
+/* Integration test kernel for symlink_handle create and close
+(C) 2018 Niall Douglas <http://www.nedproductions.biz/> (22 commits)
+File Created: Jul 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 "kernel_symlink_handle.cpp.hpp"
+
+template <class U> inline void symlink_handle_create_close_creation(U &&f)
+{
+ using namespace KERNELTEST_V1_NAMESPACE;
+ using LLFIO_V2_NAMESPACE::result;
+ using symlink_handle = LLFIO_V2_NAMESPACE::symlink_handle;
+ static const result<void> no_such_file_or_directory = LLFIO_V2_NAMESPACE::errc::no_such_file_or_directory;
+ static const result<void> file_exists = LLFIO_V2_NAMESPACE::errc::file_exists;
+ static const result<void> function_not_supported = LLFIO_V2_NAMESPACE::errc::function_not_supported;
+ static const result<void> permission_denied = LLFIO_V2_NAMESPACE::errc::permission_denied;
+
+ // clang-format off
+ static const auto permuter(mt_permute_parameters<
+ result<void>,
+ parameters<
+ typename symlink_handle::mode,
+ typename symlink_handle::creation,
+ typename symlink_handle::flag
+ >,
+ precondition::filesystem_setup_parameters,
+ postcondition::filesystem_comparison_structure_parameters
+ >(
+ {
+
+ // Does the mode parameter have the expected side effects?
+ { success(), { symlink_handle::mode::none, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::attr_read, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::attr_write, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { function_not_supported, { symlink_handle::mode::append, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::none, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+ { success(), { symlink_handle::mode::attr_read, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+ { success(), { symlink_handle::mode::attr_write, symlink_handle::creation::if_needed, symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+
+ // Does the creation parameter have the expected side effects?
+ { no_such_file_or_directory, { symlink_handle::mode::write, symlink_handle::creation::open_existing , symlink_handle::flag::none }, { "existing0" }, { "existing0" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::open_existing , symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::only_if_not_exist, symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+ { file_exists, { symlink_handle::mode::write, symlink_handle::creation::only_if_not_exist, symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::if_needed , symlink_handle::flag::none }, { "existing0" }, { "existing1" }},
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::if_needed , symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+ { function_not_supported, { symlink_handle::mode::write, symlink_handle::creation::truncate , symlink_handle::flag::none }, { "existing1" }, { "existing1" }},
+
+ // Does the flag parameter have the expected side effects?
+ { success(), { symlink_handle::mode::write, symlink_handle::creation::open_existing, symlink_handle::flag::unlink_on_first_close }, { "existing1" }, { "existing0" }}
+ },
+ precondition::filesystem_setup(),
+ postcondition::filesystem_comparison_structure()
+ ));
+ // clang-format on
+
+ auto results = permuter(std::forward<U>(f));
+ check_results_with_boost_test(permuter, results);
+}
+
+KERNELTEST_TEST_KERNEL(unit, llfio, symlink_handle_create_close, symlink_handle, "Tests that llfio::symlink_handle::symlink()'s parameters with absolute paths work as expected", symlink_handle_create_close_creation(symlink_handle_create_close::test_kernel_symlink_handle_absolute))
+KERNELTEST_TEST_KERNEL(unit, llfio, symlink_handle_create_close, symlink_handle, "Tests that llfio::symlink_handle::symlink()'s parameters with relative paths work as expected", symlink_handle_create_close_creation(symlink_handle_create_close::test_kernel_symlink_handle_relative))