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>2021-03-15 14:37:37 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-03-15 14:37:37 +0300
commit17a15470b8d079625732bccfc96a3dd45e18f1c1 (patch)
tree7313433d449358ac1a5094b6fcf97de275b4e9cd /test
parent545a722a055dcc38e7f80520a7a34008bfa9a86f (diff)
Fix inability to open directory junctions on Windows using `symlink_handle` (issue #73).
Diffstat (limited to 'test')
-rw-r--r--test/tests/issue0073.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tests/issue0073.cpp b/test/tests/issue0073.cpp
new file mode 100644
index 00000000..75f82ce2
--- /dev/null
+++ b/test/tests/issue0073.cpp
@@ -0,0 +1,67 @@
+/* Integration test kernel for issue #73 Windows directory junctions cannot be opened with symlink_handle
+(C) 2021 Niall Douglas <http://www.nedproductions.biz/> (2 commits)
+File Created: Mar 2021
+
+
+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 TestIssue0073()
+{
+#ifndef _WIN32
+ return;
+#endif
+ namespace llfio = LLFIO_V2_NAMESPACE;
+
+ auto tempdirh = llfio::temp_directory().value();
+ auto untempdir = llfio::make_scope_exit([&]() noexcept { (void) llfio::algorithm::reduce(std::move(tempdirh)); });
+ std::cout << "NOTE: Test directory can be found at " << tempdirh.current_path().value() << std::endl;
+
+ // Test windows junctions
+ {
+ auto dirh =
+ llfio::directory_handle::directory(tempdirh, "testjunction", llfio::symlink_handle::mode::write, llfio::symlink_handle::creation::if_needed).value();
+ auto h = llfio::symlink_handle::symlink(dirh, {}, llfio::symlink_handle::mode::write).value();
+ h.write({llfio::symlink_handle::const_buffers_type("linkcontent", llfio::symlink_handle::symlink_type::win_junction)}).value();
+ auto rb = h.read().value();
+ BOOST_CHECK(rb.type() == llfio::symlink_handle::symlink_type::win_junction);
+ BOOST_CHECK(rb.path().path() == "linkcontent");
+ h.unlink().value();
+ }
+
+ // Test normal symbolic links
+ {
+ auto h_ = llfio::symlink_handle::symlink(tempdirh, "testlink", llfio::symlink_handle::mode::write, llfio::symlink_handle::creation::if_needed);
+ if(!h_ && h_.error() == llfio::errc::function_not_supported)
+ {
+ std::cout << "NOTE: Failed to create symbolic link, assuming lack of SeCreateSymbolicLinkPrivilege privileges." << std::endl;
+ return;
+ }
+ auto h = std::move(h_).value();
+ h.write("linkcontent").value();
+ auto rb = h.read().value();
+ BOOST_CHECK(rb.type() == llfio::symlink_handle::symlink_type::symbolic);
+ BOOST_CHECK(rb.path().path() == "linkcontent");
+ h.unlink().value();
+ }
+}
+
+KERNELTEST_TEST_KERNEL(regression, llfio, issues, 0073, "Tests issue #0073 Windows directory junctions cannot be opened with symlink_handle", TestIssue0073())